Ejemplo n.º 1
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);
}
Ejemplo n.º 2
0
void
waraction(W_Event *data)
{
    int     enemymask;

    if (data->y == 4) {
	W_UnmapWindow(war);
	sendWarReq(newhostile);
	return;
    }
    if (data->y == 5) {
	W_UnmapWindow(war);
	return;
    }
    enemymask = 1 << data->y;

    if (me->p_swar & enemymask) {
	warning("You are already at war!");
	W_Beep();
    } else {
	if (idx_to_mask(me->p_teami) == enemymask) {
	    warning("It would never work ... your crew would have you in the brig in no time.");
	} else {
	    newhostile ^= enemymask;
	}
    }
    warrefresh();
}
/* 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);
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
findslot(void)
{
  int     oldcount = -1;
  W_Window waitWin, qwin, countWin, motdButtonWin;

  W_Window motdWin;
  extern int MaxMotdLine;
  int     WaitMotdLine = 0;
  int     mapMotd = booleanDefault("showMotd", 1);
  W_Event event;


  /* Wait for some kind of indication about in/not in */
  while (queuePos == -1)
    {
      socketPause();
      if (isServerDead())
  {

#if defined(SOUND) && !defined(HAVE_SDL)
    Exit_Sound();
#endif

    printf("Shit!  Ghostbusted!\n");
    terminate(0);
  }
      readFromServer(NULL);
      if (me != NULL)
  {
    /* We are in! */
    ANNOUNCESOCKET;
    return (me->p_no);
  }
    }

  /* We have to wait.  Make appropriate windows, etc... */

  waitWin = W_MakeWindow("wait", 0, 0, WAITWIDTH, WAITHEIGHT, NULL, 2,
       foreColor);
  countWin = W_MakeWindow("count", WAITWIDTH / 3, WAITTITLE, WAITWIDTH / 3,
        WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor);
  qwin = W_MakeWindow("waitquit", 0, WAITTITLE, WAITWIDTH / 3,
          WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor);
  motdButtonWin = W_MakeWindow("motdbutton", 2 * WAITWIDTH / 3, WAITTITLE,
           WAITWIDTH / 3, WAITHEIGHT - WAITTITLE, waitWin,
             1, foreColor);
  W_MapWindow(waitWin);
  W_MapWindow(countWin);
  W_MapWindow(motdButtonWin);
  W_MapWindow(qwin);
  if (mapMotd)
    {
      motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1, TWINSIDE,
           TWINSIDE, 0, 2, foreColor);
      W_MapWindow(motdWin);
      showMotd(motdWin, WaitMotdLine);
    }

  for (;;)
    {
      socketPause();
      readFromServer(NULL);
      if (isServerDead())
  {

#if defined(SOUND) && !defined(HAVE_SDL)
    Exit_Sound();
#endif

    printf("Damn, We've been ghostbusted!\n");
    terminate(0);
  }
      while (W_EventsPending())
  {
    W_NextEvent(&event);
    switch ((int) event.type)
      {
      case W_EV_BUTTON:
      case W_EV_KEY:
        if (mapMotd && event.Window == motdWin)
    {
      if (event.key == ' ' || event.key == 'q')
        {
          W_DestroyWindow(motdWin);
          mapMotd = !mapMotd;
        }
      else
        {
          if (event.key == 'b')
      {
        WaitMotdLine -= 28;
        WaitMotdLine = MAX(WaitMotdLine, 0);
      }
          else
      {
        WaitMotdLine += 28;
        /* scroll to start if it goes over */
        if (WaitMotdLine > MaxMotdLine)
          WaitMotdLine = 0;
      }
          W_ClearWindow(motdWin);
          showMotd(motdWin, WaitMotdLine);
          break;
        }
    }
        else if (event.Window == motdButtonWin)
    {
      if (mapMotd)
        {
          W_DestroyWindow(motdWin);
        }
      else
        {
          motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1,
               TWINSIDE, TWINSIDE, 0, 2,
               foreColor);
          W_MapWindow(motdWin);
          showMotd(motdWin, WaitMotdLine);
        }
      mapMotd = !mapMotd;
    }
        else if (event.Window == qwin)
    {

#if defined(SOUND) && !defined(HAVE_SDL)
      Exit_Sound();
#endif

      printf("OK, bye!\n");
      terminate(0);
    }
        break;
      case W_EV_EXPOSE:
        if (event.Window == waitWin)
    {
      mapWaitWin(waitWin);
    }
        else if (event.Window == motdWin)
    {
      showMotd(motdWin, WaitMotdLine);
    }
        else if (event.Window == qwin)
    {
      mapWaitQuit(qwin);
    }
        else if (event.Window == countWin)
    {
      mapWaitCount(waitWin, countWin, queuePos);
    }
        else if (event.Window == motdButtonWin)
    {
      mapWaitMotdButton(motdButtonWin);
    }
        break;
      default:
        break;
      }
  }
      if (queuePos != oldcount)
  {
    mapWaitCount(waitWin, countWin, queuePos);
    oldcount = queuePos;
  }
      if (me != NULL)
  {
    W_DestroyWindow(waitWin);
    if (mapMotd)
      {
        W_DestroyWindow(motdWin);
      }
    ANNOUNCESOCKET;
    W_Beep();
    W_Beep();
    return (me->p_no);
  }
    }
}
static int
makelite(struct distress *dist, char *pm)
{
    struct player *sender;
    struct player *j;
    struct planet *l;
    char    c;
    W_Color lcol;

    sender = &players[dist->sender];

    if (!(*pm)) {
	return (0);
    }
    /* first step is to substitute variables */
    while (*pm) {
	if (*pm == '/') {
	    pm++;

	    if (!pm)
		continue;

	    if (F_beeplite_flags & LITE_COLOR) {
		/* color lite -JR */
		switch (toupper(*(pm + 1))) {
		case 'G':
		    lcol = W_Green;
		    break;
		case 'Y':
		    lcol = W_Yellow;
		    break;
		case 'R':
		    lcol = W_Red;
		    break;
		case 'C':
		    lcol = W_Cyan;
		    break;
		case 'E':
		    lcol = W_Grey;
		    break;
		case 'W':
		default:
		    lcol = W_White;
		    break;
		}
	    } else
		lcol = W_White;

	    switch (c = *(pm++)) {

	    case 'P':		/* push player id into buf */
	    case 'G':		/* push friendly player id into buf */
	    case 'H':		/* push enemy target player id into buf */

	    case 'p':		/* push player id into buf */
	    case 'g':		/* push friendly player id into buf */
	    case 'h':		/* push enemy target player id into buf */

		switch (c) {
		case 'p':
		    j = &players[dist->tclose_j];
		    break;
		case 'g':
		    j = &players[dist->tclose_fr];
		    break;
		case 'h':
		    j = &players[dist->tclose_en];
		    break;
		case 'P':
		    j = &players[dist->close_j];
		    break;
		case 'G':
		    j = &players[dist->close_fr];
		    break;
		default:
		    j = &players[dist->close_en];
		    break;
		}
		liteplayer(j, lcol);
		break;

	    case 'B':		/* highlites planet nearest sender */
	    case 'b':
		l = &planets[dist->close_pl];
		liteplanet(l, lcol);
		break;
	    case 'L':		/* highlites planet nearest pointer */
	    case 'l':
		l = &planets[dist->tclose_pl];
		liteplanet(l, lcol);
		break;
	    case 'U':		/* highlites enemy nearest pointer */
	    case 'u':
		j = &players[dist->tclose_en];
		liteplayer(j, lcol);
		break;
	    case 'c':		/* highlites sender */
	    case 'I':
	    case 'i':
		liteplayer(sender, lcol);
		break;
	    case 'M':		/* highlites me */
	    case 'm':
		liteplayer(me, lcol);
		break;
	    case '0':
		if (F_beeplite_flags & LITE_SOUNDS)
		    W_Beep();
		break;
	    default:
/* try to continue
** bad macro character is skipped entirely,
** the message will be parsed without whatever argument has occurred. - jn
*/
		warning("Bad Macro character in distress!");
		fprintf(stderr, "Unrecognizable special character in "
		                "distress pass 1: %c\n", *(pm - 1));
		break;
	    }
	} else {
	    pm++;
	}

    }


    return (1);
}