Archive for July, 1998

Cloud Leaves quake.ie

With my departure from quake.ie, this page is no longer being regularly maintained.

Server Logs to Client Format

Here’s my ser2cli C program to convert QuakeWorld server logs to client-type logs for use with the Htmllog utility by Mark Toller. Quite simple looking but does the job.

// ser2cli.c, John Breslin, 18 January 1998

#include <stdio.h>
#include <stdlib.h>

void main (void) {

  char *start, *end, *space1, *space2, *stop1, *stop2;
  char line[101], name1[101], name2[101], check[5], part1[101], part2[101];
  FILE *ifp, *ofp;
  int i, flag;

  ifp = fopen("server.log", "r");
  ofp = fopen("client.log", "w");
  flag = 0;

  while (fgets(line, 100, ifp) == line) {
    if (strstr(line, "The match has begun!")) flag = 1;
    if (strstr(line, "Match Results: QW TM")) flag = 0;
    if (strstr(line, "suicide") && flag == 0) {
      sprintf(line, "n");
    }
    if (strstr(line, "[") != 0 && strstr(line, "]") != 0) {
      i = 0;
      while (i < 128) {
        sprintf(check, "[%02x]", i);
        while (strstr(line, check) != 0) {
          strcpy(part1, line);
          stop1 = strstr(part1, check);
          stop1[0] = '';
          strcpy(part2, strstr(line, check) + 4);
          sprintf(line, "%s%c%s", part1, i + 128, part2);
        }
        i++;
      }
    }
    if (strstr(line, " a new one") != 0 && strstr(line, " rips ") != 0) {
      strcpy(name1, line);
      space1 = strstr(name1, " rips ");
      space1[0] = '';
      strcpy(name2, strstr(line, " rips ") + 6);
      space2 = strstr(name2, " a new one");
      space2[0] = '';
      sprintf(line, "%s was destroyed by %s's Quad rocketn", name2, name1);
    }
    fputs(line, ofp);
    if (strstr(line, ".pak : maps/") != 0) {
      start = strstr(line, ".pak : maps/") + 12;
      end = strstr(line, ".bsp");
      end[0] = '';
      fprintf(ofp, "");
      fprintf(ofp, "nn%sn", start);
    }
    if (strstr(line, "./id1/maps/") != 0) {
      start = strstr(line, "./id1/maps/") + 11;
      end = strstr(line, ".bsp");
      end[0] = '';
      fprintf(ofp, "");
      fprintf(ofp, "nn%sn", start);
    }
  }
}