author | terom |
Wed, 17 Dec 2008 00:40:22 +0000 | |
changeset 381 | 9b35bc329d23 |
parent 332 | 78657bf06302 |
child 400 | d64bf28c4340 |
permissions | -rw-r--r-- |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
#ifndef NETWORKCLIENT_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
2 |
#define NETWORKCLIENT_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
4 |
// forward-declare |
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
5 |
class NetworkClient; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
6 |
class NetworkClientLocalPlayer; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
7 |
class NetworkClientRemotePlayer; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
8 |
|
332
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
9 |
#include "../GameState.hh" |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
10 |
#include "../Engine.hh" |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
11 |
#include "Session.hh" |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
12 |
#include "Object.hh" |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
13 |
|
294 | 14 |
/** |
15 |
* Our specialized NetworkObject_ClientController that overrides handle_create to create the right kind of |
|
16 |
* object (a subclass of NetowrkClientObject). |
|
17 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
18 |
class NetworkClientController : public NetworkObject_ClientController { |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
19 |
protected: |
294 | 20 |
/** |
21 |
* The NetworkClient |
|
22 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
23 |
NetworkClient &client; |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
24 |
|
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
25 |
public: |
294 | 26 |
/** |
27 |
* Control objects on the given client using the client.netsession's NETCHAN_CORE channel |
|
28 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
29 |
NetworkClientController (NetworkClient &client); |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
30 |
|
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
31 |
protected: |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
32 |
/** |
294 | 33 |
* We override handle_create from NetworkObject_ClientController to call one of the on_* methods, which creates |
34 |
* a NetworkClientObject subclass |
|
35 |
* |
|
36 |
* @see NetworkObject_ClientController::handle_create |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
37 |
*/ |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
38 |
virtual void handle_create (NetworkObjectID obj_id, NetworkMessageID msg_id, NetworkPacketInput &pkt, NetworkNode *node); |
294 | 39 |
|
40 |
/** |
|
41 |
* Handle NETMSG_SERVER_HELLO -> NetworkClientLocalPlayer |
|
42 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
43 |
void on_server_hello (NetworkObjectID obj_id, NetworkPacketInput &pkt); |
294 | 44 |
|
45 |
/** |
|
46 |
* Handle NETMSG_PLAYER_INFO -> NetworkClientRemotePlayer |
|
47 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
48 |
void on_player_info (NetworkObjectID obj_id, NetworkPacketInput &pkt); |
294 | 49 |
|
50 |
/** |
|
51 |
* Handle NETMSG_PLAYER_JOIN -> NetworkClientRemotePlayer |
|
52 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
53 |
void on_player_join (NetworkObjectID obj_id, NetworkPacketInput &pkt); |
294 | 54 |
|
55 |
/** |
|
56 |
* Handle NETMSG_PROJECTILE_PLAYER_FIRED -> NetworkClientProjectile |
|
57 |
*/ |
|
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
274
diff
changeset
|
58 |
void on_projectile_player_fired (NetworkObjectID obj_id, NetworkPacketInput &pkt); |
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
59 |
}; |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
60 |
|
294 | 61 |
/** |
62 |
* Our NetworkClient, that connects to a NetworkServer. This has the GameState, NetworkSession, NetworkClientController, etc. |
|
63 |
*/ |
|
187 | 64 |
class NetworkClient { |
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
65 |
friend class NetworkClientController; |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
66 |
friend class NetworkClientObject; |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
67 |
friend class NetworkClientPlayerBase; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
68 |
friend class NetworkClientLocalPlayer; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
69 |
friend class NetworkClientRemotePlayer; |
223 | 70 |
friend class NetworkClientProjectile; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
71 |
|
187 | 72 |
protected: |
294 | 73 |
/** |
332
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
74 |
* The Engine |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
75 |
*/ |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
76 |
Engine &engine; |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
77 |
|
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
78 |
/** |
294 | 79 |
* The GameState |
80 |
*/ |
|
187 | 81 |
GameState &state; |
294 | 82 |
|
187 | 83 |
CL_SlotContainer slots; |
294 | 84 |
|
85 |
/** |
|
86 |
* The connect()-mode NetworkSession |
|
87 |
*/ |
|
88 |
NetworkSession netsession; |
|
187 | 89 |
|
294 | 90 |
/** |
91 |
* The server NetworkNode from Netsession::connect |
|
92 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
93 |
NetworkNode *server; |
294 | 94 |
|
95 |
/** |
|
96 |
* Our specialized NetworkObject_ClientController |
|
97 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
98 |
NetworkClientController controller; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
99 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
100 |
public: |
294 | 101 |
/** |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
332
diff
changeset
|
102 |
* Create a NetworkClient with the given GameState, connecting a server on the given NetworkEndpoint |
294 | 103 |
* |
332
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
104 |
* @param engine the Engine we're running as |
294 | 105 |
* @param state the GameState to use |
106 |
* @param connect_to the address to connect to |
|
107 |
*/ |
|
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
332
diff
changeset
|
108 |
NetworkClient (Engine &engine, GameState &state, const NetworkEndpoint &connect_to); |
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
109 |
|
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
110 |
protected: |
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
111 |
/** |
332
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
112 |
* We have disconnected from the server |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
113 |
*/ |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
114 |
void on_disconnected (void); |
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
115 |
|
78657bf06302
handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents:
330
diff
changeset
|
116 |
/** |
294 | 117 |
* Receive the NETCHAN_TERRAIN_ARRAY message from the server and apply it to our GameState::world terrain |
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
118 |
*/ |
203
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
119 |
void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
120 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
121 |
public: |
294 | 122 |
/** |
123 |
* Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently |
|
124 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
125 |
void player_quit (NetworkClientRemotePlayer *player); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
126 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
127 |
|
294 | 128 |
/** |
129 |
* Our base NetworkObject_Client object, containing the NetworkClient and a CL_SlotContainer for conveniance |
|
130 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
131 |
class NetworkClientObject : public NetworkObject_Client { |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
132 |
protected: |
294 | 133 |
/** |
134 |
* The NetworkClient |
|
135 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
136 |
NetworkClient &client; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
137 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
138 |
CL_SlotContainer slots; |
294 | 139 |
|
140 |
/** |
|
141 |
* Construct this using the given client and obj_id, passing the client.controller and obj_id to the |
|
142 |
* NetworkObject_Client's constructor |
|
143 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
144 |
NetworkClientObject (NetworkClient &client, NetworkObjectID obj_id); |
223 | 145 |
}; |
146 |
||
294 | 147 |
/** |
148 |
* Our base class for NetworkClient Players, this implements most of the server -> client messages |
|
149 |
* |
|
150 |
* This inherits from NetworkClientObject and virtually from Player, as classes should inherit from both this and |
|
151 |
* LocalPlayer/RemotePlayer |
|
152 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
153 |
class NetworkClientPlayerBase : public NetworkClientObject, public virtual Player { |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
154 |
protected: |
294 | 155 |
/** |
156 |
* Dummy-initialize Player, initialize NetworkClientObject, and hook up our signals |
|
157 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
158 |
NetworkClientPlayerBase (NetworkClient &client, NetworkObjectID obj_id, Vector position); |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
159 |
|
302 | 160 |
protected: |
161 |
// @{ |
|
162 |
/** |
|
163 |
* These should never be called directly, always via the network |
|
164 |
*/ |
|
165 |
virtual void spawn (Vector position); |
|
166 |
virtual void respawn (TimeMS dt); |
|
167 |
// @} |
|
303 | 168 |
|
169 |
/** |
|
170 |
* Ignore, the servers tells us this |
|
171 |
*/ |
|
172 |
virtual void die (bool start_timer = true); |
|
302 | 173 |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
174 |
private: |
294 | 175 |
/** |
176 |
* NETMSG_PLAYER_POSITION -> PhysicsObject::updatePhysics |
|
177 |
*/ |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
178 |
void on_position (NetworkPacketInput &pkt); |
294 | 179 |
|
180 |
/** |
|
181 |
* NETMSG_PLAYER_DIG -> Player::handleDig |
|
182 |
*/ |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
183 |
void on_dig (NetworkPacketInput &pkt); |
294 | 184 |
|
185 |
/** |
|
186 |
* NETMSG_PLAYER_WEAPON_CHANGE -> Player::rope.handleChangeWeapon |
|
187 |
*/ |
|
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
224
diff
changeset
|
188 |
void on_weapon_change (NetworkPacketInput &pkt); |
294 | 189 |
|
190 |
/** |
|
191 |
* NETMSG_PLAYER_ROPE_THROW -> Player::rope.updateState(ROPE_FLYING) |
|
192 |
*/ |
|
241 | 193 |
void on_rope_throw (NetworkPacketInput &pkt); |
294 | 194 |
|
195 |
/** |
|
196 |
* NETMSG_PLAYER_ROPE_FIXED -> Player::rope.updateState(ROPE_FIXED) |
|
197 |
*/ |
|
241 | 198 |
void on_rope_fixed (NetworkPacketInput &pkt); |
294 | 199 |
|
200 |
/** |
|
201 |
* NETMSG_PLAYER_ROPE_RELEASED -> Player::rope.updateState(ROPE_FOLDED) |
|
202 |
*/ |
|
241 | 203 |
void on_rope_released (NetworkPacketInput &pkt); |
294 | 204 |
|
205 |
/** |
|
206 |
* NETMSG_PLAYER_ROPE_LENGTH -> Player::Rope.updateLength |
|
207 |
*/ |
|
241 | 208 |
void on_rope_length (NetworkPacketInput &pkt); |
302 | 209 |
|
210 |
/** |
|
211 |
* NETMSG_PLAYER_SPAWN -> Player::spawn |
|
212 |
*/ |
|
213 |
void on_spawn (NetworkPacketInput &pkt); |
|
214 |
||
215 |
/** |
|
216 |
* NETMSG_PLAYER_Die -> Player::die |
|
217 |
*/ |
|
218 |
void on_die (NetworkPacketInput &pkt); |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
219 |
}; |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
220 |
|
294 | 221 |
/** |
222 |
* Our NetworkClientPlayerBase + LocalPlayer specialization, this lets us handle local input |
|
223 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
224 |
class NetworkClientLocalPlayer : public NetworkClientPlayerBase, public LocalPlayer { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
225 |
public: |
294 | 226 |
/** |
227 |
* Calls NetworkClientPlayerBase/Player constructors, calls GameState::setLocalPlayer |
|
228 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
229 |
NetworkClientLocalPlayer (NetworkClient &client, NetworkObjectID obj_id, Vector position); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
230 |
|
294 | 231 |
/** |
232 |
* Overriden from LocalPlayer to send a NETMSG_CLIENT_INPUT message without executing LocalPlayer::handleInput |
|
233 |
* locally |
|
234 |
*/ |
|
277 | 235 |
virtual void handleInput (PlayerInput input, TimeMS dt); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
236 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
237 |
|
294 | 238 |
/** |
239 |
* Our NetworkClientPlayerBase + RemotePlayer specialization, this lets us handle players quitting |
|
240 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
241 |
class NetworkClientRemotePlayer : public NetworkClientPlayerBase, public RemotePlayer { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
242 |
public: |
294 | 243 |
/** |
244 |
* Calls NetworkClientPlayerBase/Player constructors and hooks up signals |
|
245 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
246 |
NetworkClientRemotePlayer (NetworkClient &client, NetworkObjectID obj_id, Vector position); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
247 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
248 |
private: |
294 | 249 |
/** |
250 |
* Calls NetworkClient::player_quit, and then destroys ourselves |
|
251 |
*/ |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
252 |
void on_quit (NetworkPacketInput &pkt); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
253 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
254 |
|
294 | 255 |
/** |
256 |
* A Projectile that was created on the server |
|
257 |
*/ |
|
274
c35307e8645c
add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents:
263
diff
changeset
|
258 |
class NetworkClientProjectile : public NetworkClientObject, public Projectile { |
223 | 259 |
public: |
294 | 260 |
/** |
261 |
* Call Projectile's constructor, hook up signals and call player->weaponFired |
|
262 |
*/ |
|
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
274
diff
changeset
|
263 |
NetworkClientProjectile (NetworkClient &client, NetworkObjectID obj_id, Player *player, Vector position, |
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
274
diff
changeset
|
264 |
Vector velocity, Weapon *weapon); |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
265 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
266 |
protected: |
294 | 267 |
/** |
268 |
* Overrides Projectile::onDestroy to ignore this, as we must wait for the server to tell us where it impacted |
|
269 |
* so that we can remove the ground reliably |
|
270 |
*/ |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
271 |
virtual void onDestroy (Vector position, bool removeGround); |
296
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
272 |
|
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
273 |
/** |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
274 |
* Overrides Projectile::onHitPlayer to ignore this, as we must wait for the server to tell us if it really did |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
275 |
* happen. |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
276 |
*/ |
330 | 277 |
virtual void onHitPlayer (Player *player); |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
278 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
279 |
private: |
294 | 280 |
/** |
281 |
* NETMSG_PROJECTILE_DESTROY -> Projectile::onDestory |
|
282 |
*/ |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
283 |
void on_destroy (NetworkPacketInput &pkt); |
296
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
284 |
|
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
285 |
/** |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
286 |
* NETMSG_PROJECTILE_HIT_PLAYER -> Projectile::onHitPlayer |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
287 |
*/ |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
294
diff
changeset
|
288 |
void on_hit_player (NetworkPacketInput &pkt); |
223 | 289 |
}; |
290 |
||
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
291 |
#endif |