--- deliantra/server/socket/info.C 2006/09/10 13:43:33 1.5 +++ deliantra/server/socket/info.C 2006/12/09 17:28:37 1.12 @@ -1,10 +1,5 @@ /* - * static char *rcsid_sock_info_c = - * "$Id: info.C,v 1.5 2006/09/10 13:43:33 root Exp $"; - */ - -/* CrossFire, A Multiplayer game for X-windows Copyright (C) 2002 Mark Wedel & Crossfire Development Team @@ -24,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ /** @@ -103,10 +98,8 @@ print_message (int colr, const object *pl, const char *tmp) { - if (tmp == (char *) NULL) - { - tmp = "[NULL]"; - } + if (!tmp) + tmp = "[NULL]"; if (!pl || (pl->type == PLAYER && pl->contr == NULL)) return; @@ -118,7 +111,6 @@ } } - /** * Prints out the contents of specified buffer structures, * and clears the string. @@ -224,43 +216,31 @@ if (flags & NDI_ALL) { player *tmppl; - int i; for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); - for (i = 1; i < socket_info.allocated_sockets; i++) - { - if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri < 10) - { - cs_write_string (&init_sockets[i], buf, strlen (buf)); - /* Most messages don't have a newline, so add one */ - cs_write_string (&init_sockets[i], "\n", 1); - } - } - return; } + if (!pl || (pl->type == PLAYER && pl->contr == NULL)) { /* Write to the socket? */ print_message (0, NULL, buf); return; } + if (pl->type != PLAYER) return; + if (pri >= pl->contr->listening) return; if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) - { - /* following prints stuff out, as appropriate */ - check_output_buffers (pl, buf); - } + /* following prints stuff out, as appropriate */ + check_output_buffers (pl, buf); else - { - print_message (flags & NDI_COLOR_MASK, pl, buf); - } + print_message (flags & NDI_COLOR_MASK, pl, buf); } /** @@ -357,7 +337,7 @@ */ void -new_info_map_except (int color, mapstruct *map, object *op, const char *str) +new_info_map_except (int color, maptile * map, object *op, const char *str) { player *pl; @@ -373,7 +353,7 @@ */ void -new_info_map_except2 (int color, mapstruct *map, object *op1, object *op2, const char *str) +new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) { player *pl; @@ -389,7 +369,7 @@ */ void -new_info_map (int color, mapstruct *map, const char *str) +new_info_map (int color, maptile * map, const char *str) { player *pl; @@ -419,68 +399,69 @@ { switch (pl->contr->shoottype) { - case range_none: - strcpy (obuf, "Range: nothing"); - break; + case range_none: + strcpy (obuf, "Range: nothing"); + break; - case range_bow: - { - object *op; + case range_bow: + { + object *op; - for (op = pl->inv; op; op = op->below) - if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) - break; - if (op == NULL) + for (op = pl->inv; op; op = op->below) + if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) break; - sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); - } - break; + if (op == NULL) + break; - case range_magic: - if (settings.casting_time == TRUE) - { - if (pl->casting_time > -1) - { - if (pl->casting_time == 0) - sprintf (obuf, "Range: Holding spell (%s)", (const char *) pl->spell->name); - else - sprintf (obuf, "Range: Casting spell (%s)", (const char *) pl->spell->name); - } - else - sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); - } - else - sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); - break; + sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); + } + break; - case range_misc: - sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none"); - break; - - /* range_scroll is only used for controlling golems. If the - * the player does not have a golem, reset some things. - */ - case range_golem: - if (pl->contr->ranges[range_golem] != NULL) - sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); - else - { - pl->contr->shoottype = range_none; - strcpy (obuf, "Range: nothing"); - } - break; + case range_magic: + if (settings.casting_time == TRUE) + { + if (pl->casting_time > -1) + { + if (pl->casting_time == 0) + sprintf (obuf, "Range: Holding spell (%s)", &pl->spell->name); + else + sprintf (obuf, "Range: Casting spell (%s)", &pl->spell->name); + } + else + sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); + } + else + sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); + break; + + case range_misc: + sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none"); + break; + + /* range_scroll is only used for controlling golems. If the + * the player does not have a golem, reset some things. + */ + case range_golem: + if (pl->contr->ranges[range_golem] != NULL) + sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); + else + { + pl->contr->shoottype = range_none; + strcpy (obuf, "Range: nothing"); + } + break; - case range_skill: - sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none"); - break; - - case range_builder: - sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0)); - break; + case range_skill: + sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none"); + break; + + case range_builder: + sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0)); + break; - default: - strcpy (obuf, "Range: illegal"); + default: + strcpy (obuf, "Range: illegal"); } } @@ -514,7 +495,7 @@ { int x, y, dx, dy, mflags; sint16 nx, ny; - mapstruct *mp; + maptile *mp; New_Face *f; for (dx = -1; dx <= 1; dx++) @@ -580,7 +561,7 @@ { int x, y, mflags; sint16 nx, ny; - mapstruct *mp; + maptile *mp; New_Face *f; for (x = -strength; x < strength; x++) @@ -689,24 +670,13 @@ void Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) { - int i; size_t len; char buf[MAX_BUF]; if (With != NULL) - { - snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); - } + snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); else - { - snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); - } + snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); + len = strlen (buf); - for (i = 1; i < socket_info.allocated_sockets; i++) - { - if (init_sockets[i].old_mode == Old_Listen) - { - cs_write_string (&init_sockets[i], buf, len); - } - } }