ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/client.h
(Generate patch)

Comparing deliantra/server/include/client.h (file contents):
Revision 1.104 by root, Tue Jan 3 11:25:31 2012 UTC vs.
Revision 1.109 by root, Tue Nov 6 03:45:17 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the Affero GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23#ifndef CLIENT_H 23#ifndef CLIENT_H
24#define CLIENT_H 24#define CLIENT_H
189 uint16 ACC (RW, look_position); /* start of drawing of look window */ 189 uint16 ACC (RW, look_position); /* start of drawing of look window */
190 uint16 ACC (RW, mss); // likely tcp maximum segment size 190 uint16 ACC (RW, mss); // likely tcp maximum segment size
191 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ 191 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */
192 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ 192 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */
193 uint8 ACC (RW, faceset); // CF+ selected faceset 193 uint8 ACC (RW, faceset); // CF+ selected faceset
194 uint8 ACC (RW, ws_version); // websocket protocol versio for framing
194 195
195 maptile_ptr ACC (RW, current_map); // CF+ last/current player map 196 maptile_ptr ACC (RW, current_map); // CF+ last/current player map
196 region_ptr ACC (RW, current_region); // CF+ last/current player region 197 region_ptr ACC (RW, current_region); // CF+ last/current player region
197 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position 198 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position
198 199
205 int ACC (RW, bg_scrub); // how many ticks till the next background face send 206 int ACC (RW, bg_scrub); // how many ticks till the next background face send
206 207
207 struct tcp_info tcpi; 208 struct tcp_info tcpi;
208 tstamp next_rate_adjust; 209 tstamp next_rate_adjust;
209 210
211 // websocket frame buffer
212 uint8 ws_inbuf_type; // current frame type
213 uint8 *ws_inbuf;
214 uint32 ws_inbuf_len;
215 uint32 ws_inbuf_alloc;
216
210 unordered_vector<char *> mapinfo_queue; 217 unordered_vector<char *> mapinfo_queue;
211 void mapinfo_queue_clear (); 218 void mapinfo_queue_clear ();
212 void mapinfo_queue_run (); 219 void mapinfo_queue_run ();
213 bool mapinfo_try (char *buf); 220 bool mapinfo_try (char *buf);
214 221
215 struct ixsend { 222 struct ixsend {
216 int16_t pri; // unused 223 int16_t pri; // higher means faces are sent earlier, default 0
217 faceidx idx; 224 faceidx idx;
218 uint32_t ofs; // if != 0, need to send remaining bytes of partial_face 225 uint32_t ofs; // if != 0, need to send remaining bytes of partial_face
219 }; 226 };
220 std::vector<ixsend, slice_allocator<ixsend> > ixface; // which faces to send to the client using ix 227 std::vector<ixsend, slice_allocator<ixsend> > ixface; // which faces to send to the client using ix
221 228
239 std::bitset<FT_NUM> fx_want; 246 std::bitset<FT_NUM> fx_want;
240 247
241 // if we get an incomplete packet, this is used to hold the data. 248 // if we get an incomplete packet, this is used to hold the data.
242 // we add 2 byte for the header, one for the trailing 0 byte 249 // we add 2 byte for the header, one for the trailing 0 byte
243 uint8 inbuf[MAXSOCKBUF + 2 + 1]; 250 uint8 inbuf[MAXSOCKBUF + 2 + 1];
251 void inbuf_handle ();
244 252
245 enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 }; 253 enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 };
246 struct msg_buf 254 struct msg_buf
247 { 255 {
248 tick_t expire; 256 tick_t expire;
279 void skip_packet (int len); // we have processed the packet, skip it 287 void skip_packet (int len); // we have processed the packet, skip it
280 288
281 MTH void flush (); 289 MTH void flush ();
282 MTH void write_outputbuffer (); 290 MTH void write_outputbuffer ();
283 MTH int outputbuffer_len () const { return outputbuffer.len; } 291 MTH int outputbuffer_len () const { return outputbuffer.len; }
292 void send_raw (void *buf_, int len);
293
284 void send (void *buf_, int len); 294 void send (void *buf_, int len);
285
286 void send_packet (const_octet_string buf); 295 void send_packet (const_octet_string buf);
287 void send_packet (const_octet_string buf, int len); 296 void send_packet (const_octet_string buf, int len);
288 void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3))); 297 void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3)));
289 void send_packet (packet &sl); 298 void send_packet (packet &sl);
290 299
304 MTH void tick (); // called every server tick to do housekeeping etc. 313 MTH void tick (); // called every server tick to do housekeeping etc.
305 314
306 MTH static client *create (int fd, const char *peername); 315 MTH static client *create (int fd, const char *peername);
307 MTH static void clock (); 316 MTH static void clock ();
308 MTH static void flush_sockets (); 317 MTH static void flush_sockets ();
318
319 MTH void run (); // start handshake after init
309 320
310protected: 321protected:
311 client (int fd, const char *from_ip); 322 client (int fd, const char *from_ip);
312 ~client (); 323 ~client ();
313}; 324};
342 ACC (RW, tcpi.tcpi_snd_cwnd); 353 ACC (RW, tcpi.tcpi_snd_cwnd);
343 ACC (RW, tcpi.tcpi_advmss); 354 ACC (RW, tcpi.tcpi_advmss);
344 ACC (RW, tcpi.tcpi_reordering); 355 ACC (RW, tcpi.tcpi_reordering);
345#endif 356#endif
346 357
347//+GPL
348
349#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\
350 ( ((__type)>0) &&\
351 ((__sockPtr)->has_readable_type) && \
352 ((__sockPtr)->supported_readables & (1<<(__type))) )
353
354#define FACE_TYPES 1
355#define PNG_FACE_INDEX 0
356
357//-GPL
358
359typedef object_vector<client, &client::active> sockvec; 358typedef object_vector<client, &client::active> sockvec;
360 359
361extern sockvec clients; 360extern sockvec clients;
362 361
363#define for_all_clients(var) \ 362#define for_all_clients(var) \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines