Exemple #1
0
void BoardGame::drawHover(QPixmap *hover, QPainter *painter, const int player)
{
	drawBackground(hover, painter);
	painter->setPen(NoPen);
	painter->setBrush(QBrush(playerColor(player), Dense4Pattern));
	paintPoint(painter, hover->rect(), player);
}
Exemple #2
0
void BoardGame::drawPoint(QPixmap *cache, QPainter *painter, const QPoint& point, const int player)
{
	if (player == -1)
		return;
	painter->setPen(NoPen);
	painter->setBrush(QBrush(playerColor(player)));
	paintPoint(painter, pointRect(cache->size(), point), player);
}
Exemple #3
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));
    }
}
void
doShields(int dx, int dy, W_Image *ship_bits, struct player *j)
{
    if (showShields && (j->p_flags & PFSHIELD)) {
	/*-----------Colored shields by shield damage--------*/

	int     color = playerColor(j);
	if (show_shield_dam && j == me) {
	    float   ft;

	    ft = (float) j->p_shield / (float) j->p_ship->s_maxshield;
	    if (ft > 0.66)
		color = gColor;
	    else if (ft > 0.33)
		color = yColor;
	    else if (j->p_shield > 5)
		color = rColor;
	    else
		color = unColor;
	}
	W_DrawShield(w, dx, dy, ship_bits->width, color);
    }
}
/* 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);
    }
}
Exemple #6
0
dmessage(char *message, unsigned char flags, unsigned char from, unsigned char to)
{
  register int len;
  W_Color color;
  char    timebuf[10];
  LONG    curtime;
  struct tm *tm;
  char    buf[80];
  int     take, destroy, team, kill, killp, killa, bomb, conq;
  struct distress dist;

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

  time(&curtime);
  tm = localtime(&curtime);
  sprintf(timebuf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
  len = strlen(message);
  if (from == 255)
    {
      /* From God */
      color = textColor;
    }
  else
    {
      color = playerColor(&(players[from]));
    }
  if (censorMessages)
    if ((flags != kill) && (flags != killp) &&
  (flags != killa) && (flags != bomb) &&
  (flags != take) && (flags != destroy))
      censor(message);

  /* aha! A new type distress/macro call came in. parse it appropriately */
  if (flags == (MTEAM | MDISTR | MVALID))
    {
      HandleGenDistr(message, from, to, &dist);
      len = makedistress(&dist, message, distmacro[dist.distype].macro);

#ifdef BEEPLITE
      if (UseLite)
  rcdlite(&dist);
#endif

      if (len <= 0)
  return;
      flags ^= MDISTR;
    }


  if (niftyNewMessages)
    {
      if (logmess)
  {
    if (logFile != NULL)
      {
        fprintf(logFile, "%s: %s\n", timebuf, message);
        fflush(logFile);
      }
    else
      {
        printf("%s: %s\n", timebuf, message);
      }
  }
      if (!(logmess && logFile == NULL) && flags == conq)
  {
    /* output conquer stuff to stdout in addition to message window */
    fprintf(stdout, "%s\n", message);
    if (instr(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 == (MCONFIG + MINDIV + MVALID))
  {
    if (from == 255)
      CheckFeatures(message);
    return;
  }
      if ((flags == team) || (flags == take) || (flags == destroy))
  {
    W_WriteText(messwt, 0, 0, color, message, len, shipFont(me));
    if ((flags == team) &&
        !strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        printf("dmessage:flags==team PIG call from=%d\n", from);
        pmessage(cowid, from, MINDIV);
      }
  }

      else if ((flags == kill) || (flags == killp) ||
         (flags == killa) || (flags == bomb))
  {
    W_WriteText(messwk, 0, 0, color, message, len, 0);
    if (!reportKills)
      return;        /* HW */
  }

      else if (flags & MINDIV)
  {
    W_WriteText(messwi, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        printf("dmessage:MINDIV PIG call from=%d\n", from);
        pmessage(cowid, from, MINDIV);
      }
  }
      else
  {          /* if we don't know where *
              * * the message beLONGs by
              * * * this time, stick it
              * in * * the all board... */
    W_WriteText(messwa, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
  }
      W_WriteText(reviewWin, 0, 0, color, message, len, 0);

    }
  else
    {

      /* ok, here we have the old kludge nastiness that we can turn on if we
       * * * HAVE to.  yuk, blech, ptooie... */

      if ((strncmp(message, "GOD->ALL", 8) == 0 &&
     (instr(message, "was kill") ||
      instr(message, "killed by"))) ||
    (*message != ' ' && instr(message, "We are being attacked")))
  {
    W_WriteText(messwk, 0, 0, color, message, len, 0);
    if (!reportKills)
      return;
    W_WriteText(reviewWin, 0, 0, color, message, len, 0);
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    return;
  }
      switch (flags & (MTEAM | MINDIV | MALL))
  {
  case MTEAM:
    W_WriteText(messwt, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  case MINDIV:
    if (!(flags & MCONFIG))
      W_WriteText(messwi, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s ", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  default:
    W_WriteText(messwa, 0, 0, color, message, len, 0);
    if (!strncmp(message + 10, "     ", 5) && (message[15] == 0))
      {
        pmessage(cowid, from, MINDIV);
      }
    if (logmess)
      {
        if (logFile != NULL)
    {
      fprintf(logFile, "%s ", timebuf);
      fprintf(logFile, "%s\n", message);
      fflush(logFile);
    }
        else
    {
      printf("%s", message);
      printf("%s\n", timebuf);
    }
      }
    break;
  }
      W_WriteText(reviewWin, 0, 0, color, message, len, 0);
    }
}
Exemple #7
0
static void DrawShips(void)
{
  register struct player *j;
  register struct phaser *php;

  char    idbuf[10];
  const int view = SCALE * TWINSIDE / 2;
  int     dx, dy, px, py, wx, wy, tx, ty, lx, ly;

#ifndef DYNAMIC_BITMAPS
  W_Icon(*ship_bits)[VIEWS];
#endif



  /* Kludge to try to fix missing ID chars on tactical (short range) display.
   *
   */

  idbuf[0] = '0';
  idbuf[1] = '\0';

  for (j = players + MAXPLAYER - 1; j >= players; --j)
    {

#ifdef HAVE_XPM
      void   *sprite = S_Ship(j->p_no);

#else

      if ((j->p_status != PALIVE) && (j->p_status != PEXPLODE))
  continue;

      if (j->p_flags & PFOBSERV)
  {
    /* observer and NOT locked onto a player (ie. locked onto planet or
     * * * vacuum) */

    if (!(j->p_flags & PFPLOCK))
      continue;

    /* observer and NOT cloaked - don't display ship but do tractors *
     * * phasers and torps are done for that ship already */

    if (!(j->p_flags & PFCLOAK))
      continue;
  }
#endif /* HAVE_XPM */

      /* jmn - observer support.. tried to diplay tractors but no works */

      if (j->p_flags & PFCLOAK)
  {
    if (j->p_cloakphase < (CLOAK_PHASES - 1))
      {

#ifdef SOUND
        if (myPlayer(j) && (j->p_cloakphase == 0)) {
#if defined(HAVE_SDL)
    Play_Sound(CLOAKED_WAV);
#else
    Play_Sound(CLOAK_SOUND);
#endif
        }
#endif

        j->p_cloakphase++;
      }
  }
      else
  {
    if (j->p_cloakphase)
      {

#ifdef SOUND
        if (myPlayer(j))
    if (j->p_cloakphase == CLOAK_PHASES - 1) {
#if defined(HAVE_SDL)
      Play_Sound(UNCLOAK_WAV);
#else
      Play_Sound(UNCLOAK_SOUND);
    } else {
      Abort_Sound(CLOAK_SOUND);
#endif
    }
#endif

        j->p_cloakphase--;
      }
  }
      dx = j->p_x - me->p_x;
      dy = j->p_y - me->p_y;

#ifdef HAVE_XPM
      if ((sprite == NULL) && (dx > view || dx < -view || dy > view || dy < -view))
#else
      if (dx > view || dx < -view || dy > view || dy < -view)
#endif

  continue;

      dx = dx / SCALE + TWINSIDE / 2;
      dy = dy / SCALE + TWINSIDE / 2;


#ifdef HAVE_XPM
      if ((sprite == NULL) || (pixFlags & NO_CLK_PIX))
#endif

  if (j->p_flags & PFCLOAK && (j->p_cloakphase == (CLOAK_PHASES - 1)))
    {
      if (myPlayer(j)

#ifdef RECORDGAME
    || playback
#endif

    )
        {
    W_WriteBitmap(dx - (cloak_width / 2), dy - (cloak_height / 2),
            cloakicon, myColor);

#ifdef VARY_HULL
    clearzone[0][clearcount] = dx - (shield_width / 2 + 1);
    clearzone[1][clearcount] = dy - (shield_height / 2 + 1);
    clearzone[2][clearcount] = shield_width + 3;
    clearzone[3][clearcount] = shield_height + 3;
    clearcount++;
#else
    clearzone[0][clearcount] = dx - (shield_width / 2);
    clearzone[1][clearcount] = dy - (shield_height / 2);
    clearzone[2][clearcount] = shield_width;
    clearzone[3][clearcount] = shield_height;
    clearcount++;
#endif

    goto shieldlabel;    /* draw the shield even when
              * * * cloaked */
        }
      continue;
    }
      if (j->p_status == PALIVE)
  {

#ifndef DYNAMIC_BITMAPS
    switch (j->p_team)
      {
      case FED:

#ifdef TNG_FED_BITMAPS
        if (use_tng_fed_bitmaps)
    ship_bits = tng_fed_bitmaps;
        else
#endif

    ship_bits = fed_bitmaps;
        break;
      case ROM:
        ship_bits = rom_bitmaps;
        break;
      case KLI:
        ship_bits = kli_bitmaps;
        break;
      case ORI:
        ship_bits = ori_bitmaps;
        break;
      default:
        ship_bits = ind_bitmaps;
        break;
      }
#endif

#if defined (VARY_HULL) || defined (BEEPLITE)
    clearzone[0][clearcount] = dx - (shield_width / 2 + 6);
    clearzone[1][clearcount] = dy - (shield_height / 2 + 6);
    clearzone[2][clearcount] = shield_width + 12;
    clearzone[3][clearcount] = shield_height + 12;
    clearcount++;
#else
    clearzone[0][clearcount] = dx - (shield_width / 2);
    clearzone[1][clearcount] = dy - (shield_height / 2);
    clearzone[2][clearcount] = shield_width;
    clearzone[3][clearcount] = shield_height;
    clearcount++;
#endif

#ifdef HAVE_XPM
    if (sprite != NULL)
      {
        clearsize = W_DrawSprite(sprite, dx, dy, TWINSIDE);

#if defined (VARY_HULL)
        if (clearsize > shield_width + 12)
#else
        if (clearsize > shield_width)
#endif

    {
      clearcount--;
      clearzone[0][clearcount] = dx - (clearsize / 2);
      clearzone[1][clearcount] = dy - (clearsize / 2);
      clearzone[2][clearcount] = clearsize;
      clearzone[3][clearcount] = clearsize;
      clearcount++;
    }
      }
    else
#endif /* HAVE_XPM */

      if (j->p_team == ROM && j->p_ship.s_type == CRUISER &&
    ROMVLVS)
      W_WriteBitmap(dx - (j->p_ship.s_width / 2),
      dy - (j->p_ship.s_height / 2), ROMVLVS_bitmap[rosette(j->p_dir)],
        playerColor(j));
    else
      W_WriteBitmap(dx - (j->p_ship.s_width / 2),
        dy - (j->p_ship.s_height / 2),

#ifndef DYNAMIC_BITMAPS
        ship_bits[j->p_ship.s_type][rosette(j->p_dir)],
#else
        ship_bitmaps[PlayerBitmap(j)][rosette(j->p_dir)],
#endif

        playerColor(j));

    if (j->p_cloakphase > 0)
      {

#ifdef HAVE_XPM
        if (sprite == NULL)
#endif

    W_WriteBitmap(dx - (cloak_width / 2),
      dy - (cloak_height / 2), cloakicon, playerColor(j));
      if (!myPlayer(j))      /* if myplayer draw the shield */
        continue;
      }

  shieldlabel:

#ifdef BEEPLITE
    if ((UseLite && emph_player_seq_n[j->p_no] > 0)
        && (liteflag & LITE_PLAYERS_LOCAL))
      {
        int     seq_n = emph_player_seq_n[j->p_no] % emph_player_seql_frames;

        W_WriteBitmap(dx - (emph_player_seql_width / 2),
          dy - (emph_player_seql_height / 2),
          emph_player_seql[seq_n],
          W_White);
      }
#endif

#ifdef VARY_HULL
    if (j == me && vary_hull)
      {
        int     hull_left = (100 * (me->p_ship.s_maxdamage -
          me->p_damage)) / me->p_ship.s_maxdamage, hull_num = 7;
        int     hull_color;

        if (hull_left <= 16)
    {
      hull_num = 0;
      hull_color = W_Red;
    }
        else if (hull_left <= 28)
    {
      hull_num = 1;
      hull_color = W_Yellow;
    }
        else if (hull_left <= 40)
    {
      hull_num = 2;
      hull_color = W_Green;
    }
        else if (hull_left <= 52)
    {
      hull_num = 3;
      hull_color = W_Green;
    }
        else if (hull_left <= 64)
    {
      hull_num = 4;
      hull_color = W_Green;
    }
        else if (hull_left <= 76)
    {
      hull_num = 5;
      hull_color = W_White;
    }
        else if (hull_left <= 88)
    {
      hull_num = 6;
      hull_color = W_White;
    }
        else
    hull_color = playerColor(j);

        W_WriteBitmap(dx - (shield_width / 2 + 1),
          dy - (shield_height / 2 + 1),
          hull[hull_num], hull_color);
      }
#endif

#ifdef SOUND
    if (j->p_no == me->p_no)
      {
        if ((sound_flags & PFSHIELD) && !(j->p_flags & PFSHIELD)) {
#if defined(HAVE_SDL)
    Play_Sound(SHIELD_DOWN_WAV);
#else
    Play_Sound(SHIELD_DOWN_SOUND);
#endif
        }
        if (!(sound_flags & PFSHIELD) && (j->p_flags & PFSHIELD)) {
#if defined(HAVE_SDL)
    Play_Sound(SHIELD_UP_WAV);
#else
    Play_Sound(SHIELD_UP_SOUND);
#endif
        }
      }
#endif

    /* It used to be that if "showShields" was false, shields were not
     * * * shown.  COW has already stopped accepting showShields flags
     * * from * the server, now stop using showShields altogether.
     * James * Soutter * (Zork)     4 Jan 95 */

    if (j->p_flags & PFSHIELD)
      {
        int     color = playerColor(j);

#ifdef VSHIELD_BITMAPS
        int     shieldnum;

        if (j == me && VShieldBitmaps)
    {
      shieldnum = SHIELD_FRAMES * me->p_shield / me->p_ship.s_maxshield;
      if (shieldnum >= SHIELD_FRAMES)
        shieldnum = SHIELD_FRAMES - 1;
      color = gColor;
      if (shieldnum < SHIELD_FRAMES * 2 / 3)
        {
          color = yColor;
          if (shieldnum < SHIELD_FRAMES * 2 / 3)
      {
        color = rColor;
      }
        }
    }
        else
    {
      color = playerColor(j);
      shieldnum = 2;
    }
#endif

        if (warnShields && j == me)
    {
      switch (me->p_flags & (PFGREEN | PFYELLOW | PFRED))
        {
        case PFGREEN:
          color = gColor;
          break;
        case PFYELLOW:
          color = yColor;
          break;
        case PFRED:
          color = rColor;
          break;
        }
    }

#ifdef VSHIELD_BITMAPS
        W_WriteBitmap(dx - (shield_width / 2),
      dy - (shield_height / 2), shield[shieldnum], color);
#else

        W_WriteBitmap(dx - (shield_width / 2),
          dy - (shield_height / 2), shield, color);
#endif
      }
    /* Det circle */
    if (detCircle)
            {
        if (myPlayer(j) || isObsLockPlayer(j))
              {
      int dcr = DETDIST*2/SCALE;
      int dcx = dx - (dcr/2);
      int dcy = dy - (dcr/2);
      W_WriteCircle(w, dcy, dcy, dcr, W_Red);
      clearzone[0][clearcount] = dcx;
      clearzone[1][clearcount] = dcy;
      clearzone[2][clearcount] = dcr + dcr;
      clearzone[3][clearcount] = dcr + dcr;
      clearcount++;
      detCircle--;
                }
            }
    if (j->p_flags & PFCLOAK)    /* when cloaked stop here */
      continue;

    {
      int     color = playerColor(j);

      idbuf[0] = *(shipnos + j->p_no);

      if (myPlayer(j) || isObsLockPlayer(j))
        {
    switch (me->p_flags & (PFGREEN | PFYELLOW | PFRED))
      {
      case PFGREEN:
        color = gColor;
        break;
      case PFYELLOW:
        color = yColor;
        break;
      case PFRED:
        color = rColor;
        break;
      }
        }
      W_MaskText(w, dx + (j->p_ship.s_width / 2),
           dy - (j->p_ship.s_height / 2), color,
           idbuf, 1, shipFont(j));

      clearzone[0][clearcount] = dx + (j->p_ship.s_width / 2);
      clearzone[1][clearcount] = dy - (j->p_ship.s_height / 2);
      clearzone[2][clearcount] = W_Textwidth;
      clearzone[3][clearcount] = W_Textheight;
      clearcount++;
    }

  }
      else if (j->p_status == PEXPLODE)
  {
    int     i;

    i = j->p_explode;

#ifdef SOUND
    if (i == 1)
#if defined(HAVE_SDL)
      Play_Sound(j == me ? EXPLOSION_WAV : EXPLOSION_OTHER_WAV);
#else
      Play_Sound(j == me ? EXPLOSION_SOUND : OTHER_EXPLOSION_SOUND);
#endif
#endif

#ifdef HAVE_XPM
    if (sprite != NULL)
      {
        clearsize = W_DrawSprite(sprite, dx, dy, TWINSIDE);
        clearzone[0][clearcount] = dx - (clearsize / 2);
        clearzone[1][clearcount] = dy - (clearsize / 2);
        clearzone[2][clearcount] = clearsize;
        clearzone[3][clearcount] = clearsize;
        clearcount++;
      }
    else
#endif

      if (i < EX_FRAMES ||
    (i < SBEXPVIEWS && j->p_ship.s_type == STARBASE))
      {

        if (j->p_ship.s_type == STARBASE)
    {
      W_WriteBitmap(dx - (sbexp_width / 2),
        dy - (sbexp_height / 2), sbexpview[i],
        playerColor(j));
      clearzone[0][clearcount] = dx - (sbexp_width / 2);
      clearzone[1][clearcount] = dy - (sbexp_height / 2);
      clearzone[2][clearcount] = sbexp_width;
      clearzone[3][clearcount] = sbexp_height;
    }
        else
    {
      W_WriteBitmap(dx - (ex_width / 2), dy - (ex_height / 2),
        expview[i], playerColor(j));
      clearzone[0][clearcount] = dx - (ex_width / 2);
      clearzone[1][clearcount] = dy - (ex_height / 2);
      clearzone[2][clearcount] = ex_width;
      clearzone[3][clearcount] = ex_height;
    }
        clearcount++;
        j->p_explode++;
      }
  }

      /* Now draw his phaser (if it exists) */
      php = &phasers[j->p_no];

      if (php->ph_status != PHFREE)
  {

#ifdef SOUND
    if (!sound_phaser)
      {
#if defined(HAVE_SDL)
        Play_Sound(j == me ? PHASER_WAV : PHASER_OTHER_WAV);
#else
        Play_Sound(j == me ? PHASER_SOUND : OTHER_PHASER_SOUND);
#endif
        sound_phaser++;
      }
#endif

    if ((php->ph_updateFuse -= weaponUpdate) == 0)
      {
        /* Expire the phaser */

#if 0
        fputs("[phaser]", stderr);
        fflush(stderr);
#endif

        php->ph_status = PHFREE;
      }
    else
      {
        if (php->ph_status == PHMISS)
    {
      /* Here I will have to compute end coordinate */
      tx = PHASEDIST * j->p_ship.s_phaserdamage / 100 *
          Cos[php->ph_dir];

      ty = PHASEDIST * j->p_ship.s_phaserdamage / 100 *
          Sin[php->ph_dir];

      tx = (j->p_x + tx - me->p_x) / SCALE + TWINSIDE / 2;
      ty = (j->p_y + ty - me->p_y) / SCALE + TWINSIDE / 2;
      php->ph_fuse = 0;

    }
        else if (php->ph_status == PHHIT2)
    {
      tx = (php->ph_x - me->p_x) / SCALE + TWINSIDE / 2;
      ty = (php->ph_y - me->p_y) / SCALE + TWINSIDE / 2;
    }
        else
    {        /* Start point is dx, dy */
      tx = (players[php->ph_target].p_x - me->p_x) /
          SCALE + TWINSIDE / 2;
      ty = (players[php->ph_target].p_y - me->p_y) /
          SCALE + TWINSIDE / 2;
    }


        /* Shrink the phasers if necessary: * * Measure length in 16ths
         *
         * * to make the maths a little * easier for the computer (div
         * 16  * is a 4 bit shift). *  * Add 8 to each sum to round
         * properly.  */

        if (shrinkPhaserOnMiss || php->ph_status != PHMISS)
    {
      if (j == me)
        {
          px = (dx * (16 - phaserShrink) + tx * phaserShrink + 8)
        / 16;
          py = (dy * (16 - phaserShrink) + ty * phaserShrink + 8)
        / 16;
        }
      else
        {
          px = (dx * (16 - theirPhaserShrink) +
          tx * theirPhaserShrink + 8) / 16;

          py = (dy * (16 - theirPhaserShrink) +
          ty * theirPhaserShrink + 8) / 16;
        }
    }
        else
    {
      px = dx;
      py = dy;
    }


        /* Now draw the phasers */

        if (friendlyPlayer(j))
    {
      if (highlightFriendlyPhasers && (php->ph_status == PHHIT))
        W_CacheLine(w, px, py, tx, ty, foreColor);
      else
        {
          if ((php->ph_fuse % 2) == 1)
      W_CacheLine(w, px, py, tx, ty, foreColor);
          else
      W_CacheLine(w, px, py, tx, ty, shipCol[remap[j->p_team]]);
        }
      php->ph_fuse++;

      clearline[0][clearlcount] = px;
      clearline[1][clearlcount] = py;
      clearline[2][clearlcount] = tx;
      clearline[3][clearlcount] = ty;
      clearlcount++;
    }
        else
    {
      if ((enemyPhasers > 0) && (enemyPhasers <= 10))
        {
          unsigned char dir;

          if (tx == px && ty == py)
      continue;

#ifdef SHORT_PACKETS
          if (php->ph_status != PHMISS) /* KOC 10/20/95  */
      {      /* hack for SP_2 */
#define XPI     3.1415926
        dir = (unsigned char) nint(atan2((double) (ty - py),
           (double) (tx - px)) / XPI * 128.0);
#undef XPI
      }
          else
#endif

      {
        dir = NORMALIZE(php->ph_dir + 64);
      }

          wx = px + enemyPhasers * Cos[dir];
          wy = py + enemyPhasers * Sin[dir];
          lx = px - enemyPhasers * Cos[dir];
          ly = py - enemyPhasers * Sin[dir];

          W_MakePhaserLine(w, wx, wy, tx, ty,
               shipCol[remap[j->p_team]]);
          W_MakePhaserLine(w, lx, ly, tx, ty,
               shipCol[remap[j->p_team]]);

          php->ph_fuse++;

          clearline[0][clearlcount] = wx;
          clearline[1][clearlcount] = wy;
          clearline[2][clearlcount] = tx;
          clearline[3][clearlcount] = ty;
          clearlcount++;

          clearline[0][clearlcount] = lx;
          clearline[1][clearlcount] = ly;
          clearline[2][clearlcount] = tx;
          clearline[3][clearlcount] = ty;
          clearlcount++;
        }
      else
        {
          W_MakePhaserLine(w, px, py, tx, ty,
               shipCol[remap[j->p_team]]);

          php->ph_fuse++;

          clearline[0][clearlcount] = px;
          clearline[1][clearlcount] = py;
          clearline[2][clearlcount] = tx;
          clearline[3][clearlcount] = ty;
          clearlcount++;
        }
    }
      }
  }

#ifdef SOUND
      else if (j->p_no == me->p_no)
  sound_phaser = 0;
#endif

      /* ATM - show tractor/pressor beams (modified by James Collins) */
      /* showTractorPressor is a variable set by xtrekrc. */

      if (showTractorPressor)
  {
    if (myPlayer(j) && isAlive(me) && (j->p_flags & PFTRACT || j->p_flags & PFPRESS))
      {
        double  theta;
        unsigned char dir;
        int     lx[2], ly[2], target_width;

        struct player *tractee;

        if (me->p_tractor < 0 || me->p_tractor >= MAXPLAYER)
    continue;
        tractee = &players[me->p_tractor];

        if (tractee->p_status != PALIVE ||
      ((tractee->p_flags & PFCLOAK) &&
       (tractee->p_cloakphase == (CLOAK_PHASES - 1))))
    {
      continue;
    }

        if (tcounter >= 2)
    {        /* continue tractor stuff */
      if (!continuetractor)
        tcounter--;
      px = (players[me->p_tractor].p_x - me->p_x)
          / SCALE + TWINSIDE / 2;
      py = (players[me->p_tractor].p_y - me->p_y)
          / SCALE + TWINSIDE / 2;
      if (px == dx && py == dy)
        continue;      /* this had better be last *
              *
              * * in for(..) */
#define XPI     3.1415926
      theta = atan2((double) (px - dx),
        (double) (dy - py)) + XPI / 2.0;
      dir = (unsigned char) nint(theta / XPI * 128.0);
      if (tractee->p_flags & PFSHIELD)
        target_width = shield_width;
      else
        {
          target_width = tractee->p_ship.s_width / 2;
        }
      lx[0] = px + (Cos[dir] * (target_width / 2));
      ly[0] = py + (Sin[dir] * (target_width / 2));
      lx[1] = px - (Cos[dir] * (target_width / 2));
      ly[1] = py - (Sin[dir] * (target_width / 2));
#undef XPI
      if (j->p_flags & PFPRESS)
        {
          W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Yellow);
          W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Yellow);
        }
      else
        {
          W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Green);
          W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Green);
        }

#ifdef WIN32
      /* Fixup for minor inconsistencies between SAC's interger *
       *
       * * linedraw and Win32 LineTo() */
      tpline = clearlcount;
#endif

      clearline[0][clearlcount] = dx;
      clearline[1][clearlcount] = dy;
      clearline[2][clearlcount] = lx[0];
      clearline[3][clearlcount] = ly[0];
      clearlcount++;
      clearline[0][clearlcount] = dx;
      clearline[1][clearlcount] = dy;
      clearline[2][clearlcount] = lx[1];
      clearline[3][clearlcount] = ly[1];
      clearlcount++;
    }
      }
    else if (!(me->p_flags & PFPRESS || me->p_flags & PFTRACT))
      tcounter = 2;
  }
    }
}
Exemple #8
0
void BoardGame::drawLast(QPixmap *cache, QPainter *painter, const QPoint& point, const int player)
{
	painter->setPen(QPen(playerColor(player), 0, DashLine));
	painter->setBrush(NoBrush);
	painter->drawRect(pointRect(cache->size(), point));
}
Exemple #9
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));
    }
}