Пример #1
0
showMacroWin(void)
{
  int     num = macrocnt + 5;

  if (!macroWin)
    {
      if (maclevel == 0)
  {
    lineno = 0;
    filldist(0);
    num = lineno + 5;
  }

      /* we'll use GWINSIDE since it is (probably) less than or equal to *
       * TWINSIDE.  The smaller the better. */
      macroWin = W_MakeTextWindow("macrow", GWINSIDE + BORDER, BORDER,
          80, num, NULL, BORDER);

      W_ResizeTextWindow(macroWin, 80, num);
      W_DefineTrekCursor(macroWin);
      W_SetWindowExposeHandler(macroWin, fillmacro);
      W_SetWindowButtonHandler(macroWin, switchmacros);
      W_MapWindow(macroWin);
    }
  else if (W_IsMapped(macroWin))
    W_UnmapWindow(macroWin);
  else
    W_MapWindow(macroWin);
}
Пример #2
0
static void toggle_help()
{
  if (W_IsMapped(metaHelpWin)) {
    hide_help();
  } else {
    show_help();
  }
}
Пример #3
0
void    metainput(void)
/* Wait for actions in the meta-server window.
 *
 * This is really the meta-server window's own little input() function. It is
 * needed so we don't have to use all the bull in the main input(). Plus to
 * use it I'd have to call mapAll() first and the client would read in the
 * default server and then call it up before I can select a server. */
{
  W_Event data;

  (void) SIGNAL(SIGCHLD, sigchld);
  while (W_IsMapped(metaWin)) {
    while (1) {
      W_Flush();
      if (W_EventsPending()) break;
      if (ReadMetasRecv(W_Socket()) || metareap_needed) {
        metareap();
        metaHeight = num_servers + N_OVERHEAD;
        metawindow();
        W_Flush();
      }
      refresh_cyclic();
    }
    W_NextEvent(&data);
    switch ((int) data.type) {
    case W_EV_KEY:
      if (data.Window == metaList || data.Window == metaWin)
        if (key(&data)) return;
      if (data.Window == metaHelpWin) hide_help();
      break;
    case W_EV_BUTTON:
      if (data.Window == metaList)
        if (button(&data)) return;
      if (data.Window == metaHelpWin) hide_help();
      if (data.Window == metaWin && data.y < 200)
        W_NextScreenShot(metaWin, 0, 0);
      break;
    case W_EV_EXPOSE:
      if (data.Window == metaHelpWin) expo_help();
      if (data.Window == metaWin) {
        W_DrawScreenShot(metaWin, 0, 0);
        W_DrawImage(200, 9, logo);
      }
      break;
    case W_EV_CLOSED:
      if (data.Window == metaWin) {
        fprintf(stderr, "you quit, by closing the server list window\n");
        terminate(0);
      }
      break;
    default:
      break;
    }
  }
}
Пример #4
0
/* 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);
}
Пример #5
0
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));
    }
}
/* handles the mouse and keyboard events that happen in one of the message
   windows.  For key events, if the event is within the team or all window then
   it will automatically start the message for you, with destination to the
   player's team or ALL, respectively.  If it's a button event, it will scroll
   the message window back, forward, or to start (left, right, and middle
   button respectively).  It beeps if there is no messages to scroll (ie at
   the top or bottom already). [BDyess] 12/07/93 */
void
messageWinEvent(W_Event *evt)
{
    W_Window window = evt->Window;
    int     key = evt->key;

    if (!W_IsMapped(window))
	return;

    if (evt->type == W_EV_KEY) {
	if (key == ('e' + 128)) {	/* erase window [BDyess] */
	    W_ClearWindow(window);
	} else if (window == messWin[WALL].window) {
	    smessage_ahead('A', key);
	} else if (window == messWin[WTEAM].window) {
	    smessage_ahead('T', key);
	} else {
	    smessage(key);
	}
    }
}
Пример #7
0
/* deal with events sent to the option window */
void    optionaction(W_Event * data)
{
  register struct option *op;
  int     i;
  register char *cp;

  if (data->y >= CurrentMenu->numopt)
    {
      W_Beep();
      return;
    }
  if (notdone == 0)
    return;

  op = &(CurrentMenu->menu[data->y]);

  /* Update string; don't claim keystrokes for non-string options */
  /* deal with options with string input first */
  if (op->op_string == 0)
    {
      if (data->type == W_EV_KEY)
  return;
    }
  else
    {
      if (data->type == W_EV_BUTTON)
  return;
      switch (data->key)
  {

  case '\b':         /* delete character */
  case '\177':
    cp = op->op_string;
    i = strlen(cp);
    if (i > 0)
      {
        cp += i - 1;
        *cp = '\0';
      }
    break;

  case '\027':         /* word erase */
    cp = op->op_string;
    i = strlen(cp);
    /* back up over blanks */
    while (--i >= 0 && isspace(cp[i]))
      ;
    i++;
    /* back up over non-blanks */
    while (--i >= 0 && !isspace(cp[i]))
      ;
    i++;
    cp[i] = '\0';
    break;

  case '\025':         /* kill line */
  case '\030':
    op->op_string[0] = '\0';
    break;

  default:         /* add character to the list
              *
              */
    if (data->key < 32 || data->key > 127)
      break;
    cp = op->op_string;
    i = strlen(cp);
    if (i < (op->op_size - 1) && !iscntrl(data->key))
      {
        cp += i;
        cp[1] = '\0';
        cp[0] = data->key;
      }
    else
      W_Beep();
    break;
  }
    }

  /* Toggle int, if it exists */
  if (op->op_array)
    {
      if (data->key == W_RBUTTON)
  {
    (*op->op_option)++;
    if (*(op->op_array)[*op->op_option] == '\0')
      {
        *op->op_option = 0;
      }
  }
      else if (data->key == W_MBUTTON)
  {
    /* set option number to zero on the middle key to ease shutoff */
    *op->op_option = 0;
  }
      else if (data->key == W_LBUTTON)
  {
    /* if left button, decrease option  */
    (*op->op_option)--;
    /* if decreased too far, set to top option */
    if (*(op->op_option) < 0)
      {
        *op->op_option = 0;
        while (*(op->op_array)[*op->op_option] != '\0')
    {
      (*op->op_option)++;
    }
        (*op->op_option)--;
      }
  }


      /* Actions to be taken when certain options are selected. (Yes, this is
       * * * a hack). */

      if (op->op_option == &plistStyle)
  {
    if (plistCustomLayout == 0 && plistStyle == 0)
      plistStyle = (data->key == W_LBUTTON) ? PLISTLASTSTYLE : 1;

    RedrawPlayerList();
  }
      else if (op->op_option == &showgalactic)
  {
    redrawall = 1;
  }

#ifdef ROTATERACE
      else if (rotate != old_rotate)
  {
    register i;
    register struct planet *l;
    register struct player *j;

    redrawall = 1;
    reinitPlanets = 1;

    for (i = 0, l = planets; i < MAXPLANETS; i++, l++)
      {
        if (rotate)
    {
      rotate_deg = -old_rotate_deg + rotate * 64;
      rotate_coord(&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2, GWIDTH / 2);
      rotate_deg = rotate * 64;
    }
        else
    {
      rotate_deg = -old_rotate_deg;
      rotate_coord(&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2, GWIDTH / 2);
      rotate_deg = 0;
    }
      }

    /* we could wait for the server to do this but looks better if we *
     *
     * * do it now. */
    for (i = 0, j = players; i < MAXPLAYER; i++, j++)
      {
        if (j->p_status != PALIVE)
    continue;
        if (rotate)
    {
      rotate_deg = -old_rotate_deg + rotate * 64;
      rotate_coord(&j->p_x, &j->p_y, rotate_deg,
             GWIDTH / 2, GWIDTH / 2);
      rotate_dir(&j->p_dir, rotate_deg);

      rotate_deg = rotate * 64;
    }
        else
    {
      rotate_deg = -old_rotate_deg;
      rotate_coord(&j->p_x, &j->p_y, rotate_deg,
             GWIDTH / 2, GWIDTH / 2);
      rotate_dir(&j->p_dir, rotate_deg);
      rotate_deg = 0;
    }
      }
    /* phasers/torps/etc .. wait for server */

    old_rotate = rotate;
    old_rotate_deg = rotate_deg;
  }
#endif

    }


  /* Does the button have a range of values? */

  else if (op->op_range)
    {
      if (data->key == W_RBUTTON)
  {
    (*op->op_option) += op->op_range->increment;
  }
      else if (data->key == W_MBUTTON)
  {
    (*op->op_option) = op->op_range->min_value;
  }
      else if (data->key == W_LBUTTON)
  {
    (*op->op_option) -= op->op_range->increment;
  }
      /* wrap value around within option range */
      if (*(op->op_option) > op->op_range->max_value)
  *(op->op_option) = op->op_range->min_value;
      if (*(op->op_option) < op->op_range->min_value)
  *(op->op_option) = op->op_range->max_value;
    }


  /* Is the option a toggle? */

#ifdef HAVE_XPM
  /* Bitwise Toggle  */

  else if ((op->op_option) && (op->op_size))
    {
      if (!(pixMissing & op->op_size))
  {
    *op->op_option ^= op->op_size;

    if (op->op_size & (NO_MAP_PIX | NO_BG_PIX | NO_HALOS))
      redrawall = 1;
  }
    }
#endif

  else if (op->op_option)
    {
      *op->op_option = !*op->op_option;

      /* Actions to be taken when certain options are selected. * (Yes, this
       * * is a hack). */

      if (op->op_option == &showPlanetOwner)
  redrawall = 1;
      else if (op->op_option == &partitionPlist)
  RedrawPlayerList();
      else if (op->op_option == &sortPlayers)
  RedrawPlayerList();
      else if (op->op_option == &sortMyTeamFirst)
  RedrawPlayerList();
    }

  /* Map/unmap window, if it exists */

  if (op->op_targetwin)
    {
      if (W_IsMapped(*op->op_targetwin))
  W_UnmapWindow(*op->op_targetwin);
      else
  {
    W_MapWindow(*op->op_targetwin);

    if (*op->op_targetwin == udpWin)
      udpwindow();
    if (*op->op_targetwin == pStats)
      redrawPStats();
    if (*op->op_targetwin == netstatWin)
      nswindow();
    if (*op->op_targetwin == spWin)
      spwindow();

#ifdef XTREKRC_HELP
    if (defWin && *op->op_targetwin == defWin)
      showdef();
#endif

#ifdef SOUND
    if (*op->op_targetwin == soundWin)
      soundwindow();
#endif

#ifdef DOC_WIN
    if (docwin && *op->op_targetwin == docwin)
      showdocs(0);

    if (xtrekrcwin && *op->op_targetwin == xtrekrcwin)
      showxtrekrc(0);
#endif
  }
    }

  /* deal with possible menu change */
  if (MenuPage != CurrentMenu->page_num)
    {
      SetMenuPage(MenuPage);
      RefreshOptions();
    }
  else if (notdone)
    optionrefresh(op);
  else
    {
      optionrefresh(op);
      optiondone();
    }

  return;
}
Пример #8
0
void
showMotd(W_Window win)
{
    int     i;
    struct list *data;
    int     count;
    int     headernum;

    newMotdStuff = 0;		/* clear the flag */

    if (currpage == NULL)
	currpage = motddata;
    if (currpage == NULL)
	return;
    if (!W_IsMapped(win))
	return;

    headernum = currpage->page % NRHEADERS;
    W_ClearWindow(win);
    if(xpm) 
      W_DrawImageNoClip(win, 0, 0, 0, getImage(I_HEADER), 0);
    else 
    {
      W_Image *headerA, *headerB, *header1;
      headerA = getImage(I_HEADERA);
      headerB = getImage(I_HEADERB);
      header1 = getImage(I_HEADER1);
      W_DrawImageNoClip(win, 0, 0, 0, headerA, foreColor);
      W_DrawImageNoClip(win, headerA->width, 0, 0, 
                        headerB, foreColor);
      W_DrawImageNoClip(win, headerA->width, 
                       headerB->height,
		       0,
		       getImage(I_HEADER1 + headernum),
		       foreColor);
      if (headernum == 2) {	/* fill in client: */
	  /* note: font dependant */
      } else if (headernum == 3) {/* fill in server: */
	  ;
      }
    }
    if (currpage->first) {
	currpage->first = 0;
	data = currpage->text;
	while (data != NULL) {
	    data->bold = checkBold(data->data);
	    data = data->next;
	}
    }
    data = currpage->text;
    count = LINESPERPAGE;	/* Magical # of lines to display */
    i = getImage(I_HEADERA)->height / (paradise ? 10 : W_Textheight) + 1;
    while (count > 0) {
	if (data == NULL)
	    break;

	if (data->bold) {
	    W_WriteText(win, 20, i * (paradise ? 10 : W_Textheight), textColor, data->data,
			strlen(data->data), W_BoldFont);
	} else {
	    W_WriteText(win, 20, i * (paradise ? 10 : W_Textheight), textColor, data->data,
			strlen(data->data), W_RegularFont);
	}
	data = data->next;
	count--;
	i++;
    }
    if (win == w) {
	count = (int)W_StringWidth(blk_refitstring, W_RegularFont) / 2;
	W_WriteText(mapw, 250 - count, 480, textColor, blk_refitstring,
		    strlen(blk_refitstring), W_RegularFont);
    }
    showPics(win);
/*    showValues(mapw); Should be handled in event loop now RF */

    /* keep the warning visible [BDyess] */
    if(hudwarning && warncount) {
      W_MaskText(w, center - (warncount / 2) * W_Textwidth, HUD_Y, W_Green,
                  warningbuf, warncount, W_RegularFont);
    }
    /* flush buffer if one exists [BDyess] */
    if(W_IsBuffered(win)) W_DisplayBuffer(win);	
}
Пример #9
0
void
get_N_dispatch_outfit_event(int *team, int *s_type, int *lastplayercount)
{
    W_Event event;
    int     validshipletter = 0;
    static int resetting = 0;
    int     oldresetting;
    int     i;

    oldresetting = resetting;

    W_NextEvent(&event);
    switch ((int) event.type) {
    case W_EV_KEY:
	{
	    struct shiplist *shipscan;
	    validshipletter = 0;
	    shipscan = shiptypes;
	    while (shipscan) {
		if (shipscan->ship->s_letter == event.key) {
		    *s_type = shipscan->ship->s_type;
		    validshipletter = 1;
		    break;
		}
		shipscan = shipscan->next;
	    }
	}

	if (me->p_status == PTQUEUE) {
	    for (i = 0; i < WNUM; i++) {
		if (event.Window == messWin[i].window) {
		    messageWinEvent(&event);
		    break;
		}
	    }
	    if (i != WNUM)
		break;
	    if (event.Window == messagew ||
		event.Window == tstatw ||
		event.Window == warnw)
		smessage(event.key);
	}
	if (event.Window == motdWin) {
	    motdWinEvent(&event);
	    break;
	} else if (event.Window == playerw || event.Window == infow) {
	    /* allow 'i' 'I' and '^i' in playerw [BDyess] */
	    playerwEvent(&event);
	    break;
	} else if (event.Window == w || event.Window == mapw) {
	    switch (event.key) {
#ifdef Q_OUTFITTING
	    case 'q':
		*team = number_of_teams;
		me->p_status = PFREE;
		break;
#endif				/* Q_OUTFITTING */
	    case 'R':
		warning("Are you sure you want to reset your stats?");
		resetting = 1;
		break;
	    case 'y':
		if (resetting) {
		    sendResetStatsReq('Y');
		    warning("OK, your stats have been reset.");
		    resetting = 0;
		}
		break;
	    case 'n':
		if (resetting) {
		    warning("I didn't think so.");
		    resetting = 0;
		}
		break;

	    case 'f':		/* Scroll motd forward */
		if (currpage == NULL)
		    currpage = motddata;
		if (currpage == NULL || currpage->next == NULL)
		    break;
		currpage->next->prev = currpage;
		currpage = currpage->next;
		showMotd(w);
		resetting = 0;
		break;
	    case 'b':		/* Scroll motd backward */
		if (currpage == NULL || currpage->prev == NULL)
		    break;
		currpage = currpage->prev;
		showMotd(w);
		resetting = 0;
		break;
		/* ok, let's have some info windows available on the TQ */

	    default:		/* hmm, something that doesn't have to do
				   with the MOTD, maybe it's an info window
				   request */
		switch (doKeymap(&event)) {
		case 'U':	/* U = Rank list */
		    if (W_IsMapped(rankw)) {
			W_UnmapWindow(rankw);
		    } else {
			W_MapWindow(rankw);
		    }
		    break;
		case 'P':	/* P = Planet list */
		    if (W_IsMapped(planetw)) {
			W_UnmapWindow(planetw);
			W_UnmapWindow(planetw2);
		    } else {
			W_MapWindow(planetw);
			W_MapWindow(planetw2);
		    }
		    break;
		case 'h':	/* h = Map help window */
		    if (W_IsMapped(helpWin)) {
			W_UnmapWindow(helpWin);
		    } else {
			W_MapWindow(helpWin);
		    }
		    if (optionWin)
			optionredrawtarget(helpWin);
		    break;
		case 'O':	/* O = options Window */
		    if (optionWin != NULL && W_IsMapped(optionWin))
			optiondone();
		    else
			optionwindow();
		    break;
		case 'w':	/* w = map war stuff */
		    if (W_IsMapped(war))
			W_UnmapWindow(war);
		    else
			warwindow();
		    break;
		case '&':
		    if (defaultsFile) {
			char    buf[150];
			sprintf(buf, "Reading defaults from %s", defaultsFile);
			warning(buf);
			freeDefaults();
			defaultsFile = initDefaults(defaultsFile);
			resetDefaults();
		    } else {
			warning("No defaults file to read from!");
		    }
		}
		break;
	    }

	    break;		/* switch event type */
	}
	if (event.Window == qwin)
	    return;		/* normal keypresses can't make you quit */

	if (event.Window == optionWin) {
	    optionaction(&event);
	    return;
	}
	if (!validshipletter)
	    break;
	/*
	   it wasn't the main window, see if they hit the key in a team
	   window to choose their ship... falling through
	*/
    case W_EV_BUTTON:

	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		*team = i;
		break;
	    }
	if (event.Window == qwin) {
	    *team = number_of_teams;
	    me->p_status = PFREE;
	    break;
	}
	/* allow message scrollback [BDyess] */
	for (i = 0; i < WNUM; i++) {
	    if (event.Window == messWin[i].window) {
		messageWinEvent(&event);
		break;
	    }
	}
	/* allow bozo selection in playerw [BDyess] */
	if (event.Window == playerw) {
	    playerwEvent(&event);
	    break;
	} else if (event.Window == war)
	    waraction(&event);
	else if (event.Window == optionWin)
	    optionaction(&event);
	else if (event.Window == motdWin)
	    motdWinEvent(&event);
	else if (event.Window == w) {
	    W_Window tmp = motdWin;
	    motdWin = w;
	    motdWinEvent(&event);
	    motdWin = tmp;
	}
	if (*team != -1 && !teamRequest(*team, *s_type)) {
	    *team = -1;
	}
	break;
    case W_EV_EXPOSE:
	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		lastplayercount[i] = -1;	/* force update */
		redrawTeam(teamWin[i], i, &lastplayercount[i]);
		break;
	    }
	if (event.Window == qwin)
	    redrawQuit();
	else if (event.Window == w)
	    showMotd(w);
	else if (event.Window == mapw) {
		showValues(mapw);
	    redraw_death_messages();
	} else
	    /* let the normal expose handler figure out who to redraw */
	    dispatch_W_expose_event(&event);
	break;
    case W_EV_KILL_WINDOW:	/* WM_DESTROY_WINDOW support [BDyess] */
        if(event.Window == baseWin) exit(0);
	else W_UnmapWindow(event.Window);
	break;
    }

    if (oldresetting && resetting) {
	resetting = 0;
	warning("Resetting of stats cancelled");
    }
}
Пример #10
0
redraw(void)
{
  /* erase warning line if necessary */
  if ((warntimer <= udcounter) && (warncount > 0))
    {
      /* XFIX */
      W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight);
      warncount = 0;
    }

  run_clock(lastread);         /* for hosers who don't know
              * * * what a Xclock is */
  clearLocal();

#ifdef BEEPLITE
  if (tts_timer)
    {
      static int last_width;

      tts_timer--;
      if (!tts_timer)
  {
    /* timed out */
    W_EraseTTSText(w, TWINSIDE, tts_pos, last_width);
    last_width = 0;
  }
      else if (tts_timer == tts_time - 1 && last_width)
  {
    /* first draw -- erase previous */
    W_EraseTTSText(w, TWINSIDE, tts_pos, last_width);
    /* draw new */
    W_WriteTTSText(w, TWINSIDE, tts_pos, tts_width, lastIn,
       tts_len);
    last_width = tts_width;
  }
      else
  {
    /* regular draw */
    W_WriteTTSText(w, TWINSIDE, tts_pos, tts_width, lastIn, tts_len);
    last_width = tts_width;
  }
    }
#endif

  local();           /* redraw local window */

  /* XFIX */
  W_FlushLineCaches(w);

  if (newDashboard)        /* 6/2/93 LAB */
    if (newDashboard == old_db)
      db_redraw(0);
    else
      redrawTstats();
  else if (newDashboard == old_db)
    stline(0);
  else
    redrawTstats();

  old_db = newDashboard;

  if (W_IsMapped(statwin))
    updateStats();

  /* XFIX: last since its least accurate information */
  map();
}
Пример #11
0
showdocs(int atline)
{
  FILE   *fptr;
  int     i, length, top, center;
  struct list *data;
  int     count;
  char    buf[128];
  W_Font  font;

  if (!docwin)
    docwin = W_MakeWindow("DocWin", 0, 181, 500, 500, 0, 2,
        foreColor);

  W_ClearWindow(docwin);

  if (!W_IsMapped(docwin))
    W_MapWindow(docwin);

  sprintf(buf, "---  %s  ---", (char *) query_cowid());
  length = strlen(buf);

  /* using GWINSIDE instead of TWINSIDE because with SMALL_SCREEN defined it
   * * makes more sense to use the smaller width in the interest of saving *
   * screen real estate */
  center = GWINSIDE / 2 - (length * W_Textwidth) / 2;
  W_WriteText(docwin, center, W_Textheight, textColor,
        buf, length, W_BoldFont);
  sprintf(buf, cbugs);
  length = strlen(buf);
  center = GWINSIDE / 2 - (length * W_Textwidth) / 2;
  W_WriteText(docwin, center, 3 * W_Textheight, textColor,
        buf, length, W_RegularFont);

  if (!docdata)
    loaddocs();

  top = 10;

  if (atline > maxdoclines)
    atline = maxdoclines - 28;

  data = docdata;

  for (i = 0; i < atline; i++)
    {
      if (data == NULL)
  {
    atline = 0;
    data = docdata;
    break;
  }
      data = data->next;
    }

  count = 28;          /* Magical # of lines to * *
              * display */

  for (i = top; i < 50; i++)
    {
      if (data == NULL)
  break;

      if (data->data == NULL)
  continue;

      switch (data->face)
  {
  case BOLD:
    font = W_BoldFont;
    break;
  case ITALIC:
    font = W_UnderlineFont;
    break;
  case NORMAL:
    font = W_RegularFont;
    break;
  }


      W_WriteText(docwin, 20, i * W_Textheight, textColor, data->data,
      strlen(data->data), font);
      data = data->next;
      count--;

      if (count <= 0)
  break;
    }
}
Пример #12
0
showxtrekrc(int atline)
{
  FILE   *fptr;
  int     i, length, top, center;
  struct list *data;
  int     count;
  char    buf[128];
  W_Font  font;

  if (!xtrekrcwin)
    xtrekrcwin = W_MakeWindow("xtrekrcWin", 0, 200, 500, 500, 0, 2,
            foreColor);

  W_ClearWindow(xtrekrcwin);

  if (!W_IsMapped(xtrekrcwin))
    W_MapWindow(xtrekrcwin);

  sprintf(buf, "---  %s  ---", (char *) query_cowid());
  length = strlen(buf);
  center = GWINSIDE / 2 - (length * W_Textwidth) / 2;
  W_WriteText(xtrekrcwin, center, W_Textheight, textColor,
        buf, length, W_BoldFont);
  sprintf(buf, cbugs);
  length = strlen(buf);
  center = GWINSIDE / 2 - (length * W_Textwidth) / 2;
  W_WriteText(xtrekrcwin, center, 3 * W_Textheight, textColor,
        buf, length, W_RegularFont);

  if (!xtrekrcdata)
    loadxtrekrc();

  top = 10;

  if (atline > maxxtrekrclines)
    atline = maxxtrekrclines - 28;

  data = xtrekrcdata;

  for (i = 0; i < atline; i++)
    {
      if (data == NULL)
  {
    atline = 0;
    data = xtrekrcdata;
    break;
  }
      data = data->next;
    }

  count = 28;          /* Magical # of lines to * *
              * display */

  for (i = top; i < 50; i++)
    {
      if (data == NULL)
  break;

      if (data->data == NULL)
  continue;

      switch (data->face)
  {
  case BOLD:
    font = W_BoldFont;
    break;
  case ITALIC:
    font = W_UnderlineFont;
    break;
  case NORMAL:
    font = W_RegularFont;
    break;
  }


      W_WriteText(xtrekrcwin, 20, i * W_Textheight, textColor, data->data,
      strlen(data->data), font);
      data = data->next;
      count--;

      if (count <= 0)
  break;
    }
}
Пример #13
0
int
main(int argc, char **argv)
{
    int     team, s_type;
    char   *dpyname = NULL;
    int     usage = 0;
    int     err = 0;
    char   *name, *ptr, *cp;
    struct passwd *pwent;
    int     passive = 0;
    int     xpmopt = 1;
    int     useORopt = 0;
    int     useCookieOpt = 0;
    int     dontUseCookieOpt = 0;
/*    char *defaultsFile=NULL;*/

    pseudo[0] = defpasswd[0] = '\0';

    name = *argv++;
    argc--;
    if ((ptr = strrchr(name, '/')) != NULL)
	name = ptr + 1;
    while (*argv) {
	if (**argv != '-') {
	    serverName = *argv;	/* don't abort argument processing */
	    argv++;
	    argc--;
	} else {
	    ++*argv;

	    argc--;
	    ptr = *argv++;
	    while (*ptr) {
		switch (*ptr) {
		case 'C':	/* character name */
		    (void) strncpy(pseudo, *argv, sizeof(pseudo));
		    argv++;
		    argc--;
		    break;

		case 'P':	/* authorization password */
		    (void) strncpy(defpasswd, *argv, sizeof(defpasswd));
		    {
			int     i;
			for (i = 0; (*argv)[i]; i++)
			    (*argv)[i] = 0;
		    }
		    argv++;
		    argc--;
		    break;

		case 'u':
		    usage++;
		    break;
		case 's':
		    if (*argv) {
			xtrekPort = atoi(*argv);
			passive = 1;
			argv++;
			argc--;
		    }
		    break;
		case 'p':
		    if (*argv) {
			xtrekPort = atoi(*argv);
			argv++;
			argc--;
		    }
		    break;
		case 'd':
		    dpyname = *argv;
		    argc--;
		    argv++;
		    break;
		case 'm':
		    usemeta = 1;
		    break;
		case 'h':
		    serverName = *argv;
		    argc--;
		    argv++;
		    break;

		case 't':
		    title = *argv;
		    argc--;
		    argv++;
		    break;
		case 'r':
		    defaultsFile = *argv;
		    argv++;
		    argc--;
		    break;
#ifdef AUTHORIZE
		case 'o':
		    RSA_Client = -1;
		    break;
		case 'R':
		    RSA_Client = -2;
		    break;
#else
		case 'o':
		case 'R':
		    printf("This client does not have binary authorization.\n");
		    break;
#endif
		case 'e':
#ifdef AUTHORIZE
		    checkExpire(1);
#else
		    printf("This client does not RSA verify and will not expire.\n");
#endif
		    exit(0);
		    break;
		case 'f':	/* list ftp sites */
		    fprintf(stderr, "\n\
The newest version of the Paradise client can be found at:\n\
      ftp.netrek.org  in /pub/netrek/paradise/bin/\n");
		    exit(0);
		case 'G':
		    if (*argv) {
			ghoststart++;
			ghost_pno = atoi(*argv);
			printf("Emergency restart being attempted...\n");
			argv++;
			argc--;
		    }
		    break;
		case '2':	/* force paradise */
		    paradise = 1;
		    break;
		case 'F':	/* File playback */
		    if (*argv) {
			playFile = strdup(*argv);
			playback = 1;
			argv++;
			argc--;
		    }
		    break;
		case 'x':
		    xpmopt = 0;
		    break;
		case 'k':		/* cookie mode [BDyess] */
		    useCookieOpt = 1;
		    break;
		case 'K':		/* no-cookies :( [BDyess] */
		    dontUseCookieOpt = 1;
		    break;
		case 'v':
		    verbose_image_loading = 1;
		    break;
		case 'O':		/* turn on GXor image drawing [BDyess]*/
		    useORopt = 1;	
		    break;
                case 'c': 	/* dump .paradiserc defaults [BDyess] */
		    dump_defaults = 1;
		    break;
		default:
		    fprintf(stderr, "%s: unknown option '%c'\n", name, *ptr);
		    err++;
		    break;
		}
		ptr++;
	    }
	}
    }

    inittrigtables();

    initStars();		/* moved from redraw.c at KAO\'s suggestion */

    if (usage || err) {
	printUsage(name);
#ifdef AUTHORIZE
	checkExpire(1);
#endif
	exit(0);
	/* exit(err); Exits from checkExpire */
    }
    defaultsFile = initDefaults(defaultsFile);

    if(xpmopt) xpm = 1;
    else xpm = booleanDefault("xpm",xpm);
    if(xpm) printf("XPM mode enabled.\n");
    /* command line option overrides .paradiserc value [BDyess] */
    if(useORopt) useOR = 1;
    else useOR = booleanDefault("useOR",useOR);
    if(useOR) printf("OR mode enabled.\n");
    if(useOR || !xpm) cookie = 0;	/* default no-cookies unless in XPM
    					   mode w/out OR [BDyess] */
					/* note: need a milk mode :) */
    if(useCookieOpt) cookie = 1;
    else if(dontUseCookieOpt) cookie = 0;
    else cookie = booleanDefault("cookie",cookie);
    if(cookie) printf("Cookie mode enabled.\n");

#ifdef AUTHORIZE
    if (RSA_Client != -1)
	checkExpire(0);
#endif

    /* compatability */
    if (argc > 0)
	serverName = argv[0];

    srandom(getpid() + time((long *) 0));

    if(playback || booleanDefault("playback",0)) {
        defNickName = "playback";
	usemeta=0;
        serverName = "playback";
    } else
    {
        if (serverName) {
	    char    temp[80], *s;
	    sprintf(temp, "server.%s", serverName);
	    if ((s = stringDefault(temp,NULL))) {
		printf("Using nickname \"%s\" for server %s\n", serverName, s);
		defNickName = serverName;
		serverName = s;
		defFlavor = stringDefault("flavor",NULL);
	    }
	}
	if (!serverName) {
	    serverName = stringDefault("server",NULL);
        }
	if (!serverName && !passive) {
	    serverName = DEFAULT_SERVER;
	    usemeta = 1;		/* no server specified, show the menu */
	}
	if (passive)
	    serverName = "passive";	/* newwin gets a wrong title otherwise */

	if (xtrekPort < 0)
	    xtrekPort = intDefault("port", -1);
	if (xtrekPort < 0)
	    xtrekPort = DEFAULT_PORT;
    } /* playback */
    build_default_configuration();

    metaserverAddress = stringDefault("metaserver",
				      "metaserver.netrek.org");
    if (usemeta)
	openmeta();

    W_Initialize(dpyname);

    metaFork = booleanDefault("metaFork", metaFork);
    /* do the metawindow thang */
    if (usemeta) {
	metawindow();
	metainput();
	if (metaFork)
	    W_Initialize(dpyname);
	newwin(dpyname, name);
    } else

	/* this creates the necessary x windows for the game */
	newwin(dpyname, name);

    /* open memory...? */
    openmem();
    if (!startPlayback())
    {
	if (!passive) {
	    serverName = callServer(xtrekPort, serverName);
	} else {
	    connectToServer(xtrekPort);
	}
    }
    sendFeature("FEATURE_PACKETS", 'S', 1, 0, 0);

    timeStart = time(NULL);
    findslot();

    /* sets all the settings from defaults file (.xtrekrc probably) */
    resetDefaults();

#ifdef UNIX_SOUND
    init_sound();
    play_sound(SND_PARADISE);
#endif

    mapAll();
/*    signal(SIGINT, SIG_IGN);*/
    signal(SIGCHLD, reaper);

    /* Get login name */
    if ((pwent = getpwuid(getuid())) != NULL)
	(void) strncpy(login, pwent->pw_name, sizeof(login));
    else
	(void) strncpy(login, "Bozo", sizeof(login));
    login[sizeof(login) - 1] = '\0';

    if (pseudo[0] == '\0') {
	char *freeme;
	strncpy(pseudo, freeme = stringDefault("name",login), sizeof(pseudo));
	free(freeme);
    }
    pseudo[sizeof(pseudo) - 1] = '\0';

    if (defpasswd[0] == '\0') {
	char buf[100];  /* added password by character name -JR */
	sprintf(buf,"password.%s",pseudo);
	if((cp = stringDefault(buf,NULL)) || (cp = stringDefault("password",NULL)))
	    (void) strncpy(defpasswd, cp, sizeof(defpasswd));
    }
    defpasswd[sizeof(defpasswd) - 1] = '\0';

    /*
       sendLoginReq("Gray Lensman", "hh", "sfd", 0); loginAccept = -1; while
       (loginAccept == -1) { socketPause(1,0); readFromServer(); }
    */
    getname(pseudo, defpasswd);
    loggedIn = 1;

    /*
       Set p_hostile to hostile, so if keeppeace is on, the guy starts off
       hating everyone (like a good fighter should)
    */
    me->p_hostile = (1 << number_of_teams) - 1;

    redrawTstats();

    me->p_planets = 0;
    me->p_genoplanets = 0;
    me->p_armsbomb = 0;
    me->p_genoarmsbomb = 0;
    /* Set up a reasonable default */
    me->p_whydead = KNOREASON;
    me->p_teami = -1;
    s_type = defaultShip(CRUISER);	/* from rlb7h 11/15/91 TC */

    if (booleanDefault("netStats", 1))
	startPing();		/* tell the server that we support pings */

    /*
       hack to make galaxy class ships work.  This could be more elegant, but
       the configuration code would have to be modified quite a bit, since
       the client doesn't know if it's on a paradise server until after it
       connects, and it needs the configuration info before it connects.
    */
    init_galaxy_class();

    initkeymap(-1);		/* needs to have ship types initialized -JR */

    setjmp(env);		/* Reentry point of game */

    if (ghoststart) {
	int     i;

	ghoststart = 0;

	for (i = -1; i < 5; i++)
	    if (teaminfo[i].letter == me->p_mapchars[0])
		break;

	me->p_teami = i;

	if (me->p_damage > me->p_ship->s_maxdamage) {
	    me->p_status = POUTFIT;
	} else
	    me->p_status = PALIVE;
    } else
	me->p_status = POUTFIT;

    while (1) {
	switch (me->p_status) {
	case POUTFIT:
	case PTQUEUE:
	    /* give the player the motd and find out which team he wants */
	    new_entrywindow(&team, &s_type);
	    allowPlayerlist = 1;
	    if (W_IsMapped(playerw))
		playerlist();

	    if (!playback)
		if (team == -1) {
		    W_DestroyWindow(w);
		    sendByeReq();
		    sleep(1);
		    printf("OK, bye!\n");
		    EXIT(0);
		}
	    sendVersion();
	    myship = getship(myship->s_type);

	    currentship = myship->s_type;

	    /*
	       sendOptionsPacket(); this would totally blast any flags you
	       had on the server
	    */

	    redrawall = 1;
	    enter();
	    calibrate_stats();
	    W_ClearWindow(w);
	    /*
	       for (i = 0; i < NSIG; i++) { signal(i, SIG_IGN); }
	    */

	    me->p_status = PALIVE;	/* Put player in game */

#ifdef UNIX_SOUND
            kill_sound ();
#endif
            
	    hockeyInit();

	    if (showStats)	/* Default showstats are on. */
		W_MapWindow(statwin);
	    if (showNewStats)	/* default showNewStats are off. [BDyess] */
	        W_MapWindow(newstatwin);

	    if (tryUdp && commMode != COMM_UDP) {
		sendUdpReq(COMM_UDP);
	    }

	    if (tryShort) {
		sendShortReq(SPK_VON);
		tryShort = 0;	/* only try it once */
	    }
	    /* Send request for a full update */
	    if (askforUpdate) {
		if(recv_short)
		    sendShortReq(SPK_SALL);
		else
		    sendUdpReq(COMM_UPDATE);
	    }
	    sendUpdatePacket(1000000 / updateSpeed);

	    W_Deiconify(baseWin);

	    break;
	case PALIVE:
	case PEXPLODE:
	case PDEAD:
	case POBSERVE:

	    /* Get input until the player quits or dies */
	    input();
	    W_ClearWindow(mapw);
	    break;
	default:
	    printf("client has p_status=%d.  how strange\n", me->p_status);
	    me->p_status = POUTFIT;
	}
    }

    /* NOTREACHED */
}
Пример #14
0
redraw()
{
    /* erase warning line if necessary */
    if ((warntimer <= udcounter) && (warncount > 0)) {
	W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight, backColor);
	warncount = 0;
    }

    if (W_FastClear) {
	W_ClearWindow(w);
	clearcount=0;
	clearlcount=0;
    } else {
	/* TSH 2/10/93 */
	while (clearcount) {
	    clearcount--;
	    W_CacheClearArea(w, clearzone[0][clearcount], 
		clearzone[1][clearcount],
		clearzone[2][clearcount], clearzone[3][clearcount]);
	}
	while (clearlcount) {
	    clearlcount--;
	    W_CacheLine(w, clearline[0][clearlcount], clearline[1][clearlcount],
		clearline[2][clearlcount], clearline[3][clearlcount],
		backColor);
	}
	W_FlushClearAreaCache(w);
	W_FlushLineCaches(w);

	while (mclearlcount){
	    mclearlcount--;
	    W_CacheLine(mapw, mclearline[0][mclearlcount], 
		mclearline[1][mclearlcount], mclearline[2][mclearlcount], 
		mclearline[3][mclearlcount],
		backColor);
	}
	while (mclearpcount){
	    mclearpcount--;
	    W_CachePoint(mapw, mclearpoint[0][mclearpcount], 
		mclearpoint[1][mclearpcount], backColor);
	}
	W_FlushLineCaches(mapw);
	W_FlushPointCaches(mapw);
    }

    local();	/* redraw local window */

    if (mapmode) map();

    if (W_IsMapped(statwin)){
	updateStats();
    }

    /* need a status line but we'll make do with the bottom of the local
       display for now */
    if(runclock)
       run_clock(1);	/* isae */
    if(record)
      show_record(1);
    if(playback)
      show_playback(1);

    if(playback && extracting)
       show_extracting(extracting); /* 7/27/93 BM */

    /* W_Flush(); */
}
/* 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);
    }
}
Пример #16
0
void
new_entrywindow(int *team, int *s_type)
{
    int     i;
    int     lastplayercount[4];	/* number of players on each team */
    int     okayMask, lastOkayMask;	/* teams you're allowed to choose */
    char    buf[100];

    /* OUTFIT timeout stuff */
    long    startTime = -1;
    long    lasttime = -1;
    int     spareTime = 0;

    if (fastQuit) {
	*team = -1;
	return;
    }
    lastOkayMask = okayMask = tournMask;

    /* erase packet lights to make Bob happy [BDyess] */
    light_erase();

    /*
       map all team selection windows, and stripe out those that are
       unchoosable
    */
    for (i = 0; i < number_of_teams; i++) {
	W_MapWindow(teamWin[i]);
	lastplayercount[i] = -1;
    }
    W_MapWindow(qwin);

    /* no team selected yet */
    *team = -1;
    /*
       set to team index (0..n-1) to choose a team. set to n if you want to
       quit
    */

    /* I don't know why this restriction is in place - RF */
    if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE) {
	showMotd(w);
	W_ClearWindow(mapw);
	showValues(mapw);
	redraw_death_messages();
    }
    do {

	/* set team to n if you want to quit */
	while (!W_EventsPending() && (me->p_status == POUTFIT ||
				      me->p_status == PTQUEUE)) {
	    /* no window events, just process socket stuff */
	    fd_set  mask;

	    light_erase();

	    readFromServer();

	    if (me->p_status == POUTFIT || me->p_status == PTQUEUE) {
		/* wait up to a half-second for input from the window system */
		struct timeval tv;

		tv.tv_sec = 0;
		tv.tv_usec = 500000;

		FD_ZERO(&mask);
		FD_SET(W_Socket(), &mask);
		select(W_Socket() + 1, &mask, 0, 0, &tv);
	    }

#if SHOW_MAP_AT_MOTD_DATA_ITEM_IMPLEMENTED
	    if(showMapAtMotd) {
		map();
	    }
#endif
	    redraw_death_messages();

	    if (me->p_status == PTQUEUE)
		startTime = -1;

	    if (me->p_status == POUTFIT) {
		/* time only elapses in OUTFIT mode */

		if (startTime == -1) {	/* we were on the tqueue */
		    /* I hate this [BDyess] */
		    W_Deiconify(baseWin);	/* we changed status.  alert
						   the user */
		    startTime = time(0);
		    spareTime = 480;	/* Allow them extra time, as long */
		    /* as they are active */
		}
		elapsed = time(0) - startTime;

		if (elapsed > autoQuit) {
		    printf("Auto-Quit.\n");
		    *team = number_of_teams;
		    break;
		}
	    }
	    if (lasttime != time(0)) {
		if (W_IsMapped(playerw))
		    playerlist2();

		if (newMotdStuff) {
		    showMotd(w);
			showValues(mapw);
		    redraw_death_messages();
		}
		if (me->p_status == POUTFIT) {
		    showTimeLeft(elapsed, autoQuit);
		}
		lasttime = time(0);
	    }
	    okayMask = tournMask;

	    /* redraw those windows whose choosable status has changed */
	    for (i = 0; i < number_of_teams; i++) {
		if ((okayMask ^ lastOkayMask) & (1 << i)) {
		    lastplayercount[i] = -1;	/* force update */
		}
		redrawTeam(teamWin[i], i, &lastplayercount[i]);
	    }
	    lastOkayMask = okayMask;
	}

	if (playback)  /* silly.  Shouldn't even be mapping team windows. */
	    break;
	/* they quit or ran out of time */
	if (*team == number_of_teams) {
	    me->p_status = PFREE;	/* exit outer while loop */
	    break;
	}
	/*
	   this makes them eventually run out of time no matter how awake
	   they are.  Only affects the OUTFIT screen.
	*/
	if (me->p_status == POUTFIT && startTime != -1) {
	    if (time(0) - startTime <= spareTime) {
		spareTime -= time(0) - startTime;
		startTime = time(0);
	    } else {
		startTime += spareTime;
		spareTime = 0;
	    }
	}
	if (!W_EventsPending())
	    continue;

	/* ok, there's a window event pending */

	/* thiswill set p_status to PFREE if they decide to quit */
	get_N_dispatch_outfit_event(team, s_type, lastplayercount);

    } while ((me->p_status == POUTFIT ||
	      me->p_status == PTQUEUE)
	     && (!pb_update)
	);

    if (*team >= 0) {
	strcpy(buf, "Welcome aboard ");
	if (paradise)
	    strcat(buf, ranks2[me->p_stats2.st_rank].name);
	else
	    strcat(buf, ranks[me->p_stats.st_rank].name);
	sprintf(buf, "Welcome aboard %s!", get_players_rank_name(me));
	warning(buf);
    }
    if (playback) {
	extern int lastTeamReq;
	*team = me->p_teami = lastTeamReq;
    } else
	/* if they quit or ran out of time */
    if (me->p_status == PFREE)
	*team = -1;
    else if (me->p_status == PALIVE ||
	     me->p_status == POBSERVE)
	if (*team == -1)
	    *team = me->p_teami;
	else
	    me->p_teami = *team;


    for (i = 0; i < number_of_teams; i++)
	W_UnmapWindow(teamWin[i]);
    W_UnmapWindow(qwin);
}
Пример #17
0
void
redraw(void)
{

    /* erase warning line if necessary */
    if ((warntimer <= udcounter && hwarncount <= udcounter) &&
        (warncount || hwarncount)) {
      W_ClearWindow(warnw);
    }
    if (warntimer <= udcounter && warncount) {
       W_MaskText(w, center - (warncount / 2) * W_Textwidth, 
                  winside - W_Textheight - HUD_Y, backColor, warningbuf, 
		  warncount, W_RegularFont);
       warncount = 0;
    }
    if (hwarntimer <= udcounter && hwarncount) {
       W_MaskText(w, center - (hwarncount / 2) * W_Textwidth, HUD_Y, 
                  backColor, hwarningbuf, hwarncount, W_BoldFont);
       hwarncount = 0;
    }

    if(W_IsBuffered(w)) {   /* buffered, clear the entire buffer [BDyess] */
      W_ClearBuffer(w);
      clearcount = 0;
      clearlcount = 0;
      tractcurrent = tracthead;
    } else
    {
      if (W_FastClear) {
	  W_ClearWindow(w);
	  clearcount = 0;
	  clearlcount = 0;
	  tractcurrent = tracthead;
      } else {
	  while (clearcount) {
	      clearcount--;
	      /* XFIX */
	      W_CacheClearArea(w, clearzone[clearcount].x,
			 clearzone[clearcount].y, clearzone[clearcount].width,
			       clearzone[clearcount].height);
	  }
	  while (clearlcount) {
	      clearlcount--;
	      /* XFIX */
	      W_CacheLine(w, clearline[0][clearlcount],
			  clearline[1][clearlcount], clearline[2][clearlcount],
			  clearline[3][clearlcount], backColor);
	  }
	  /* XFIX */
	  W_FlushClearAreaCache(w);
	  W_FlushLineCaches(w);
	  /* erase the tractor lines [BDyess] */
	  for (tractrunner = tracthead; tractrunner != tractcurrent;
	       tractrunner = tractrunner->next) {
	      W_MakeTractLine(w, tractrunner->sx, tractrunner->sy,
			      tractrunner->d1x, tractrunner->d1y,
			      backColor);
	      W_MakeTractLine(w, tractrunner->sx, tractrunner->sy,
			      tractrunner->d2x, tractrunner->d2y,
			      backColor);
	  }
	  tractcurrent = tracthead;
      }
    }

    local();			/* redraw local window */

    /* XFIX */
    W_FlushLineCaches(w);

    stline(0);			/* draw dashboard [BDyess] */

    /* flush buffers [BDyess] */
    W_DisplayBuffer(tstatw);	/* dashboard [BDyess] */
    W_DisplayBuffer(w);		/* local [BDyess] */

				/* would do it in W_EventsPending, just have
				   it here so the display is updated sooner. */
    W_Flush();

    if (W_IsMapped(statwin)) {
	updateStats();
    }
    if (W_IsMapped(newstatwin)) {
	updateNewStats();
    }

    updateInform();		/* check and update info window [BDyess] */

    /* XFIX: last since its least accurate information */
    if (mapmode) {
      map();
      /* write the buffered data, if any [BDyess] */
      W_DisplayBuffer(mapw);
    }
}
Пример #18
0
playerlist1()
{
    register int i;
    char buf[100];
    register struct player *j;
    int kills, losses;
    double ratio;
    float pRating, oRating, dRating, bRating;

    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;
	}
#ifndef LTD_STATS
	if (j->p_ship.s_type == STARBASE) {
	    kills=j->p_stats.st_sbkills;
	    losses=j->p_stats.st_sblosses;
	} else {
	    kills=j->p_stats.st_kills + j->p_stats.st_tkills;
	    losses=j->p_stats.st_losses + j->p_stats.st_tlosses;
	}
	if (losses==0) {
	    ratio=kills;
	} else {
	    ratio=(double) kills/losses;
	}
	oRating = offenseRating(j);
	dRating = defenseRating(j);
	pRating = planetRating(j);
	bRating = bombingRating(j);
#else /* LTD_STATS */
	kills = 0;
	losses = 0;
	ratio = 0;
	oRating = 0;
	dRating = 0;
	pRating = 0;
	bRating = 0;
#endif /* LTD_STATS */
	(void) sprintf(buf, "%c%c %s  %-9.9s %-16.16s%5.2f %5d %5d %6.2lf   %5.2f   %5.2f %8.2f",
	    teamlet[j->p_team],
	    shipnos[j->p_no],
	    (j->p_status == PALIVE) ? classes[j->p_ship.s_type] : 
	       statchars(j->p_status),
	    ranks[j->p_stats.st_rank].name,
	    j->p_name,
	    j->p_kills,
	    kills,
	    losses,
	    ratio,
	    oRating,
	    dRating,
#ifndef LTD_STATS
	    (oRating+pRating+bRating)*(j->p_stats.st_tticks/36000.0));
#else /* LTD_STATS */
	    0.0);
#endif /* LTD_STATS */
	W_WriteText(plstatw, 0, i+2, 
		/* TSH 2/10/93 */
		(me->p_flags & PFPLOCK && j->p_no == me->p_playerl)?
		myColor: playerColor(j), buf, strlen(buf),
	    shipFont(j));
    }
}