コード例 #1
0
ファイル: redraw.c プロジェクト: timothyzillion/netrek
/* update stat window record for max speed, army capacity */
updateMaxStats(int redraw)
{
  char    buf[BUFSIZ];
  static int lastdamage = -1;
  static int lastkills = -1;
  static int lastship = -1;
  int     maxspeed;
  int     troop_capacity;
  float   kills;
  int     mykills;

  if (newDashboard)
    return;

  if ((me->p_flags & (PFPLOCK | PFOBSERV)) == (PFPLOCK | PFOBSERV))
    kills = players[me->p_playerl].p_kills;
  else
    kills = me->p_kills;

  mykills = (int) (10. * kills);

  /* don't really need a update if nothing's changed! */
  if (!redraw && lastkills == mykills && lastship == me->p_ship.s_type &&
      lastdamage == me->p_damage)
    return;

  lastkills = mykills;
  lastdamage = me->p_damage;
  lastship = me->p_ship.s_type;

  if (me->p_ship.s_type == ASSAULT)
    troop_capacity = (((kills * 3) > me->p_ship.s_maxarmies) ?
          me->p_ship.s_maxarmies : (int) (kills * 3));
  else if (me->p_ship.s_type != STARBASE)
    troop_capacity = (((kills * 2) > me->p_ship.s_maxarmies) ?
          me->p_ship.s_maxarmies : (int) (kills * 2));
  else
    troop_capacity = me->p_ship.s_maxarmies;

  maxspeed = (me->p_ship.s_maxspeed + 2) -
      (me->p_ship.s_maxspeed + 1) *
      ((float) me->p_damage / (float) (me->p_ship.s_maxdamage));
  if (maxspeed > me->p_ship.s_maxspeed)
    maxspeed = me->p_ship.s_maxspeed;
  if (maxspeed < 0)
    maxspeed = 0;


  sprintf(buf,
  "Flags        Warp Dam Shd Torps  Kills Armies   Fuel  Wtemp Etemp  Time");
  W_WriteText(tstatw, 50, 5, textColor, buf, strlen(buf), W_RegularFont);
  sprintf(buf,
  "Maximum:   %2d/%2d  %3d %3d              %2d/%2d  %6d   %3d   %3d",
    maxspeed, me->p_ship.s_maxspeed,
    me->p_ship.s_maxdamage, me->p_ship.s_maxshield,
    troop_capacity, me->p_ship.s_maxarmies,
    me->p_ship.s_maxfuel, me->p_ship.s_maxwpntemp / 10,
    me->p_ship.s_maxegntemp / 10);
  W_WriteText(tstatw, 50, 27, textColor, buf, strlen(buf), W_RegularFont);
}
コード例 #2
0
static void
warrefresh(void)
{
    fillwin(0, feds, newhostile, me->p_swar, FEDm);
    fillwin(1, roms, newhostile, me->p_swar, ROMm);
    fillwin(2, klis, newhostile, me->p_swar, KLIm);
    fillwin(3, oris, newhostile, me->p_swar, ORIm);
    W_WriteText(war, 0, 4, textColor, gos, strlen(gos), 0);
    W_WriteText(war, 0, 5, textColor, exs, strlen(exs), 0);
}
コード例 #3
0
ファイル: parsemeta.c プロジェクト: hhirsch/netrek
void    metawindow()
/* Show the meta server menu window */
{
  int i, height;
  char *header;
  static int lastHeight = 0;

  if (!metaWin) {
    height = 250 + metaHeight * (W_Textheight + 8) + 4 * (metaHeight - 1);
    metaWin = W_MakeWindow("Netrek Server List", 0, 0, 716, height, NULL, 2,
                           foreColor);
    W_SetBackgroundImage(metaWin, "Misc/map_back.png");
    logo = W_ReadImage(metaWin, "netrek-green-white-300px.png");
    metaList = W_MakeMenu("metalist", 50, 200, LINE, metaHeight, metaWin, 1);
    lastHeight = metaHeight;
    make_help();
  } else {
    if (metaHeight > lastHeight) {
      W_ReinitMenu(metaList, LINE, metaHeight);
      W_ResizeMenu(metaList, LINE, metaHeight);
      lastHeight = metaHeight;
    }
    // FIXME: handle metaList growing beyond metaWin
  }

  header = "Server                                           Status        Type      Age";
  W_WriteText(metaList, 0, 0, W_Cyan, header, -1, 0);

  for (i = 0; i < metaHeight; i++) redraw(i);

  /* Give the window the right name */
  W_RenameWindow(metaWin, metaWindowName);

  /* Add additional options */
  W_WriteText(metaList, 0, metaHeight-B_REFRESH, W_Yellow,
              "Refresh                                           (r)",
              -1, 0);
  add_redraw();
  W_WriteText(metaList, 0, metaHeight-B_HELP, W_Yellow,
                "Help & Tips                                       (h)",
              -1, 0);
  W_WriteText(metaList, 0, metaHeight-B_QUIT, W_Yellow,
                "Quit                                              (q)",
              -1, 0);

  /* Map window */
  W_MapWindow(metaList);
  W_MapWindow(metaWin);
}
コード例 #4
0
ファイル: getname.c プロジェクト: timothyzillion/netrek
makeNewGuy(void)
/* Make the dude with name tempname and password password1. Move to state
 * ST_DONE. */
{
  char   *s;

  if (strcmp(password1, password2) != 0)
    {
      if (!autolog)
  {
    s = "Passwords do not match";
    W_WriteText(w, 100, 130, textColor, s, strlen(s), W_BoldFont);
    (void) W_EventsPending();
    sleep(3);
    W_ClearWindow(w);
  }
      else
  noautologin();
      *tempname = 0;
      state = ST_GETNAME;
      return;
    }

  /* same routine! */
  checkpassword();
}
コード例 #5
0
static void
showTimeLeft(int t, int max)
{
    char    buf[BUFSIZ];
    int     cx, cy, ex, ey, tx, ty;

    if ((max - t) < 10 && t & 1) {
	W_Beep();
	W_Deiconify(baseWin);
    }
    if (iconified)
	drawIcon();
    /* XFIX */
    W_ClearArea(qwin, 0, 0, BOXSIDE, BOXSIDE);

    W_DrawImageNoClip(qwin, 0, 0, 0, getImage(I_CLOCK), foreColor);

    cx = BOXSIDE / 2;
    cy = BOXSIDE / 2 - 6;
    ex = cx - 35 * Sin[((255 * t) / max + 64) % 256];
    ey = cy - 35 * Cos[((255 * t) / max + 64) % 256];
    W_MakeLine(qwin, cx, cy, ex, ey, foreColor);

    sprintf(buf, "%d", max - t);
    cy = BOXSIDE / 2 - 1;
    tx = cx - (int)W_StringWidth(buf, W_RegularFont) / 2;
    ty = cy - W_Textheight;
    W_WriteText(qwin, tx, ty, textColor, buf, strlen(buf), W_RegularFont);
}
コード例 #6
0
ファイル: option.c プロジェクト: timothyzillion/netrek
/* blank out option line 'i' */
OptionClear(int i)
{
  char   *blanktext = "                                               ";

  if (optionWin && notdone)
    W_WriteText(optionWin, 0, i, textColor, blanktext, OPTIONLEN, 0);
}
コード例 #7
0
ファイル: parsemeta.c プロジェクト: hhirsch/netrek
static void add_redraw()
{
  char buf[LINE + 1];

  snprintf(buf, LINE, "Add a server: %s_", add_buffer);
  W_WriteText(metaList, 0, metaHeight-B_ADD, W_Yellow, buf, -1, 0);
}
コード例 #8
0
static void
fillwin(int menunum, char *string, int hostile, int warbits, int teammask)
{
    char    buf[80];

    if (teammask & warbits) {
	(void) sprintf(buf, "  %s%s", string, wars);
	W_WriteText(war, 0, menunum, rColor, buf, strlen(buf), 0);
    } else if (teammask & hostile) {
	(void) sprintf(buf, "  %s%s", string, hostiles);
	W_WriteText(war, 0, menunum, yColor, buf, strlen(buf), 0);
    } else {
	(void) sprintf(buf, "  %s%s", string, peaces);
	W_WriteText(war, 0, menunum, gColor, buf, strlen(buf), 0);
    }
}
コード例 #9
0
void
sprefresh(int i)
{
    char    buf[BUFSIZ];

    switch (i) {

    case SPK_VFIELD:
	sprintf(buf, "%seceive variable and short packets",
		recv_short ? "R" : "Don't r");
	break;
    case SPK_MFIELD:
	sprintf(buf, "%seceive messages", recv_mesg ? "R" : "Don't r");
	break;
    case SPK_KFIELD:
	sprintf(buf, "%seceive kill messages", recv_kmesg ? "R" : "Don't r");
	break;
    case SPK_WFIELD:
	sprintf(buf, "%seceive warning messages", recv_warn ? "R" : "Don't r");
	break;
    case SPK_TFIELD:
	sprintf(buf, "Receive threshold: %s_", recv_threshold_s);
	break;
    case SPK_WHYFIELD:
	sprintf(buf, "%sdd why dead messages", why_dead ? "A" : "Don't a");
	break;
    case SPK_DONE:
	sprintf(buf, "Done");
	break;
    }

    W_WriteText(spWin, 0, i, textColor, buf, strlen(buf), 0);
}
コード例 #10
0
ファイル: findslot.c プロジェクト: timothyzillion/netrek
mapWaitCount(W_Window waitWin, W_Window countWin, int count)
{
  char   *s1 = "Wait";
  char   *s2 = "Queue";
  char    buf[80];
  int     length;

  W_WriteText(countWin, 17, 5, textColor, s1, strlen(s1), W_RegularFont);
  W_WriteText(countWin, 15, 15, textColor, s2, strlen(s2), W_RegularFont);
  sprintf(buf, "%d    ", count);
  if (count == -1)
    STRNCPY(buf, "?", 2);
  W_WriteText(countWin, WAITWIDTH / 6 - strlen(buf) * W_Textwidth / 2, 25,
        textColor, buf, strlen(buf), W_RegularFont);
  sprintf(buf, "Q%d @ %s", count, serverName);
  W_SetWindowName(waitWin, buf);
}
コード例 #11
0
ファイル: parsemeta.c プロジェクト: hhirsch/netrek
static void refresh()
{
  W_WriteText(metaList, 0, metaHeight-B_REFRESH, W_Red,
              "Refresh (in progress)", -1, 0);
  W_NextScreenShot(metaWin, 0, 0);
  W_Flush();
  ReadMetasSend();
}
コード例 #12
0
ファイル: getname.c プロジェクト: timothyzillion/netrek
noautologin(void)
{
  autolog = 0;
  *defpasswd = *password1 = *password2 = '\0';
  alf = "Automatic login failed";
  W_WriteText(w, 100, 130, textColor, alf, strlen(alf),
        W_BoldFont);

}
コード例 #13
0
ファイル: findslot.c プロジェクト: timothyzillion/netrek
mapWaitWin(W_Window waitWin)
{
  char   *s;
  char    buf[60];

  sprintf(buf, "Game full at %s", serverName);
  s = buf;

  W_WriteText(waitWin, 15, 5, textColor, s, strlen(s), W_RegularFont);
}
コード例 #14
0
ファイル: parsemeta.c プロジェクト: hhirsch/netrek
static void expo_help()
{
  int i, h;
  h = (sizeof(metahelp_message)/sizeof(char *));
  for (i=0; i<h; i++) {
    char *line = metahelp_message[i];
    if (line == NULL) break;
    W_WriteText(metaHelpWin, 20, i * W_Textheight + 20, textColor, line, -1,
                W_RegularFont);
  }
}
コード例 #15
0
void    planetlist(void)
{
  register int i;
  register int k = 0;
  char    buf[BUFSIZ];
  register struct planet *j;

  /* W_ClearWindow(planetw); */
  (void) sprintf(buf, "Planet Name      own armies REPAIR FUEL AGRI CORE info");
  W_WriteText(planetw, 2, 1, textColor, buf, strlen(buf), W_RegularFont);
  k = 2;
  for (i = 0, j = &planets[i]; i < MAXPLANETS; i++, j++)
    {
      if (j->pl_info & me->p_team)
	{
	  (void) sprintf(buf, "%-16s %3s %3d    %6s %4s %4s %4s %c%c%c%c",
			 j->pl_name,
			 teamname[j->pl_owner],
			 j->pl_armies,
			 (j->pl_flags & PLREPAIR ? "REPAIR" : "      "),
			 (j->pl_flags & PLFUEL ? "FUEL" : "    "),
			 (j->pl_flags & PLAGRI ? "AGRI" : "    "),
			 (j->pl_flags & PLCORE ? "CORE" : "    "),
			 (j->pl_info & FED ? 'F' : ' '),
			 (j->pl_info & ROM ? 'R' : ' '),
			 (j->pl_info & KLI ? 'K' : ' '),
			 (j->pl_info & ORI ? 'O' : ' '));
	  W_WriteText(planetw, 2, k++, planetColor(j), buf, strlen(buf),
		      planetFont(j));
	}
      else
	{
	  (void) sprintf(buf, "%-16s",
			 j->pl_name);
	  W_WriteText(planetw, 2, k++, unColor, buf, strlen(buf),
		      W_RegularFont);
	}
    }
}
コード例 #16
0
static void
writeMessage(char *message, W_Color color, int len, int type)
{
    struct messageWin *j;

    /*printf("writeMessage: message = %s, len = %d\n",message,len);*/

    for (j = &messWin[0]; j < &messWin[WNUM]; j++) {
	if (!(j->flags & type))
	    continue;
	W_WriteText(j->window, 0, 0, color, message, len, 0);
    }
}
コード例 #17
0
/*
 * ATM: show the current values of the .sysdef parameters.
 */
void
showValues(W_Window win)
{
    int     i;
    struct list *data;

    /* try to find the start of the info */
    data = sysdefptr;

    for (i = 12; i < 50; i++) {
	if (data == NULL)
	    break;
	if (data->data[0] == '+')	/* quick boldface hack */
	    W_WriteText(win, 20, i * W_Textheight, textColor, data->data + 1,
			strlen(data->data) - 1, W_BoldFont);
	else
	    W_WriteText(win, 20, i * W_Textheight, textColor, data->data,
			strlen(data->data), W_RegularFont);
	data = data->next;
    }
    W_DisplayBuffer(win);
}
コード例 #18
0
ファイル: macrowin.c プロジェクト: timothyzillion/netrek
void
        filldist(int fill)
{
  register int i;
  register int row;
  register int c;
  int     num;
  char    key[3];

  lineno = 0;
  for (i = 1, row = 5; distmacro[i].macro != '\0'; i++)
    {
      if (fill)
  {
    if (distmacro[i].c < 128)
      sprintf(key, "%c\0", distmacro[i].c);
    else
      sprintf(key, "^%c\0", distmacro[i].c - 96);
    sprintf(maclines[0], "%-8s %s",
      key,
      distmacro[i].name);
    W_WriteText(macroWin, 2, row++, W_Yellow, maclines[0],
          strlen(maclines[0]), W_RegularFont);
  }
      lineno++;
      num = formatline(distmacro[i].macro);
      if (fill)
  {
    for (c = 0; c < num; c++)
      {
        W_WriteText(macroWin, 8, row++, textColor, maclines[c],
        strlen(maclines[c]), W_RegularFont);
      }
  }
      if (lineno > NUMLINES)
  continue;
    }
}
コード例 #19
0
ファイル: playerlist.c プロジェクト: quozl/netrek-server
/* generic player/planet update */
plstat()
{
    int i;
    char buf[100];

    switch (plmode) {
    case 0:
	W_ClearWindow(plstatw);
	(void) strcpy(buf, "# Type Login     Name               Kills Shields Damage Armies  Fuel Speed  WT");
	W_WriteText(plstatw, 0, 1, textColor, buf, strlen(buf), W_RegularFont);
	for (i=0; i<MAXPLAYER; i++) {
	    updatePlayer[i]=1;
	}
	break;
    case 1:
	W_ClearWindow(plstatw);
	(void) strcpy(buf, "# Type Rank      Name            Kills   Win  Loss  Ratio Offense Defense     DI");
	W_WriteText(plstatw, 0, 1, textColor, buf, strlen(buf), W_RegularFont);
	for (i=0; i<MAXPLAYER; i++) {
	    updatePlayer[i]=1;
	}
	break;
    case 2:
    case 3:
	/* planets */
	W_ClearWindow(plstatw);
	strcpy(buf, "Planet Name      own armies flags info   Planet Name      own armies flags info");
	W_WriteText(plstatw, 2, 1, textColor, buf, strlen(buf), W_RegularFont);
	for (i=0; i<MAXPLANETS; i++) {
	    updatePlanet[i]=1;
	}
	break;
    default:
	fprintf(stderr, "Internal error: bad plmode in plstat2\n");
    }

    plstat2();
}
コード例 #20
0
ファイル: sound.c プロジェクト: hhirsch/netrek
void soundwindow(void) {
#if defined(HAVE_SDL)
	char *buf="All or nothing with SDL sound. Sorry";
	W_WriteText(soundWin, 0, 0, textColor, buf, strlen(buf), 0);
#else
	int     i;

	for (i=0; i <= SOUND_DONE; i++)
		soundrefresh(i);
#endif

	/* Map window */
	W_MapWindow(soundWin);
}
コード例 #21
0
ファイル: option.c プロジェクト: timothyzillion/netrek
/* Refresh the option window given by the option struct */
optionrefresh(register struct option *op)
{
  register int on;
  char    buf[BUFSIZ];

  if (op == NULL || notdone == 0)
    return;

  if (op->op_string)
    {
      (void) sprintf(buf, op->op_text, op->op_string);
    }
  else if (op->op_array)
    {            /* Array of strings */
      strcpy(buf, op->op_array[*op->op_option]);
    }
  else if (op->op_range)
    {
      (void) sprintf(buf, op->op_text, *(op->op_option));
    }
  else
    {
      /* Either a boolean or a window */
      if (op->op_option)

#ifdef HAVE_XPM
  if (op->op_size)       /* Pixmap Bit Value */
    on = !(*op->op_option & op->op_size);
  else
#endif

    on = *op->op_option;       /* use int for status */
      else if (op->op_targetwin)
  on = W_IsMapped(*op->op_targetwin);  /* use window for status */
      else
  on = 1;          /* shouldn't happen */

      if (!on)
  strcpy(buf, "Don't ");
      else
  buf[0] = '\0';
      strcat(buf, op->op_text);
    }

  if (islower(buf[0]))
    buf[0] = toupper(buf[0]);

  W_WriteText(optionWin, 0, op->op_num, textColor, buf, strlen(buf), 0);
}
コード例 #22
0
ファイル: playerlist.c プロジェクト: quozl/netrek-server
playerlist0()
{
    register int i;
    char buf[100];
    register struct player *j;
    int		len;

    if (!W_IsMapped(plstatw)) return;
    for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
	if (!updatePlayer[i]) continue;
	updatePlayer[i]=0;
/*	if (j->p_status != PALIVE) {*/
	if (j->p_status == PFREE) {
	    W_ClearArea(plstatw, 0, i+2, 83, 1, backColor);
	    continue;
	}

      /* Since a) this is the most common player list shown, and b) sprintf is
	 very computationally expensive (i.e. 20% of total xsg time is 
	 spent in _doprnt) we do this like the client handles the stat bar --
	 brute force. */
	
	len = build_playerstats_buf(buf, j);
#ifdef nodef
	(void) sprintf(buf, "%c%c %s  %-9.9s %-16.16s %7.2f   %5d  %5d    %3d %5d    %2d %3d%c",
	    j->p_team == ALLTEAM?'A':teamlet[j->p_team],
	    shipnos[j->p_no],
	    (j->p_status == PALIVE) ? classes[j->p_ship.s_type] : 
	       statchars(j->p_status),
	    j->p_login,
	    j->p_name,
	    j->p_kills,
	    j->p_shield,
	    j->p_damage,
	    j->p_armies,
	    j->p_fuel,
	    j->p_speed,
	    j->p_wtemp/10,	/* TSH 3/10/93 (client shows div by 10)*/
	    (j->p_flags & PFWEP)?'W':' ');
	len = strlen(buf);
#endif
	W_WriteText(plstatw, 0, i+2, 
		/* TSH 2/10/93 */
		(me->p_flags & PFPLOCK && j->p_no == me->p_playerl)?
		  myColor: playerColor(j), buf, len,
	    shipFont(j));
    }
}
コード例 #23
0
ファイル: getname.c プロジェクト: timothyzillion/netrek
showreadme(void)
{
  static char *README[] =
  {
    "",
  };
  int     i, length;


  for (i = 0; i < SIZEOF(README); i++)
    {
      length = strlen(README[i]);

      W_WriteText(w, 20, i * W_Textheight + 180, textColor, README[i],
      length, W_RegularFont);
    }
}
コード例 #24
0
ファイル: stats.c プロジェクト: hhirsch/netrek
void    redrawStats(void)
{
  int     i;

  W_ClearWindow(statwin);
  initStats();
  for (i = 0; i < NUM_SLIDERS; i++)
    {
      sliders[i].lastVal = 0;
    }
  for (i = 0; i < NUM_SLIDERS; i++)
    {
      W_WriteText(statwin, TX_OFF(sliders[i].label_length), TY_OFF(i),
		  textColor, sliders[i].label, sliders[i].label_length,
		  W_RegularFont);
      box(0, BX_OFF() - 1, BY_OFF(i) - 1, SL_WID + 2, SL_HEI + 2, borderColor);
      sliders[i].lastVal = 0;
    }
}
コード例 #25
0
ファイル: getname.c プロジェクト: timothyzillion/netrek
checkpassword(void)
/* Check dude's password. If he is ok, move to state ST_DONE. */
{
  char   *s;

  sendLoginReq(tempname, password1, login, 0);
  loginAccept = -1;
  while (loginAccept == -1)
    {
      socketPause();
      readFromServer(NULL);
      if (isServerDead())
  {
    printf("Server is hosed.\n");

#ifdef AUTOKEY
    if (autoKey)
      W_AutoRepeatOn();
#endif

    terminate(0);
  }
    }
  if (loginAccept == 0)
    {
      if (!autolog)
  {
    s = "Bad password!";
    W_WriteText(w, 100, 100, textColor, s, strlen(s), W_BoldFont);
    (void) W_EventsPending();
    sleep(3);
    W_ClearWindow(w);
  }
      else
  noautologin();
      *tempname = 0;
      state = ST_GETNAME;
      return;
    }
  STRNCPY(me->p_name, tempname, sizeof(tempname));
  keeppeace = (me->p_stats.st_flags / ST_KEEPPEACE) & 1;
  state = ST_DONE;
}
コード例 #26
0
ファイル: spopt.c プロジェクト: timothyzillion/netrek
void    sprefresh(int i)
/*
 * Refresh button i in the Short Packed Window.
 *
 * Buttons are:
 * SPK_VFIELD           - Variable short packets.
 * SPK_MFIELD           - Messages.
 * SPK_KFIELD           - Kill Messages.
 * SPK_WFIELD           - Warn Messages.
 * SPK_TFIELD           - Recieve Threshold.
 * SPK_DONE             - Done.
 */
{
  char    buf[BUFSIZ];

  switch (i)
    {

    case SPK_VFIELD:
      sprintf(buf, "%seceive variable and short packets",
        recv_short ? "R" : "Don't r");
      break;
    case SPK_MFIELD:
      sprintf(buf, "%seceive messages", recv_mesg ? "R" : "Don't r");
      break;
    case SPK_KFIELD:
      sprintf(buf, "%seceive kill messages", recv_kmesg ? "R" : "Don't r");
      break;
    case SPK_WFIELD:
      sprintf(buf, "%seceive warning messages", recv_warn ? "R" : "Don't r");
      break;
    case SPK_TFIELD:
      sprintf(buf, "Receive threshold: %s_", recv_threshold_s);
      break;
    case SPK_DONE:
      sprintf(buf, "Done");
      break;
    }

  W_WriteText(spWin, 0, i, textColor, buf, strlen(buf), 0);
}
コード例 #27
0
ファイル: netstatopt.c プロジェクト: timothyzillion/netrek
/* Refresh item i */
nsrefresh(int i)
{
  double  ns_get_tstat(void), ns_get_lstat(void);
  char    buf[BUFSIZ], *ns_get_nfthresh_s(void);
  W_Color color;

  switch (i)
    {

    case NETSTAT_SWITCH:
      sprintf(buf, "%sollect network stats",
        netstat ? "C" : "Don't c");
      color = textColor;
      break;
    case NETSTAT_RESET:
      sprintf(buf, "Reset network stats");
      color = textColor;
      break;
    case NETSTAT_TOTAL:
      sprintf(buf, "Total              : %4.2f", ns_get_tstat());
      color = yColor;
      break;
    case NETSTAT_LOCAL:
      sprintf(buf, "This ship          : %4.2f", ns_get_lstat());
      color = yColor;
      break;
    case NETSTAT_FAILURES:
      sprintf(buf, "Network failures   : %d", ns_get_nfailures());
      color = yColor;
      break;
    case NETSTAT_NFTHRESH:
      sprintf(buf, "Network failure threshold: %s_", ns_get_nfthresh_s());
      color = textColor;
      break;
    case NETSTAT_DONE:
      sprintf(buf, "Done");
      color = textColor;
      break;
    }
  W_WriteText(netstatWin, 0, i, color, buf, strlen(buf), 0);
}
コード例 #28
0
/* I don't know if this works correctly or not.  It is ripped from BRM and has
   been modified a bit to fit.  Right now it doesn't do anything.  [BDyess] */
void
CheckFeatures(char *m)
{
    char    buf[BUFSIZ];
    char   *pek = &m[10];

    if ((int) strlen(m) < 11)
	return;

    while ((*pek == ' ') && (*pek != '\0'))
	pek++;

    strcpy(buf, "Paradise Client: ");

    if (!strcmp(pek, "NO_VIEW_BOX")) {
	allowViewBox = 0;
	strcat(buf, pek);
    }
    if (!strcmp(pek, "NO_CONTINUOUS_MOUSE")) {
	allowContinuousMouse = 0;
	strcat(buf, pek);
    }
    if (!strcmp(pek, "NO_SHOW_ALL_TRACTORS")) {
	allowShowAllTractorPressor = 0;
	strcat(buf, pek);
    }
    if (!strcmp(pek, "HIDE_PLAYERLIST_ON_ENTRY")) {
	allowPlayerlist = 0;
	strcat(buf, pek);
    }
    if (!strcmp(pek, "NO_NEWMACRO")) {
/*      UseNewMacro = 0;*/
	strcat(buf, pek);
    }
    if (!strcmp(pek, "NO_SMARTMACRO")) {
/*      UseSmartMacro = 0;*/
	strcat(buf, pek);
    }
    if (!strcmp(pek, "WHY_DEAD")) {
	why_dead = 1;
	strcat(buf, pek);
    }
    if (!strcmp(pek, "RC_DISTRESS")) {
        F_gen_distress = 1;
/*      distmacro = dist_prefered;*/
	strcat(buf, pek);
    }
    /* what the hell is this? - jmn */
    if (!strncmp(pek, "INFO", 4)) {
	strcat(buf, pek);
    }
    if (strlen(buf) == strlen("Paradise Client: ")) {
	strcat(buf, "UNKNOWN FEATURE: ");
	strcat(buf, pek);
    }
    buf[79] = '\0';

    printf("%s\n", buf);

    W_WriteText(messWin[WREVIEW].window, 0, 0, W_White, buf,(int)strlen(buf),0);
    W_WriteText(messWin[WALL].window, 0, 0, W_White, buf, (int)strlen(buf), 0);
}
コード例 #29
0
/* this function determines the color that the given message should be and
   then passes it to writeMessage [BDyess] */
void
print_message(char *message, unsigned int flags, unsigned int from, 
              unsigned int to)
{
    register int len;
    W_Color color;
    W_Window targwin;

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

    len = strlen(message);
    if (from == 254) {		/* client passing info around */
	switch (showPhaser) {
	case 0:
	    break;
	case 1:
	    writeMessage(message, textColor, len, WA_KILL | WA_REVIEW);
	    break;
	case 2:
	    writeMessage(message, textColor, len, WA_REVIEW | WA_PHASER);
	    break;
	case 3:
	    writeMessage(message, textColor, len, WA_REVIEW);
	    break;
	}
	return;
    }
    if (from == 255) {
	if (flags == MCONFIG + MINDIV + MVALID) {
	    CheckFeatures(message);
	    return;
	}
	/* From God */
	color = textColor;
    } else {
	/* kludge to fix the occasional incorrect color message */
	if (*message == ' ' && from != me->p_no) {
	    /* XXX fix to handle funky teams */
	    switch (*(message + 1)) {
	    case 'F':
		color = W_Yellow;
		break;
	    case 'R':
		color = W_Red;
		break;
	    case 'K':
		color = W_Green;
		break;
	    case 'O':
		color = W_Cyan;
		break;
	    case 'I':
		color = W_Grey;
		break;
	    default:
		color = playerColor(&(players[from]));
	    }
	} else
	    color = playerColor(&(players[from]));
    }

    /* added/modified to fit with the scrollback feature 1/94 -JR */
    if (!paradise && niftyNewMessages) {
	if (flags == conq) {
	    /* output conquer stuff to stdout in addition to message window */
	    fprintf(stdout, "%s\n", message);
	    if (strstr(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 == team) || (flags == take) || (flags == destroy)) {
	    writeMessage(message, color, len, WA_TEAM | WA_REVIEW);
	    targwin = messWin[WTEAM].window;
	} else if ((flags == kill) || (flags == killp) || (flags == killa) || (flags == bomb)) {
	    writeMessage(message, color, len, 
			 WA_KILL | (reportKills ? WA_REVIEW : 0));
	    targwin = messWin[WKILL].window;
	} else if (flags & MINDIV) {
	    writeMessage(message, color, len, (WA_INDIV | WA_REVIEW));
	    targwin = messWin[WINDIV].window;
	} else if (flags == (MMACRO | MALL)) {
	    writeMessage(message, color, len, (WA_MACRO | WA_REVIEW));
	    targwin = messWin[WALL].window;
	} else {
	    /*
	       if we don't know where the message belongs by this time, stick
	       it in the all board...
	    */
	    writeMessage(message, color, len, (WA_ALL | WA_REVIEW));
	    targwin = messWin[WALL].window;
	}
    } else {

	/*
	   Kludge stuff for report kills...
	*/
	if ((strncmp(message, "GOD->ALL", 8) == 0 &&
	     (strstr(message, "was kill") ||
	      strstr(message, "killed by"))) ||
	      strstr(message, "burned to a crisp by") ||
	      strstr(message, "shot down by") ||
	     (*message != ' ' && strstr(message, "We are being attacked"))) {

	    /* strip off the useless GOD->ALL by adding 9 to message [BDyess] */
	    message += 9;
	    writeMessage(message, color, len, 
			 WA_KILL | (reportKills ? WA_REVIEW : 0));

	    return;
	}
	/*
	   note: messages are kept track of even if the associated window is
	   not mapped.  This allows the window to be later mapped and have
	   all the past messages. [BDyess]
	*/
	if (flags & MTEAM) {
	    writeMessage(message, color, len, WA_TEAM | WA_REVIEW);
	    targwin = messWin[WTEAM].window;
	} else if (flags & MINDIV) {
	    writeMessage(message, color, len, WA_INDIV | WA_REVIEW);
	    targwin = messWin[WINDIV].window;
	} else if (flags == (MMACRO | MALL)) {
	    writeMessage(message, color, len, WA_MACRO | WA_REVIEW);
	    targwin = messWin[WALL].window;
	} else {
	    writeMessage(message, color, len, WA_ALL | WA_REVIEW);
	    targwin = messWin[WALL].window;
	}
    }
    /*
       send warnings to warning or message window, if player doesn't have
       messag es mapped
    */
    if ((use_msgw && (targwin == messWin[WINDIV].window || targwin == messWin[WTEAM].window)) ||
	(!W_IsMapped(targwin) && !W_IsMapped(messWin[WREVIEW].window))) {
	if (!messpend && messagew) {	/* don't collide with messages being
					   written! */
	    W_ClearWindow(messagew);
	    W_WriteText(messagew, 5, 5, color, message, len, W_RegularFont);
	} else
	    warning(message);
    }
}
コード例 #30
0
ファイル: getname.c プロジェクト: timothyzillion/netrek
getname(char *defname, char *defpasswd)

/* Let person identify themselves from w */
{
  register char ch;
  int     secondsLeft = 199, laststate;
  char    tempstr[40];
  LONG    lasttime;
  char   *namptr, *passptr;
  register int j;
  struct timeval timeout;
  fd_set  readfds;

  autolog = (*defpasswd && *defname) ? 1 : 0;

  MZERO(mystats, sizeof(struct stats));

  mystats->st_tticks = 1;
  for (j = 0; j < 95; j++)
    {
      mystats->st_keymap[j] = j + 32;
      mystats->st_keymap[j + 96] = j + 32 + 96;

#ifdef MOUSE_AS_SHIFT
      mystats->st_keymap[j + 192] = j + 32;
      mystats->st_keymap[j + 288] = j + 32;
      mystats->st_keymap[j + 384] = j + 32;
#endif
    }
  mystats->st_keymap[95] = 0;
  mystats->st_flags = ST_MAPMODE + ST_NAMEMODE + ST_SHOWSHIELDS +
      ST_KEEPPEACE + ST_SHOWLOCAL * 2 + ST_SHOWGLOBAL * 2;

  lasttime = time(NULL);

  if (ghoststart)
    return;

  tempname[0] = '\0';
  password1[0] = '\0';
  password2[0] = '\0';

  laststate = state = ST_GETNAME;
  displayStartup(defname);
  while (1)
    {
      handleWEvents(defname);

      if (!autolog)
  {

#ifndef HAVE_WIN32
    W_FullScreen(baseWin);
    timeout.tv_sec = 1;
    timeout.tv_usec = 0;
#else
    /* Since we don't have a socket to check on Win32 for windowing *
     * system events, we set the timeout to zero and effectively poll.
     * * Yes, I could do the correct thing and call *
     * WaitForMultipleObjects() etc. but I don't feel like it */
    timeout.tv_sec = 0;
    timeout.tv_usec = 100000;
#endif

    FD_ZERO(&readfds);
    FD_SET(sock, &readfds);
    if (udpSock >= 0)
      FD_SET(udpSock, &readfds);

#ifndef HAVE_WIN32
    FD_SET(W_Socket(), &readfds);
#endif

    if (SELECT(32, &readfds, 0, 0, &timeout) < 0)
      {
        perror("select");
        continue;
      }

    if (FD_ISSET(sock, &readfds)
        || (udpSock >= 0 && FD_ISSET(udpSock, &readfds)))
      readFromServer(&readfds);

#ifndef HAVE_WIN32
    if (FD_ISSET(W_Socket(), &readfds))
#else
    if (W_EventsPending())
#endif

      handleWEvents(defname);
  }
      else
  {
    readFromServer(&readfds);
  }

      if (isServerDead())
  {
    printf("Shit, we were ghostbusted\n");

#ifdef HAVE_XPM
    W_GalacticBgd(GHOST_PIX);
#endif

#ifdef AUTOKEY
    if (autoKey)
      W_AutoRepeatOn();
#endif

    terminate(0);
  }

      if (time(0) != lasttime)
  {
    lasttime++;
    secondsLeft--;
    showreadme();
    if (!autolog)
      {
        sprintf(tempstr, "Seconds to go: %d ", secondsLeft);
        W_WriteText(w, 100, 400, textColor, tempstr, strlen(tempstr),
        W_RegularFont);
      }
    if (secondsLeft == 0)
      {
        me->p_status = PFREE;
        printf("Timed Out.\n");

#ifdef AUTOKEY
        if (autoKey)
    W_AutoRepeatOn();
#endif

        terminate(0);
      }
  }
      if (state == ST_DONE)
  {
    W_ClearWindow(w);
    W_ClearWindow(mapw);
    return;
  }
      if (autolog)
  {
    switch (state)
      {
      case ST_GETNAME:
        tempname[0] = '\0';
        ch = 13;
        j = 0;
        break;

      case ST_GETPASS:
      case ST_MAKEPASS1:
      case ST_MAKEPASS2:
        ch = defpasswd[j++];
        if (ch == '\0')
    {
      j = 0;
      ch = 13;
    }
        break;

      default:
        break;
      }

    loginproced(ch, defname);

  }

      laststate = state;
    }
}