… | |
… | |
83 | enum { |
83 | enum { |
84 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
84 | PF_PLAYER = 0x01, // must have valid player / will by synchronised |
85 | PF_PLAYING = 0x02, // must be in playing state |
85 | PF_PLAYING = 0x02, // must be in playing state |
86 | PF_COMMAND0 = 0x04, // command starts at offset 0 |
86 | PF_COMMAND0 = 0x04, // command starts at offset 0 |
87 | PF_COMMAND6 = 0x08, // command starts at offset 6 |
87 | PF_COMMAND6 = 0x08, // command starts at offset 6 |
|
|
88 | }; |
|
|
89 | |
|
|
90 | // face type.s bit 0 means "has meta info prepended" |
|
|
91 | enum { |
|
|
92 | FT_FACE = 0 * 2 + 0, // faces (images) |
|
|
93 | FT_MUSIC = 1 * 2 + 1, // background music |
|
|
94 | FT_SOUND = 2 * 2 + 1, // effects |
|
|
95 | FT_RSRC = 3 * 2 + 0, // generic data files |
|
|
96 | FT_NUM, |
88 | }; |
97 | }; |
89 | |
98 | |
90 | struct packet_type |
99 | struct packet_type |
91 | { |
100 | { |
92 | const char *name; |
101 | const char *name; |
… | |
… | |
155 | bool ACC (RW, sent_scroll); |
164 | bool ACC (RW, sent_scroll); |
156 | bool ACC (RW, sound); /* does the client want sound */ |
165 | bool ACC (RW, sound); /* does the client want sound */ |
157 | bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */ |
166 | bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */ |
158 | bool ACC (RW, plugincmd); // extend the protocol through a plug-in */ |
167 | bool ACC (RW, plugincmd); // extend the protocol through a plug-in */ |
159 | bool ACC (RW, mapinfocmd); // return map info and send map change info |
168 | bool ACC (RW, mapinfocmd); // return map info and send map change info |
160 | bool ACC (RW, extcmd); // call into extensions/plugins |
169 | uint8_t ACC (RW, extcmd); // call into extensions/plugins |
161 | bool ACC (RW, extmap); // extend map comamnd with extra data |
170 | bool ACC (RW, extmap); // extend map comamnd with extra data |
162 | bool ACC (RW, buggy_mapscroll); // client crashes on large mapscrolls |
171 | bool ACC (RW, buggy_mapscroll); // client crashes on large mapscrolls |
163 | bool ACC (RW, darkness); /* True if client wants darkness information */ |
172 | bool ACC (RW, darkness); /* True if client wants darkness information */ |
164 | bool ACC (RW, image2); /* Client wants image2/face2 commands */ |
173 | bool ACC (RW, image2); /* Client wants image2/face2 commands */ |
165 | uint8_t ACC (RW, fxix); // client implements fx and ix (face|image extended) commands |
174 | uint8_t ACC (RW, fxix); // client implements fx and ix (face|image extended) commands |
… | |
… | |
190 | uint8 ACC (RW, faceset); // CF+ selected faceset |
199 | uint8 ACC (RW, faceset); // CF+ selected faceset |
191 | |
200 | |
192 | tstamp ACC (RW, last_send); // last data send on socket. |
201 | tstamp ACC (RW, last_send); // last data send on socket. |
193 | |
202 | |
194 | int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ |
203 | int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ |
|
|
204 | int ACC (RW, outq); // current socket outq length, or 0 if indeterminable |
195 | |
205 | |
196 | int ACC (RW, rate_avail); // current rate balance |
206 | int ACC (RW, rate_avail); // current rate balance |
197 | int ACC (RW, max_rate); // max. # of bytes to send per tick |
207 | int ACC (RW, max_rate); // max. # of bytes to send per tick |
198 | faceidx ACC (RW, scrub_idx); // which face to send next |
208 | faceidx ACC (RW, scrub_idx); // which face to send next |
199 | int ACC (RW, bg_scrub); // how many ticks till the next background face send |
209 | int ACC (RW, bg_scrub); // how many ticks till the next background face send |
… | |
… | |
218 | |
228 | |
219 | // large structures at the end please |
229 | // large structures at the end please |
220 | struct Map lastmap; |
230 | struct Map lastmap; |
221 | std::bitset<MAXANIMNUM> anims_sent; |
231 | std::bitset<MAXANIMNUM> anims_sent; |
222 | std::bitset<MAX_FACES> faces_sent; |
232 | std::bitset<MAX_FACES> faces_sent; |
|
|
233 | std::bitset<FT_NUM> fx_want; |
223 | |
234 | |
224 | // if we get an incomplete packet, this is used to hold the data. |
235 | // if we get an incomplete packet, this is used to hold the data. |
225 | // we add 2 byte for the header, one for the trailing 0 byte |
236 | // we add 2 byte for the header, one for the trailing 0 byte |
226 | uint8 inbuf[MAXSOCKBUF + 2 + 1]; |
237 | uint8 inbuf[MAXSOCKBUF + 2 + 1]; |
227 | |
238 | |
… | |
… | |
260 | void send_packet_printf (const char *format, ...); |
271 | void send_packet_printf (const char *format, ...); |
261 | void send_packet (packet &sl); |
272 | void send_packet (packet &sl); |
262 | |
273 | |
263 | void send_drawinfo (const char *msg, int flags = NDI_BLACK); |
274 | void send_drawinfo (const char *msg, int flags = NDI_BLACK); |
264 | |
275 | |
265 | MTH bool must_send_face (faceidx facenum) |
|
|
266 | { |
|
|
267 | if (faces_sent[facenum]) |
|
|
268 | return false; |
|
|
269 | |
|
|
270 | faces_sent[facenum] = true; |
|
|
271 | return true; |
|
|
272 | } |
|
|
273 | |
|
|
274 | MTH void send_face (faceidx facenum); |
276 | MTH void send_face (faceidx facenum, int pri = 0); |
275 | MTH void send_image (faceidx facenum); |
277 | MTH void send_image (faceidx facenum); |
276 | MTH void send_faces (object *ob); |
278 | MTH void send_faces (object *ob); |
277 | MTH void send_animation (short anim_num); |
279 | MTH void send_animation (short anim_num); |
278 | void send_msg (int color, const char *type, const char *msg); |
280 | void send_msg (int color, const char *type, const char *msg); |
279 | |
281 | |