… | |
… | |
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 |
… | |
… | |
219 | |
228 | |
220 | // large structures at the end please |
229 | // large structures at the end please |
221 | struct Map lastmap; |
230 | struct Map lastmap; |
222 | std::bitset<MAXANIMNUM> anims_sent; |
231 | std::bitset<MAXANIMNUM> anims_sent; |
223 | std::bitset<MAX_FACES> faces_sent; |
232 | std::bitset<MAX_FACES> faces_sent; |
|
|
233 | std::bitset<FT_NUM> fx_want; |
224 | |
234 | |
225 | // 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. |
226 | // 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 |
227 | uint8 inbuf[MAXSOCKBUF + 2 + 1]; |
237 | uint8 inbuf[MAXSOCKBUF + 2 + 1]; |
228 | |
238 | |
… | |
… | |
261 | void send_packet_printf (const char *format, ...); |
271 | void send_packet_printf (const char *format, ...); |
262 | void send_packet (packet &sl); |
272 | void send_packet (packet &sl); |
263 | |
273 | |
264 | void send_drawinfo (const char *msg, int flags = NDI_BLACK); |
274 | void send_drawinfo (const char *msg, int flags = NDI_BLACK); |
265 | |
275 | |
266 | MTH bool must_send_face (faceidx facenum) |
|
|
267 | { |
|
|
268 | if (faces_sent[facenum]) |
|
|
269 | return false; |
|
|
270 | |
|
|
271 | faces_sent[facenum] = true; |
|
|
272 | return true; |
|
|
273 | } |
|
|
274 | |
|
|
275 | MTH void send_face (faceidx facenum); |
276 | MTH void send_face (faceidx facenum, int pri = 0); |
276 | MTH void send_image (faceidx facenum); |
277 | MTH void send_image (faceidx facenum); |
277 | MTH void send_faces (object *ob); |
278 | MTH void send_faces (object *ob); |
278 | MTH void send_animation (short anim_num); |
279 | MTH void send_animation (short anim_num); |
279 | void send_msg (int color, const char *type, const char *msg); |
280 | void send_msg (int color, const char *type, const char *msg); |
280 | |
281 | |
|
|
282 | MTH void play_sound (faceidx sound, int dx = 0, int dy = 0); |
281 | // called when something under the player changes |
283 | // called when something under the player changes |
282 | MTH void floorbox_update () { update_look = 1; } |
284 | MTH void floorbox_update () { update_look = 1; } |
283 | // called when the player has been moved |
285 | // called when the player has been moved |
284 | MTH void floorbox_reset () { look_position = 0; floorbox_update (); } |
286 | MTH void floorbox_reset () { look_position = 0; floorbox_update (); } |
285 | |
287 | |