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,2013,2014,2015,2016 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. |
… | |
… | |
101 | ST_GET_PARTY_PASSWORD, |
101 | ST_GET_PARTY_PASSWORD, |
102 | }; |
102 | }; |
103 | |
103 | |
104 | // a handler for a specific type of packet |
104 | // a handler for a specific type of packet |
105 | enum { |
105 | enum { |
106 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
106 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
107 | PF_PLAYING = 0x02, // must be in playing state |
107 | PF_PLAYING = 0x02, // must be in playing state |
108 | PF_COMMAND0 = 0x04, // command starts at offset 0 |
108 | PF_COMMAND = 0x04, // is a user command |
109 | PF_COMMAND6 = 0x08, // command starts at offset 6 |
|
|
110 | }; |
109 | }; |
111 | |
110 | |
112 | // face types. bit 0 means "has meta info prepended" |
111 | // face types. bit 0 means "has meta info prepended" |
113 | enum { |
112 | enum { |
114 | FT_FACE = 0 * 2 + 0, // faces (images) |
113 | FT_IMAGE = 0 * 2 + 0, // images |
115 | FT_MUSIC = 1 * 2 + 1, // background music |
114 | FT_MUSIC = 1 * 2 + 1, // background music |
116 | FT_SOUND = 2 * 2 + 1, // effects |
115 | FT_SOUND = 2 * 2 + 1, // effects |
117 | FT_RSRC = 3 * 2 + 0, // generic data files |
116 | FT_RSRC = 3 * 2 + 0, // generic data files |
118 | FT_NUM, |
117 | FT_NUM, |
119 | }; |
118 | }; |
… | |
… | |
150 | unsigned int inbuf_len; // number of bytes valid in inbuf |
149 | unsigned int inbuf_len; // number of bytes valid in inbuf |
151 | statsinfo stats; |
150 | statsinfo stats; |
152 | object_vector_index ACC (RO, active); |
151 | object_vector_index ACC (RO, active); |
153 | player_ptr ACC (RO, pl); |
152 | player_ptr ACC (RO, pl); |
154 | |
153 | |
155 | char *ACC (RW, host); /* Which host it is connected from (ip address) */ |
154 | char *ACC (RW, host); /* Which host it is connected from (ip:port) */ |
156 | uint8 ACC (RW, state); /* Input state of the player (name, password, etc */ |
155 | uint8 ACC (RW, state); /* Input state of the player (name, password, etc */ |
157 | |
156 | |
158 | sint8 ACC (RW, last_level); /* Last level we sent to client */ |
157 | sint8 ACC (RW, last_level); /* Last level we sent to client */ |
159 | uint16 ACC (RW, last_flags); /* fire/run on flags for last tick */ |
158 | uint16 ACC (RW, last_flags); /* fire/run on flags for last tick */ |
160 | float ACC (RW, last_weapon_sp); /* if diff than weapon_sp, update client */ |
159 | float ACC (RW, last_weapon_sp); /* if diff than weapon_sp, update client */ |
… | |
… | |
179 | bool ACC (RW, need_delinv0); /* If true, we need to delinv 0 before sending new floorbox */ |
178 | bool ACC (RW, need_delinv0); /* If true, we need to delinv 0 before sending new floorbox */ |
180 | |
179 | |
181 | bool ACC (RW, update_look); /* If true, we need to send the look window */ |
180 | bool ACC (RW, update_look); /* If true, we need to send the look window */ |
182 | bool ACC (RW, update_spells); // If true, we need to esrv_update_spells |
181 | bool ACC (RW, update_spells); // If true, we need to esrv_update_spells |
183 | bool ACC (RW, has_readable_type); /* If true client accept additional text information */ |
182 | bool ACC (RW, has_readable_type); /* If true client accept additional text information */ |
184 | bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */ |
183 | uint8 ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */ |
185 | |
184 | |
186 | bool ACC (RW, smoothing); // deliantra-style smoothing |
185 | bool ACC (RW, smoothing); // deliantra-style smoothing |
187 | bool ACC (RW, force_newmap); // force a newmap before next map update |
186 | bool ACC (RW, force_newmap); // force a newmap before next map update |
188 | uint16 ACC (RW, look_position); /* start of drawing of look window */ |
187 | uint16 ACC (RW, look_position); /* start of drawing of look window */ |
189 | uint16 ACC (RW, mss); // likely tcp maximum segment size |
188 | uint16 ACC (RW, mss); // likely tcp maximum segment size |
190 | uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ |
189 | uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ |
191 | uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ |
190 | uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ |
192 | uint8 ACC (RW, faceset); // CF+ selected faceset |
191 | uint8 ACC (RW, tileset); // selected tileset |
193 | uint8 ACC (RW, ws_version); // websocket protocol versio for framing |
192 | uint8 ACC (RW, ws_version); // websocket protocol versio for framing |
194 | |
193 | |
195 | maptile_ptr ACC (RW, current_map); // CF+ last/current player map |
194 | maptile_ptr ACC (RW, current_map); // last/current player map |
196 | region_ptr ACC (RW, current_region); // CF+ last/current player region |
195 | region_ptr ACC (RW, current_region); // last/current player region |
197 | int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position |
196 | int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position |
198 | |
197 | |
199 | tstamp ACC (RW, last_send); // last data send on socket. |
198 | tstamp ACC (RW, last_send); // last data send on socket. |
200 | |
199 | |
201 | float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */ |
200 | float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */ |
… | |
… | |
295 | void send_raw (void *buf_, int len); |
294 | void send_raw (void *buf_, int len); |
296 | |
295 | |
297 | void send (void *buf_, int len); |
296 | void send (void *buf_, int len); |
298 | void send_packet (const_octet_string buf); |
297 | void send_packet (const_octet_string buf); |
299 | void send_packet (const_octet_string buf, int len); |
298 | void send_packet (const_octet_string buf, int len); |
300 | void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3))); |
299 | void send_packet_printf (const_utf8_string format, ...) ecb_attribute ((format (printf, 2, 3))); |
301 | void send_packet (packet &sl); |
300 | void send_packet (packet &sl); |
302 | |
|
|
303 | void send_drawinfo (const_utf8_string msg, int flags = NDI_BLACK); |
|
|
304 | |
301 | |
305 | MTH void send_face (faceidx facenum, int pri = 0); |
302 | MTH void send_face (faceidx facenum, int pri = 0); |
306 | MTH void send_faces (object *ob); |
303 | MTH void send_faces (object *ob); |
307 | MTH void send_animation (short anim_num); |
304 | MTH void send_animation (short anim_num); |
308 | void send_msg (int color, const_utf8_string type, const_utf8_string msg); |
305 | void send_msg (int color, const_utf8_string type, const_utf8_string msg); |
… | |
… | |
367 | statementvar (client *, var, clients [_i]) |
364 | statementvar (client *, var, clients [_i]) |
368 | |
365 | |
369 | // returns true when the message needs special (read: perl) treatment |
366 | // returns true when the message needs special (read: perl) treatment |
370 | static inline bool |
367 | static inline bool |
371 | msg_is_special (const_any_string msg, bool nl_special = true) |
368 | msg_is_special (const_any_string msg, bool nl_special = true) |
372 | { |
369 | { |
373 | return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; |
370 | return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; |
374 | } |
371 | } |
375 | |
372 | |
376 | #endif |
373 | #endif |
377 | |
374 | |