author | terom |
Sat, 06 Dec 2008 19:14:58 +0000 | |
changeset 224 | e6faefba2ec1 |
parent 223 | 2fcaf54ed37b |
child 239 | 550397d9d479 |
permissions | -rw-r--r-- |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
|
186 | 2 |
#include "Client.hh" |
187 | 3 |
#include "Protocol.hh" |
4 |
#include "Config.hh" |
|
186 | 5 |
#include "../Engine.hh" |
6 |
#include "../Logger.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 <cassert> |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
9 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
10 |
NetworkClient::NetworkClient (GameState &state, const NetworkAddress &connect_to) : |
187 | 11 |
state(state), netsession(NETWORK_MAGIC_ID), server(netsession.connect(connect_to)), netobjs(netsession, NETCHAN_CORE, server) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
12 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
13 |
// connect slots |
223 | 14 |
slots.connect(netobjs.sig_create(NETMSG_SERVER_HELLO), this, &NetworkClient::on_server_hello); |
15 |
slots.connect(netobjs.sig_create(NETMSG_PLAYER_INFO), this, &NetworkClient::on_player_info); |
|
16 |
slots.connect(netobjs.sig_create(NETMSG_PLAYER_JOIN), this, &NetworkClient::on_player_join); |
|
17 |
slots.connect(netobjs.sig_create(NETMSG_PROJECTILE_CREATE), this, &NetworkClient::on_projectile_create); |
|
18 |
||
203
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
19 |
slots.connect(netsession.sig_chan_message(NETCHAN_TERRAIN_ARRAY), this, &NetworkClient::on_terrain_array); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
20 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
21 |
// XXX: sig_disconnected |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
22 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
23 |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
24 |
void NetworkClient::on_server_hello (NetworkObject_Client *obj, NetworkPacketInput &pkt) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
25 |
// read the packet |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
26 |
Vector position = pkt.read_vector(); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
27 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
28 |
Engine::log(INFO, "client.on_server_hello") << "obj=" << obj << ", pos=" << position; |
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 |
// create the LocalPlayer object |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
31 |
NetworkClientLocalPlayer *player = new NetworkClientLocalPlayer(*this, obj, position); |
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 |
// inform state |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
34 |
state.newLocalPlayer(player); |
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 |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
37 |
void NetworkClient::on_player_info (NetworkObject_Client *obj, NetworkPacketInput &pkt) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
38 |
// read the packet |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
39 |
Vector position = pkt.read_vector(); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
40 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
41 |
Engine::log(INFO, "client.on_player_info") << "obj=" << obj << ", pos=" << position; |
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 |
// create the LocalPlayer object |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
44 |
NetworkClientRemotePlayer *player = new NetworkClientRemotePlayer(*this, obj, position); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
45 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
46 |
// inform state |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
47 |
state.newPlayer(player); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
48 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
49 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
50 |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
51 |
void NetworkClient::on_player_join (NetworkObject_Client *obj, NetworkPacketInput &pkt) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
52 |
// read the packet |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
53 |
Vector position = pkt.read_vector(); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
54 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
55 |
Engine::log(INFO, "client.on_player_join") << "obj=" << obj << ", pos=" << position; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
56 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
57 |
// create the RemotePlayer object |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
58 |
NetworkClientRemotePlayer *player = new NetworkClientRemotePlayer(*this, obj, position); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
59 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
60 |
// inform state |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
61 |
state.newPlayer(player); |
185
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 |
void NetworkClient::on_projectile_create (NetworkObject_Client *obj, NetworkPacketInput &pkt) { |
65 |
// read the packet |
|
66 |
Vector position = pkt.read_vector(); |
|
67 |
Vector velocity = pkt.read_vector(); |
|
68 |
float explosionRadius = pkt.read_float32(); |
|
69 |
||
70 |
Engine::log(INFO, "client.on_projectile_create") << "obj=" << obj << ", pos=" << position << ", velocity=" << velocity; |
|
71 |
||
72 |
// create the NetworkClientPorjectile object |
|
73 |
new NetworkClientProjectile(*this, obj, position, velocity, explosionRadius); |
|
74 |
} |
|
75 |
||
203
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
76 |
void NetworkClient::on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node) { |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
77 |
// ignore if not from server |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
78 |
if (node != server) |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
79 |
return; |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
80 |
|
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
81 |
Terrain &terrain = state.world; |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
82 |
|
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
83 |
// read map width/height |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
84 |
uint32_t map_w = pkt.read_uint32(); |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
85 |
uint32_t map_h = pkt.read_uint32(); |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
86 |
|
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
87 |
// read map data |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
88 |
for (int x = 0; x < map_w; x++) { |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
89 |
for (int y = 0; y < map_h; y++) { |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
90 |
terrain.terrain[x][y] = (TerrainType) pkt.read_uint8(); |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
91 |
} |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
92 |
} |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
93 |
|
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
94 |
// update the pixbuf |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
95 |
terrain.generatePixelBuffer(); |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
96 |
} |
3ec7ab40755f
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents:
200
diff
changeset
|
97 |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
98 |
void NetworkClient::player_quit (NetworkClientRemotePlayer *player) { |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
99 |
// inform state |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
100 |
state.removePlayer(player); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
101 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
102 |
// delete |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
103 |
// XXX: leak because deleting the slot while it's being called breaks ClanLib |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
104 |
// delete player; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
105 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
106 |
|
223 | 107 |
/* |
108 |
* NetworkClientObjectHelper |
|
109 |
*/ |
|
110 |
NetworkClientObjectHelper::NetworkClientObjectHelper (NetworkClient &client, NetworkObject_Client *obj) : |
|
111 |
client(client), obj(obj) |
|
112 |
{ |
|
113 |
||
114 |
} |
|
115 |
||
116 |
/* |
|
117 |
* NetworkClientPlayerHelper |
|
118 |
*/ |
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
119 |
NetworkClientPlayerHelper::NetworkClientPlayerHelper (NetworkClient &client, Vector position, NetworkObject_Client *obj) : |
223 | 120 |
NetworkClientObjectHelper(client, obj), Player(client.state, position, true) |
121 |
{ |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
122 |
// receive position updates |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
123 |
slots.connect(obj->sig_message(NETMSG_PLAYER_POSITION), this, &NetworkClientPlayerHelper::on_position); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
124 |
slots.connect(obj->sig_message(NETMSG_PLAYER_DIG), this, &NetworkClientPlayerHelper::on_dig); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
125 |
} |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
126 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
127 |
void NetworkClientPlayerHelper::on_position (NetworkPacketInput &pkt) { |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
128 |
Vector position = pkt.read_vector(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
129 |
Vector velocity = pkt.read_vector(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
130 |
int flags = pkt.read_uint8(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
131 |
float aim = pkt.read_float32(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
132 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
133 |
Engine::log(INFO, "client_player.on_position") << "obj=" << obj << ", position=" << position << ", velocity=" << velocity << ", aim=" << aim << ", [" << flags << "]"; |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
134 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
135 |
// just update... |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
136 |
updatePhysics(position, velocity, flags & NETWORK_PHYSICS_INAIR, flags & NETWORK_PHYSICS_FACE_RIGHT, aim); |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
137 |
} |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
138 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
139 |
void NetworkClientPlayerHelper::on_dig (NetworkPacketInput &pkt) { |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
140 |
Vector position = pkt.read_vector(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
141 |
float radius = pkt.read_float32(); |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
142 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
143 |
Engine::log(INFO, "client_player.on_dig") << "obj=" << obj << ", position=" << position << ", radius=" << radius; |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
144 |
|
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
145 |
// just update... |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
146 |
handleDig(position, radius); |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
147 |
} |
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
148 |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
149 |
NetworkClientLocalPlayer::NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position) : |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
150 |
Player(client.state, position, true), NetworkClientPlayerHelper(client, position, obj) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
151 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
152 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
153 |
|
221 | 154 |
void NetworkClientLocalPlayer::handleInput (PlayerInput input) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
155 |
// always send move, in all cases |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
156 |
NetworkPacket pkt; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
157 |
pkt.write_uint16(input); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
158 |
|
223 | 159 |
obj->send(NETMSG_CLIENT_INPUT, pkt, false); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
160 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
161 |
// do not handle locally |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
162 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
163 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
164 |
NetworkClientRemotePlayer::NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position) : |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
203
diff
changeset
|
165 |
Player(client.state, position, true), NetworkClientPlayerHelper(client, position, obj) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
166 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
167 |
// receive messages |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
168 |
slots.connect(obj->sig_message(NETMSG_PLAYER_QUIT), this, &NetworkClientRemotePlayer::on_quit); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
169 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
170 |
|
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
171 |
void NetworkClientRemotePlayer::on_quit (NetworkPacketInput &pkt) { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
172 |
// pkt is empty |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
173 |
(void) pkt; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
174 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
175 |
Engine::log(INFO, "client_player.on_quit") << "obj=" << obj; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
176 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
177 |
client.player_quit(this); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
178 |
} |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
179 |
|
223 | 180 |
NetworkClientProjectile::NetworkClientProjectile (NetworkClient &client, NetworkObject_Client *obj, Vector position, |
181 |
Vector velocity, float explosionRadius) : |
|
182 |
NetworkClientObjectHelper(client, obj), Projectile(client.state, position, velocity, true, explosionRadius) |
|
183 |
{ |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
184 |
// hook up signals |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
185 |
slots.connect(obj->sig_message(NETMSG_PROJECTILE_DESTROY), this, &NetworkClientProjectile::on_destroy); |
223 | 186 |
} |
200
2dbf40661580
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents:
187
diff
changeset
|
187 |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
188 |
void NetworkClientProjectile::onDestroy (Vector position, bool removeGround) { |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
189 |
// ignore :> |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
190 |
} |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
191 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
192 |
void NetworkClientProjectile::on_destroy (NetworkPacketInput &pkt) { |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
193 |
Vector position = pkt.read_vector(); |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
194 |
uint8_t flags = pkt.read_uint8(); |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
195 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
196 |
Engine::log(INFO, "client_projectile.on_destroy") << "obj=" << obj << ", position=" << position << ", flags=" << flags; |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
197 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
198 |
// XXX: leak obj, not yet implemented: obj.destory(); |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
199 |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
200 |
// pass on to super |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
201 |
Projectile::onDestroy(position, flags & NETWORK_PROJECTILE_REMOVE_GROUND); |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
202 |
} |