/* NOT [BDyess] 8/22/95 */
void
dmessage(char *message, unsigned int flags, unsigned int from, unsigned int to)
{
    struct distress dist;
    int len;
    /*char dead[20], alive[20];*/

    /* aha! A new type distress/macro call came in. parse it appropriately */
    if (F_gen_distress && (flags == (MTEAM | MDISTR | MVALID))) {
	if (paradise)
	    printf("RCD: %s\n", message);
	HandleGenDistr(message, from, to, &dist);
	len = makedistress(&dist, message, distmacro[dist.distype].macro);
	if (UseLite)
	    rcdlite(&dist);
	if (len <= 0)
	    return;
	flags ^= MDISTR;
    }
    /*
       keep track of how many queued messages there are for use with the
       infoIcon [BDyess]
    */
    if (infoIcon) {
	if (to == me->p_no && flags & MINDIV) {	/* personal message */
	    me_messages++;
	} else if (flags & MTEAM) {	/* team message */
	    team_messages++;
	} else {		/* message for all */
	    all_messages++;
	}
	if (iconified)
	    drawIcon();
    }
    logit(message);

    /*
       fix for upgrade bug.  Forced UDP would resend numbers, (thinking them
       speed changes) screwing up upgrading on those twinkish sturgeon
       servers. [BDyess]
    */
    if (strncmp(message, "UPG->", 5) == 0)
	upgrading = 1;
    if (upgrading && !(me->p_flags & PFORBIT))
	upgrading = 0;

    if ((from != me->p_no) || pigSelf)
	rsvp_borg_call(message, from);

    /* beep when a personal message is sent while iconified [BDyess] */
    if (to == me->p_no && (flags & MINDIV) && iconified) {
	W_Beep();
    }
    if (from == 255 &&
	strcmp(message, "Tractor beam aborted warp engagement") == 0) {
	me->p_flags &= ~PFWARPPREP;
    }
    /* want a warning for personal kills, so check here [BDyess] */
    /* and personal deaths [BDyess] */
    if(strncmp(message,"GOD->ALL",8) && (0 == strcmp(message,pseudo))) {
      hwarning(message+9);
    }
    print_message(message, flags, from, to);
}
Esempio n. 2
0
dmessage(char *message, unsigned char flags, unsigned char from, unsigned char to)
{
  register int len;
  W_Color color;
  char    timebuf[10];
  LONG    curtime;
  struct tm *tm;
  char    buf[80];
  int     take, destroy, team, kill, killp, killa, bomb, conq;
  struct distress dist;

  take = MTEAM + MTAKE + MVALID;
  destroy = MTEAM + MDEST + MVALID;
  kill = MALL + MKILL + MVALID;
  killp = MALL + MKILLP + MVALID;
  killa = MALL + MKILLA + MVALID;
  bomb = MTEAM + MBOMB + MVALID;
  team = MTEAM + MVALID;
  conq = MALL + MCONQ + MVALID;

  time(&curtime);
  tm = localtime(&curtime);
  sprintf(timebuf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
  len = strlen(message);
  if (from == 255)
    {
      /* From God */
      color = textColor;
    }
  else
    {
      color = playerColor(&(players[from]));
    }
  if (censorMessages)
    if ((flags != kill) && (flags != killp) &&
  (flags != killa) && (flags != bomb) &&
  (flags != take) && (flags != destroy))
      censor(message);

  /* aha! A new type distress/macro call came in. parse it appropriately */
  if (flags == (MTEAM | MDISTR | MVALID))
    {
      HandleGenDistr(message, from, to, &dist);
      len = makedistress(&dist, message, distmacro[dist.distype].macro);

#ifdef BEEPLITE
      if (UseLite)
  rcdlite(&dist);
#endif

      if (len <= 0)
  return;
      flags ^= MDISTR;
    }


  if (niftyNewMessages)
    {
      if (logmess)
  {
    if (logFile != NULL)
      {
        fprintf(logFile, "%s: %s\n", timebuf, message);
        fflush(logFile);
      }
    else
      {
        printf("%s: %s\n", timebuf, message);
      }
  }
      if (!(logmess && logFile == NULL) && flags == conq)
  {
    /* output conquer stuff to stdout in addition to message window */
    fprintf(stdout, "%s\n", message);
    if (instr(message, "kill"))
      {
        fprintf(stdout, "NOTE: The server here does not properly set message flags\n");
        fprintf(stdout, "You should probably pester the server god to update....\n");
      }
  }
      if (flags == (MCONFIG + MINDIV + MVALID))
  {
    if (from == 255)
      CheckFeatures(message);
    return;
  }
      if ((flags == team) || (flags == take) || (flags == destroy))
  {
    W_WriteText(messwt, 0, 0, color, message, len, shipFont(me));
    if ((flags == team) &&
        !strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        printf("dmessage:flags==team PIG call from=%d\n", from);
        pmessage(cowid, from, MINDIV);
      }
  }

      else if ((flags == kill) || (flags == killp) ||
         (flags == killa) || (flags == bomb))
  {
    W_WriteText(messwk, 0, 0, color, message, len, 0);
    if (!reportKills)
      return;        /* HW */
  }

      else if (flags & MINDIV)
  {
    W_WriteText(messwi, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        printf("dmessage:MINDIV PIG call from=%d\n", from);
        pmessage(cowid, from, MINDIV);
      }
  }
      else
  {          /* if we don't know where *
              * * the message beLONGs by
              * * * this time, stick it
              * in * * the all board... */
    W_WriteText(messwa, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
  }
      W_WriteText(reviewWin, 0, 0, color, message, len, 0);

    }
  else
    {

      /* ok, here we have the old kludge nastiness that we can turn on if we
       * * * HAVE to.  yuk, blech, ptooie... */

      if ((strncmp(message, "GOD->ALL", 8) == 0 &&
     (instr(message, "was kill") ||
      instr(message, "killed by"))) ||
    (*message != ' ' && instr(message, "We are being attacked")))
  {
    W_WriteText(messwk, 0, 0, color, message, len, 0);
    if (!reportKills)
      return;
    W_WriteText(reviewWin, 0, 0, color, message, len, 0);
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    return;
  }
      switch (flags & (MTEAM | MINDIV | MALL))
  {
  case MTEAM:
    W_WriteText(messwt, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  case MINDIV:
    if (!(flags & MCONFIG))
      W_WriteText(messwi, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  default:
    W_WriteText(messwa, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  }
      W_WriteText(reviewWin, 0, 0, color, message, len, 0);
    }
}