1 | |
|
|
2 | /* |
1 | /* |
3 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
4 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | |
8 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
191 | new_draw_info (flags & ~NDI_ALL, pri, pl->ob, buf); |
191 | new_draw_info (flags & ~NDI_ALL, pri, pl->ob, buf); |
192 | |
192 | |
193 | return; |
193 | return; |
194 | } |
194 | } |
195 | |
195 | |
196 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
196 | if (!pl || pl->type != PLAYER || !pl->contr || !pl->contr->ns) |
197 | { |
|
|
198 | /* Write to the socket? */ |
|
|
199 | print_message (0, NULL, buf); |
|
|
200 | return; |
|
|
201 | } |
|
|
202 | |
|
|
203 | if (pl->type != PLAYER) |
|
|
204 | return; |
197 | return; |
205 | |
198 | |
206 | if (pri >= pl->contr->listening) |
199 | if (pri >= pl->contr->listening) |
207 | return; |
200 | return; |
208 | |
201 | |
209 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
202 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
210 | /* following prints stuff out, as appropriate */ |
|
|
211 | check_output_buffers (pl, buf); |
203 | check_output_buffers (pl, buf); |
212 | else |
204 | else |
213 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
205 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
214 | } |
206 | } |
215 | |
207 | |
… | |
… | |
225 | 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, ...) |
226 | { |
218 | { |
227 | char buf[HUGE_BUF]; |
219 | char buf[HUGE_BUF]; |
228 | |
220 | |
229 | va_list ap; |
221 | va_list ap; |
230 | |
|
|
231 | va_start (ap, format); |
222 | va_start (ap, format); |
232 | |
|
|
233 | vsnprintf (buf, HUGE_BUF, format, ap); |
223 | vsnprintf (buf, HUGE_BUF, format, ap); |
234 | |
|
|
235 | va_end (ap); |
224 | va_end (ap); |
236 | |
225 | |
237 | new_draw_info (flags, pri, pl, buf); |
226 | new_draw_info (flags, pri, pl, buf); |
238 | } |
227 | } |
239 | |
228 | |
… | |
… | |
266 | } |
255 | } |
267 | |
256 | |
268 | void |
257 | void |
269 | 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, ...) |
270 | { |
259 | { |
271 | |
|
|
272 | char buf[HUGE_BUF]; |
260 | char buf[HUGE_BUF]; |
273 | |
261 | |
274 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
262 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
275 | return; |
263 | return; |
276 | |
264 | |
… | |
… | |
309 | { |
297 | { |
310 | player *pl; |
298 | player *pl; |
311 | |
299 | |
312 | for_all_players (pl) |
300 | for_all_players (pl) |
313 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
301 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
314 | { |
|
|
315 | new_draw_info (color, 0, pl->ob, str); |
302 | new_draw_info (color, 0, pl->ob, str); |
316 | } |
|
|
317 | } |
303 | } |
318 | |
304 | |
319 | /** |
305 | /** |
320 | * Writes to everyone on the map except op1 and op2 |
306 | * Writes to everyone on the map except op1 and op2 |
321 | */ |
307 | */ |
… | |
… | |
325 | { |
311 | { |
326 | player *pl; |
312 | player *pl; |
327 | |
313 | |
328 | for_all_players (pl) |
314 | for_all_players (pl) |
329 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
315 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
330 | { |
|
|
331 | new_draw_info (color, 0, pl->ob, str); |
316 | new_draw_info (color, 0, pl->ob, str); |
332 | } |
|
|
333 | } |
317 | } |
334 | |
318 | |
335 | /** |
319 | /** |
336 | * Writes to everyone on the specified map |
320 | * Writes to everyone on the specified map |
337 | */ |
321 | */ |
… | |
… | |
341 | { |
325 | { |
342 | player *pl; |
326 | player *pl; |
343 | |
327 | |
344 | for_all_players (pl) |
328 | for_all_players (pl) |
345 | if (pl->ob != NULL && pl->ob->map == map) |
329 | if (pl->ob != NULL && pl->ob->map == map) |
346 | { |
|
|
347 | new_draw_info (color, 0, pl->ob, str); |
330 | new_draw_info (color, 0, pl->ob, str); |
348 | } |
|
|
349 | } |
331 | } |
350 | |
|
|
351 | |
332 | |
352 | /** |
333 | /** |
353 | * This does nothing now. However, in theory, we should probably send |
334 | * This does nothing now. However, in theory, we should probably send |
354 | * something to the client and let the client figure out how it might want |
335 | * something to the client and let the client figure out how it might want |
355 | * to handle this |
336 | * to handle this |
… | |
… | |
462 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
443 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
463 | { |
444 | { |
464 | int x, y, dx, dy, mflags; |
445 | int x, y, dx, dy, mflags; |
465 | sint16 nx, ny; |
446 | sint16 nx, ny; |
466 | maptile *mp; |
447 | maptile *mp; |
467 | New_Face *f; |
448 | facetile *f; |
468 | |
449 | |
469 | for (dx = -1; dx <= 1; dx++) |
450 | for (dx = -1; dx <= 1; dx++) |
470 | { |
451 | { |
471 | for (dy = -1; dy <= 1; dy++) |
452 | for (dy = -1; dy <= 1; dy++) |
472 | { |
453 | { |
… | |
… | |
516 | * being nonzero have been changed to check for 1. Also, since |
497 | * being nonzero have been changed to check for 1. Also, since |
517 | * map_mark is a char value, putting 2 in should cause no problems. |
498 | * map_mark is a char value, putting 2 in should cause no problems. |
518 | * |
499 | * |
519 | * This function examines the map the player is on, and determines what |
500 | * This function examines the map the player is on, and determines what |
520 | * is visible. 2 is set for walls or objects that blocks view. 1 |
501 | * is visible. 2 is set for walls or objects that blocks view. 1 |
521 | * is for open spaces. map_mark should already have been initialized |
502 | * is for open spaces. map_mark should already have been initialised |
522 | * to zero before this is called. |
503 | * to zero before this is called. |
523 | * strength is an initial strength*2 rectangular area that we automatically |
504 | * strength is an initial strength*2 rectangular area that we automatically |
524 | * see in/penetrate through. |
505 | * see in/penetrate through. |
525 | */ |
506 | */ |
526 | |
507 | |
… | |
… | |
528 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
509 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
529 | { |
510 | { |
530 | int x, y, mflags; |
511 | int x, y, mflags; |
531 | sint16 nx, ny; |
512 | sint16 nx, ny; |
532 | maptile *mp; |
513 | maptile *mp; |
533 | New_Face *f; |
514 | facetile *f; |
534 | |
515 | |
535 | for (x = -strength; x < strength; x++) |
516 | for (x = -strength; x < strength; x++) |
536 | { |
517 | { |
537 | for (y = -strength; y < strength; y++) |
518 | for (y = -strength; y < strength; y++) |
538 | { |
519 | { |
… | |
… | |
568 | * The following function is a lot messier than it really should be, |
549 | * The following function is a lot messier than it really should be, |
569 | * but there is no real easy solution. |
550 | * but there is no real easy solution. |
570 | * |
551 | * |
571 | * Mark Wedel |
552 | * Mark Wedel |
572 | */ |
553 | */ |
573 | |
|
|
574 | void |
554 | void |
575 | draw_magic_map (object *pl) |
555 | draw_magic_map (object *pl) |
576 | { |
556 | { |
577 | char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
557 | char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
578 | int xmin, xmax, ymin, ymax; |
558 | int xmin, xmax, ymin, ymax; |