ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/info.C
(Generate patch)

Comparing deliantra/server/socket/info.C (file contents):
Revision 1.5 by root, Sun Sep 10 13:43:33 2006 UTC vs.
Revision 1.11 by root, Wed Sep 20 21:53:50 2006 UTC

1
2/*
3 * static char *rcsid_sock_info_c =
4 * "$Id: info.C,v 1.5 2006/09/10 13:43:33 root Exp $";
5 */
6 1
7/* 2/*
8 CrossFire, A Multiplayer game for X-windows 3 CrossFire, A Multiplayer game for X-windows
9 4
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
22 17
23 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 21
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 22 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 23*/
29 24
30/** 25/**
31 * \file 26 * \file
32 * Basic client output functions. 27 * Basic client output functions.
101 96
102static void 97static void
103print_message (int colr, const object *pl, const char *tmp) 98print_message (int colr, const object *pl, const char *tmp)
104{ 99{
105 100
106 if (tmp == (char *) NULL) 101 if (!tmp)
107 {
108 tmp = "[NULL]"; 102 tmp = "[NULL]";
109 }
110 103
111 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 104 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
112 return; 105 return;
113 106
114 if (pl->type == PLAYER) 107 if (pl->type == PLAYER)
115 { 108 {
116 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); 109 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp);
117 return; 110 return;
118 } 111 }
119} 112}
120
121 113
122/** 114/**
123 * Prints out the contents of specified buffer structures, 115 * Prints out the contents of specified buffer structures,
124 * and clears the string. 116 * and clears the string.
125 */ 117 */
227 int i; 219 int i;
228 220
229 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) 221 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next)
230 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); 222 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf);
231 223
232 for (i = 1; i < socket_info.allocated_sockets; i++)
233 {
234 if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri < 10)
235 {
236 cs_write_string (&init_sockets[i], buf, strlen (buf));
237 /* Most messages don't have a newline, so add one */
238 cs_write_string (&init_sockets[i], "\n", 1);
239 }
240 }
241
242 return; 224 return;
243 } 225 }
226
244 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 227 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
245 { 228 {
246 /* Write to the socket? */ 229 /* Write to the socket? */
247 print_message (0, NULL, buf); 230 print_message (0, NULL, buf);
248 return; 231 return;
249 } 232 }
233
250 if (pl->type != PLAYER) 234 if (pl->type != PLAYER)
251 return; 235 return;
236
252 if (pri >= pl->contr->listening) 237 if (pri >= pl->contr->listening)
253 return; 238 return;
254 239
255 if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) 240 if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE))
256 {
257 /* following prints stuff out, as appropriate */ 241 /* following prints stuff out, as appropriate */
258 check_output_buffers (pl, buf); 242 check_output_buffers (pl, buf);
259 }
260 else 243 else
261 {
262 print_message (flags & NDI_COLOR_MASK, pl, buf); 244 print_message (flags & NDI_COLOR_MASK, pl, buf);
263 }
264} 245}
265 246
266/** 247/**
267 * Wrapper for new_draw_info printf-like. 248 * Wrapper for new_draw_info printf-like.
268 * 249 *
355/** 336/**
356 * Writes to everyone on the map *except* op. This is useful for emotions. 337 * Writes to everyone on the map *except* op. This is useful for emotions.
357 */ 338 */
358 339
359void 340void
360new_info_map_except (int color, mapstruct *map, object *op, const char *str) 341new_info_map_except (int color, maptile * map, object *op, const char *str)
361{ 342{
362 player *pl; 343 player *pl;
363 344
364 for (pl = first_player; pl != NULL; pl = pl->next) 345 for (pl = first_player; pl != NULL; pl = pl->next)
365 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) 346 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op)
371/** 352/**
372 * Writes to everyone on the map except op1 and op2 353 * Writes to everyone on the map except op1 and op2
373 */ 354 */
374 355
375void 356void
376new_info_map_except2 (int color, mapstruct *map, object *op1, object *op2, const char *str) 357new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str)
377{ 358{
378 player *pl; 359 player *pl;
379 360
380 for (pl = first_player; pl != NULL; pl = pl->next) 361 for (pl = first_player; pl != NULL; pl = pl->next)
381 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) 362 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2)
387/** 368/**
388 * Writes to everyone on the specified map 369 * Writes to everyone on the specified map
389 */ 370 */
390 371
391void 372void
392new_info_map (int color, mapstruct *map, const char *str) 373new_info_map (int color, maptile * map, const char *str)
393{ 374{
394 player *pl; 375 player *pl;
395 376
396 for (pl = first_player; pl != NULL; pl = pl->next) 377 for (pl = first_player; pl != NULL; pl = pl->next)
397 if (pl->ob != NULL && pl->ob->map == map) 378 if (pl->ob != NULL && pl->ob->map == map)
417void 398void
418rangetostring (object *pl, char *obuf) 399rangetostring (object *pl, char *obuf)
419{ 400{
420 switch (pl->contr->shoottype) 401 switch (pl->contr->shoottype)
421 { 402 {
422 case range_none: 403 case range_none:
423 strcpy (obuf, "Range: nothing"); 404 strcpy (obuf, "Range: nothing");
424 break; 405 break;
425 406
426 case range_bow: 407 case range_bow:
408 {
409 object *op;
410
411 for (op = pl->inv; op; op = op->below)
412 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED))
413 break;
414
415 if (op == NULL)
416 break;
417
418 sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing");
419 }
420 break;
421
422 case range_magic:
423 if (settings.casting_time == TRUE)
427 { 424 {
428 object *op; 425 if (pl->casting_time > -1)
429 426 {
430 for (op = pl->inv; op; op = op->below) 427 if (pl->casting_time == 0)
431 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) 428 sprintf (obuf, "Range: Holding spell (%s)", &pl->spell->name);
432 break; 429 else
433 if (op == NULL) 430 sprintf (obuf, "Range: Casting spell (%s)", &pl->spell->name);
434 break; 431 }
435 432 else
436 sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); 433 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
437 } 434 }
438 break;
439
440 case range_magic:
441 if (settings.casting_time == TRUE)
442 {
443 if (pl->casting_time > -1)
444 {
445 if (pl->casting_time == 0)
446 sprintf (obuf, "Range: Holding spell (%s)", (const char *) pl->spell->name);
447 else
448 sprintf (obuf, "Range: Casting spell (%s)", (const char *) pl->spell->name);
449 }
450 else
451 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
452 }
453 else 435 else
454 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); 436 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
455 break; 437 break;
456 438
457 case range_misc: 439 case range_misc:
458 sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none"); 440 sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none");
459 break; 441 break;
460 442
461 /* range_scroll is only used for controlling golems. If the 443 /* range_scroll is only used for controlling golems. If the
462 * the player does not have a golem, reset some things. 444 * the player does not have a golem, reset some things.
463 */ 445 */
464 case range_golem: 446 case range_golem:
465 if (pl->contr->ranges[range_golem] != NULL) 447 if (pl->contr->ranges[range_golem] != NULL)
466 sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); 448 sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name);
467 else 449 else
468 { 450 {
469 pl->contr->shoottype = range_none; 451 pl->contr->shoottype = range_none;
470 strcpy (obuf, "Range: nothing"); 452 strcpy (obuf, "Range: nothing");
471 } 453 }
472 break; 454 break;
473 455
474 case range_skill: 456 case range_skill:
475 sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none"); 457 sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none");
476 break; 458 break;
477 459
478 case range_builder: 460 case range_builder:
479 sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0)); 461 sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0));
480 break; 462 break;
481 463
482 default: 464 default:
483 strcpy (obuf, "Range: illegal"); 465 strcpy (obuf, "Range: illegal");
484 } 466 }
485} 467}
486 468
487/** 469/**
488 * Sets player title. 470 * Sets player title.
512static void 494static void
513magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) 495magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py)
514{ 496{
515 int x, y, dx, dy, mflags; 497 int x, y, dx, dy, mflags;
516 sint16 nx, ny; 498 sint16 nx, ny;
517 mapstruct *mp; 499 maptile *mp;
518 New_Face *f; 500 New_Face *f;
519 501
520 for (dx = -1; dx <= 1; dx++) 502 for (dx = -1; dx <= 1; dx++)
521 { 503 {
522 for (dy = -1; dy <= 1; dy++) 504 for (dy = -1; dy <= 1; dy++)
578void 560void
579magic_mapping_mark (object *pl, char *map_mark, int strength) 561magic_mapping_mark (object *pl, char *map_mark, int strength)
580{ 562{
581 int x, y, mflags; 563 int x, y, mflags;
582 sint16 nx, ny; 564 sint16 nx, ny;
583 mapstruct *mp; 565 maptile *mp;
584 New_Face *f; 566 New_Face *f;
585 567
586 for (x = -strength; x < strength; x++) 568 for (x = -strength; x < strength; x++)
587 { 569 {
588 for (y = -strength; y < strength; y++) 570 for (y = -strength; y < strength; y++)
692 int i; 674 int i;
693 size_t len; 675 size_t len;
694 char buf[MAX_BUF]; 676 char buf[MAX_BUF];
695 677
696 if (With != NULL) 678 if (With != NULL)
697 {
698 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); 679 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType);
699 }
700 else 680 else
701 {
702 snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); 681 snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType);
703 } 682
704 len = strlen (buf); 683 len = strlen (buf);
705 for (i = 1; i < socket_info.allocated_sockets; i++)
706 {
707 if (init_sockets[i].old_mode == Old_Listen)
708 {
709 cs_write_string (&init_sockets[i], buf, len);
710 }
711 }
712} 684}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines