Re: [LONG] Avatar and decapitate code with graveyard

From: Doppleganger Software (doppsoft@TZC.COM)
Date: 09/04/98


>And one user removed for an open flame on the list.
>
>Thank you, don't come again.

Just a quick note to Alex, he's got several e-mail account, he'll
probably join with one of the others.

ObCircle:

Back to what was said efore by Alex & George: patches are not always
going to be something you can just drop in and use.  Unless they are
something self-contained, like a spec-proc, or a manual spell, they will
require some thought when adding in.  Unfortunately, there are a lot of
people who just add them as-is, and then come to the list asking us why
they don't work.  Now, I understand if it's some obscure thing that even
experienced programmers get irked with (pointers, EVIL pointers!) but
most of the time, it's just a matter of them not understanding the
simplest parts of the code.

Oh yeah, Alex, here's the most recent version of my linewrap code.  I
think I finally killed all the quirks in it.

char *linewrap(char *str, int max)
{
  char xbuf2[MAX_STRING_LENGTH];
  char xbuf[MAX_STRING_LENGTH];
  char *tmp;
  int i, lline = 0, curr = 0, sline = 0;
  bool spec_code = FALSE;

  if (max < 40)
    max = 80;
  xbuf2[0] =xbuf[0] = '\0';
  i = max - 1;

  if (strlen(str) < i)
    return (str);

  tmp = str;
  while (*tmp && tmp) {
    if (*tmp == '\x1B'&& !spec_code)
      spec_code = TRUE;
    if (*tmp == ' ') {
      if (lline > i) {
        while (xbuf[strlen(xbuf) - 1] == ' ')
          xbuf[strlen(xbuf) - 1] = '\0';
        sprintf(xbuf, "%s\r\n%s ", xbuf, xbuf2);
        sline++;
        lline = sline;
        curr = 0;
        xbuf2[0] = '\0';
      } else {
        sprintf(xbuf, "%s%s ", xbuf, xbuf2);
        sline = 0;
        lline++;
        curr = 0;
        xbuf2[0] = '\0';
      }
    } else if ((*tmp == '\r') && (*(tmp+1) == '\n')) {
      tmp++;
      if (lline > i) {
        while (xbuf[strlen(xbuf) - 1] == ' ')
          xbuf[strlen(xbuf) - 1] = '\0';
        sprintf(xbuf, "%s\r\n%s\r\n", xbuf, xbuf2);
      } else
        sprintf(xbuf, "%s%s\r\n", xbuf, xbuf2);
      lline = 0;
      sline = 0;
      curr = 0;
      xbuf2[0] = '\0';
    } else if ((*tmp == '\n') && (*(tmp+1) == '\r')) {
      tmp++;
      if (lline > i) {
        while (xbuf[strlen(xbuf) - 1] == ' ')
          xbuf[strlen(xbuf) - 1] = '\0';
        sprintf(xbuf, "%s\r\n%s\r\n", xbuf, xbuf2);
      } else
        sprintf(xbuf, "%s%s\r\n", xbuf, xbuf2);
      lline = 0;
      sline = 0;
      curr = 0;
      xbuf2[0] = '\0';
    } else {
      xbuf2[curr] = *tmp;
      xbuf2[curr + 1] = '\0';
      curr++;
      if (!spec_code) {
        lline++;
        sline++;
      }
    }
    if (*tmp == 'm' && spec_code)
      spec_code = FALSE;
    tmp++;
  }
  if (lline > i) {
    while (xbuf[strlen(xbuf) - 1] == ' ')
      xbuf[strlen(xbuf) - 1] = '\0';
    sprintf(xbuf, "%s\r\n%s", xbuf, xbuf2);
  } else
    sprintf(xbuf, "%s%s", xbuf, xbuf2);

  return (str_dup(xbuf));
}


---
"One hundred years from now, none of this will matter because you and I
will be dead -- unless the Grim Reaper has switched his record-keeping to
a Windows 95-based system, in which case we all might live forever. "
-- Associated Press


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST