… | |
… | |
83 | |
83 | |
84 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
84 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
85 | return; |
85 | return; |
86 | |
86 | |
87 | if (pl->type == PLAYER) |
87 | if (pl->type == PLAYER) |
88 | esrv_print_msg (pl->contr->socket, colr, (char *) tmp); |
88 | esrv_print_msg (pl->contr->ns, colr, (char *) tmp); |
89 | } |
89 | } |
90 | |
90 | |
91 | /** |
91 | /** |
92 | * Prints out the contents of specified buffer structures, |
92 | * Prints out the contents of specified buffer structures, |
93 | * and clears the string. |
93 | * and clears the string. |
… | |
… | |
185 | void |
185 | void |
186 | new_draw_info (int flags, int pri, const object *pl, const char *buf) |
186 | new_draw_info (int flags, int pri, const object *pl, const char *buf) |
187 | { |
187 | { |
188 | if (flags & NDI_ALL) |
188 | if (flags & NDI_ALL) |
189 | { |
189 | { |
190 | player *tmppl; |
190 | for_all_players (pl) |
191 | |
|
|
192 | for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) |
|
|
193 | new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); |
191 | new_draw_info (flags & ~NDI_ALL, pri, pl->ob, buf); |
194 | |
192 | |
195 | return; |
193 | return; |
196 | } |
194 | } |
197 | |
195 | |
198 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
196 | if (!pl || pl->type != PLAYER || !pl->contr || !pl->contr->ns) |
199 | { |
|
|
200 | /* Write to the socket? */ |
|
|
201 | print_message (0, NULL, buf); |
|
|
202 | return; |
|
|
203 | } |
|
|
204 | |
|
|
205 | if (pl->type != PLAYER) |
|
|
206 | return; |
197 | return; |
207 | |
198 | |
208 | if (pri >= pl->contr->listening) |
199 | if (pri >= pl->contr->listening) |
209 | return; |
200 | return; |
210 | |
201 | |
211 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
202 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
212 | /* following prints stuff out, as appropriate */ |
|
|
213 | check_output_buffers (pl, buf); |
203 | check_output_buffers (pl, buf); |
214 | else |
204 | else |
215 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
205 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
216 | } |
206 | } |
217 | |
207 | |
… | |
… | |
227 | new_draw_info_format (int flags, int pri, const object *pl, const char *format, ...) |
217 | new_draw_info_format (int flags, int pri, const object *pl, const char *format, ...) |
228 | { |
218 | { |
229 | char buf[HUGE_BUF]; |
219 | char buf[HUGE_BUF]; |
230 | |
220 | |
231 | va_list ap; |
221 | va_list ap; |
232 | |
|
|
233 | va_start (ap, format); |
222 | va_start (ap, format); |
234 | |
|
|
235 | vsnprintf (buf, HUGE_BUF, format, ap); |
223 | vsnprintf (buf, HUGE_BUF, format, ap); |
236 | |
|
|
237 | va_end (ap); |
224 | va_end (ap); |
238 | |
225 | |
239 | new_draw_info (flags, pri, pl, buf); |
226 | new_draw_info (flags, pri, pl, buf); |
240 | } |
227 | } |
241 | |
228 | |
… | |
… | |
247 | return; |
234 | return; |
248 | |
235 | |
249 | if (pri >= pl->contr->listening) |
236 | if (pri >= pl->contr->listening) |
250 | return; |
237 | return; |
251 | |
238 | |
252 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
239 | if (!CLIENT_SUPPORT_READABLES (pl->contr->ns, type)) |
253 | { |
240 | { |
254 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
241 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
255 | |
242 | |
256 | if (buf == NULL) |
243 | if (buf == NULL) |
257 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
244 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
… | |
… | |
262 | new_draw_info (flags, pri, pl, buf); |
249 | new_draw_info (flags, pri, pl, buf); |
263 | free (buf); |
250 | free (buf); |
264 | } |
251 | } |
265 | } |
252 | } |
266 | else |
253 | else |
267 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, message); |
254 | esrv_print_ext_msg (pl->contr->ns, flags & NDI_COLOR_MASK, type, subtype, message); |
268 | } |
255 | } |
269 | |
256 | |
270 | void |
257 | void |
271 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
258 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
272 | { |
259 | { |
… | |
… | |
277 | return; |
264 | return; |
278 | |
265 | |
279 | if (pri >= pl->contr->listening) |
266 | if (pri >= pl->contr->listening) |
280 | return; |
267 | return; |
281 | |
268 | |
282 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
269 | if (!CLIENT_SUPPORT_READABLES (pl->contr->ns, type)) |
283 | { |
270 | { |
284 | va_list ap; |
271 | va_list ap; |
285 | |
272 | |
286 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
273 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
287 | va_start (ap, new_format); |
274 | va_start (ap, new_format); |
… | |
… | |
296 | |
283 | |
297 | va_start (ap, new_format); |
284 | va_start (ap, new_format); |
298 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
285 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
299 | va_end (ap); |
286 | va_end (ap); |
300 | strip_media_tag (buf); |
287 | strip_media_tag (buf); |
301 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, buf); |
288 | esrv_print_ext_msg (pl->contr->ns, flags & NDI_COLOR_MASK, type, subtype, buf); |
302 | } |
289 | } |
303 | } |
290 | } |
304 | |
291 | |
305 | /** |
292 | /** |
306 | * Writes to everyone on the map *except* op. This is useful for emotions. |
293 | * Writes to everyone on the map *except* op. This is useful for emotions. |
… | |
… | |
309 | void |
296 | void |
310 | new_info_map_except (int color, maptile * map, object *op, const char *str) |
297 | new_info_map_except (int color, maptile * map, object *op, const char *str) |
311 | { |
298 | { |
312 | player *pl; |
299 | player *pl; |
313 | |
300 | |
314 | for (pl = first_player; pl != NULL; pl = pl->next) |
301 | for_all_players (pl) |
315 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
302 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
316 | { |
303 | { |
317 | new_draw_info (color, 0, pl->ob, str); |
304 | new_draw_info (color, 0, pl->ob, str); |
318 | } |
305 | } |
319 | } |
306 | } |
… | |
… | |
325 | void |
312 | void |
326 | new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) |
313 | new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) |
327 | { |
314 | { |
328 | player *pl; |
315 | player *pl; |
329 | |
316 | |
330 | for (pl = first_player; pl != NULL; pl = pl->next) |
317 | for_all_players (pl) |
331 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
318 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
332 | { |
319 | { |
333 | new_draw_info (color, 0, pl->ob, str); |
320 | new_draw_info (color, 0, pl->ob, str); |
334 | } |
321 | } |
335 | } |
322 | } |
… | |
… | |
341 | void |
328 | void |
342 | new_info_map (int color, maptile * map, const char *str) |
329 | new_info_map (int color, maptile * map, const char *str) |
343 | { |
330 | { |
344 | player *pl; |
331 | player *pl; |
345 | |
332 | |
346 | for (pl = first_player; pl != NULL; pl = pl->next) |
333 | for_all_players (pl) |
347 | if (pl->ob != NULL && pl->ob->map == map) |
334 | if (pl->ob != NULL && pl->ob->map == map) |
348 | { |
335 | { |
349 | new_draw_info (color, 0, pl->ob, str); |
336 | new_draw_info (color, 0, pl->ob, str); |
350 | } |
337 | } |
351 | } |
338 | } |
… | |
… | |
518 | * being nonzero have been changed to check for 1. Also, since |
505 | * being nonzero have been changed to check for 1. Also, since |
519 | * map_mark is a char value, putting 2 in should cause no problems. |
506 | * map_mark is a char value, putting 2 in should cause no problems. |
520 | * |
507 | * |
521 | * This function examines the map the player is on, and determines what |
508 | * This function examines the map the player is on, and determines what |
522 | * is visible. 2 is set for walls or objects that blocks view. 1 |
509 | * is visible. 2 is set for walls or objects that blocks view. 1 |
523 | * is for open spaces. map_mark should already have been initialized |
510 | * is for open spaces. map_mark should already have been initialised |
524 | * to zero before this is called. |
511 | * to zero before this is called. |
525 | * strength is an initial strength*2 rectangular area that we automatically |
512 | * strength is an initial strength*2 rectangular area that we automatically |
526 | * see in/penetrate through. |
513 | * see in/penetrate through. |
527 | */ |
514 | */ |
528 | |
515 | |
… | |
… | |
598 | xmax = 0; |
585 | xmax = 0; |
599 | ymax = 0; |
586 | ymax = 0; |
600 | |
587 | |
601 | for (int x = 0; x < MAGIC_MAP_SIZE; x++) |
588 | for (int x = 0; x < MAGIC_MAP_SIZE; x++) |
602 | for (int y = 0; y < MAGIC_MAP_SIZE; y++) |
589 | for (int y = 0; y < MAGIC_MAP_SIZE; y++) |
603 | if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) |
590 | if (map_mark[x + pl->map->width * y] | FACE_FLOOR) |
604 | { |
591 | { |
605 | xmin = x < xmin ? x : xmin; |
592 | xmin = x < xmin ? x : xmin; |
606 | xmax = x > xmax ? x : xmax; |
593 | xmax = x > xmax ? x : xmax; |
607 | ymin = y < ymin ? y : ymin; |
594 | ymin = y < ymin ? y : ymin; |
608 | ymax = y > ymax ? y : ymax; |
595 | ymax = y > ymax ? y : ymax; |
… | |
… | |
614 | |
601 | |
615 | for (int y = ymin; y <= ymax; y++) |
602 | for (int y = ymin; y <= ymax; y++) |
616 | for (int x = xmin; x <= xmax; x++) |
603 | for (int x = xmin; x <= xmax; x++) |
617 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
604 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
618 | |
605 | |
619 | pl->contr->socket->send_packet (sl); |
606 | pl->contr->ns->send_packet (sl); |
620 | |
607 | |
621 | free (map_mark); |
608 | free (map_mark); |
622 | } |
609 | } |
623 | |
610 | |
624 | /** |
611 | /** |