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);
}
static void
redrawQuit(void)
{
    /* W_WriteText(qwin, 5, 5, textColor, "Quit xtrek", 10, W_RegularFont); */
    if (me->p_status == PTQUEUE) {
	W_ClearArea(qwin, 0, 0, BOXSIDE, BOXSIDE);
	W_DrawImageNoClip(qwin, 0, 0, 0, getImage(I_SAFE), foreColor);
    }
}
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));
    }
}
Exemple #4
0
void do_score()
{
    static int lastscore, lastlevel, lastships;
#ifdef SOUND
    static int lastsounds;
#endif
    if (lastscore != score) 
    {
	if ((score > 0) && (score >= nextBonus)) 
        {
	    ships++;
	    extrax = 0 - extraImage->width/2;
	    extray = WINHEIGHT/2;
	    drawExtra = 1;
	    if (nextBonus < BONUSSHIPSCORE)
		nextBonus = BONUSSHIPSCORE;
	    else
		nextBonus += BONUSSHIPSCORE;
	}
    }

#ifdef SOUND
    if (lastscore != score || lastlevel != level || lastships != ships || lastsounds != playSounds) 
#else
    if (lastscore != score || lastlevel != level || lastships != ships) 
#endif
    {
    	W_ClearArea(shellWin, 0, 0, WINWIDTH, W_Textheight + 1);
	draw_score();
	lastscore=score;
	lastlevel=level;
	lastships=ships;
#ifdef SOUND
        lastsounds=playSounds;
#endif
    }

    if (drawExtra) 
    {
	extrax += 10;
	W_DrawImage(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 0, extraImage, W_White);
	if((extrax-(int)extraImage->width/2) > WINWIDTH)
	    drawExtra = 0;
    }
}
Exemple #5
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();
}
Exemple #6
0
static void
        db_bar(char *l, int x, int y, int w, int h, int m, int t, int v, int b)
{
  int     i, hgt, val_pix, tmax_pix, yellow_pix, red_pix;
  int     label_len;
  char    label[32];


  W_ClearArea(tstatw, x, y, w, h);

  if (b)
    {
      val_pix = (w * v) / m;
    }
  else
    {
      val_pix = (w * (m - v)) / m;
    }

  tmax_pix = (w * t) / m;
  yellow_pix = w / 3;
  red_pix = (2 * w) / 3;

  if ((t < 0) ||
      (t > m) ||
      (v < 0) ||
      (v > m))
    {
      W_FillArea(tstatw, x, y, w, h, W_Red);

      W_MaskText(tstatw,
     x + w - (3 * W_Textwidth) - 2,
     y + h - W_Textheight - 2,
     W_White, l, 3, W_BoldFont);

      label_len = db_itoa(label, v);

      W_MaskText(tstatw,
     x, y,
     W_White, label, label_len, W_BoldFont);

      label_len = db_itoa(label, t);

      if (t == m)
  {
    W_MaskText(tstatw,
         x, y + W_Textheight + 2,
         W_Grey, label, label_len, W_RegularFont);
  }
      else
  {
    W_MaskText(tstatw,
         x, y + W_Textheight + 2,
         W_White, label, label_len, W_RegularFont);
  }
    }
  else
    {
      for (i = 0; i < w; i++)
  {
    hgt = h - ((h * i) / w);

    if ((i >= tmax_pix) && (i % 2))
      {
        W_MakeLine(tstatw, x + i, y + hgt, x + i, y + h, W_Grey);
      }
    else if (i <= val_pix)
      {
        if (i < yellow_pix)
    {
      W_MakeLine(tstatw, x + i, y + hgt, x + i, y + h, W_Green);
    }
        else if (i < red_pix)
    {
      W_MakeLine(tstatw, x + i, y + hgt, x + i, y + h, W_Yellow);
    }
        else
    {
      W_MakeLine(tstatw, x + i, y + hgt, x + i, y + h, W_Red);
    }
      }
  }

      if (b ? (v > (m / 2)) : (v < (m / 2)))
  {
    W_MaskText(tstatw,
         x + w - (3 * W_Textwidth) - 2,
         y + h - W_Textheight - 2,
         W_White, l, 3, W_RegularFont);
  }
      else
  {
    W_MaskText(tstatw,
         x + w - (3 * W_Textwidth) - 2,
         y + h - W_Textheight - 2,
         W_Grey, l, 3, W_RegularFont);
  }

      label_len = db_itoa(label, v);

      if (b ? (v > (m / 2)) : (v < (m / 2)))
  {
    W_MaskText(tstatw,
         x, y,
         W_White, label, label_len, W_BoldFont);
  }
      else
  {
    W_MaskText(tstatw,
         x, y,
         W_Grey, label, label_len, W_BoldFont);
  }

      label_len = db_itoa(label, t);

      if (t == m)
  {
    W_MaskText(tstatw,
         x, y + W_Textheight + 2,
         W_Grey, label, label_len, W_RegularFont);
  }
      else
  {
    W_MaskText(tstatw,
         x, y + W_Textheight + 2,
         W_White, label, label_len, W_RegularFont);
  }
    }

  W_MakeLine(tstatw, x, y + h, x + w, y + h, W_Grey);
  W_MakeLine(tstatw, x + w, y, x + w, y + h, W_Grey);
}
Exemple #7
0
void
        db_redraw_lab2(int fr)
{
  static int old_spd = -1, old_cur_max = -1;
  static int old_shl = -1, old_dam = -1;
  static int old_arm = -1, old_cur_arm = -1;
  static int old_wpn = -1, old_egn = -1;
  static int old_ful = -1;
  static float old_kills = -1;
  int     cur_max, cur_arm, label_len;
  char    label[32];


  if (me->p_ship.s_type == ASSAULT)
    {
      cur_arm = (3 * me->p_kills);
    }
  else
    {
      cur_arm = (2 * me->p_kills);
    }

  if (cur_arm < 0)
    {
      cur_arm = 0;
    }
  else if ((cur_arm > me->p_ship.s_maxarmies) ||
     (me->p_ship.s_type == STARBASE))
    {
      cur_arm = me->p_ship.s_maxarmies;
    }

  cur_max = ((me->p_ship.s_maxspeed + 2) -
       ((me->p_ship.s_maxspeed + 1) *
        ((float) me->p_damage /
         (float) me->p_ship.s_maxdamage)));

  if (cur_max < 0)
    {
      cur_max = 0;
    }
  else if (cur_max > me->p_ship.s_maxspeed)
    {
      cur_max = me->p_ship.s_maxspeed;
    }

  if (fr)
    {
      W_ClearWindow(tstatw);
    }

  db_flags(fr);

  if (fr ||
      (me->p_speed != old_spd) ||
      (old_cur_max != cur_max))
    {
      db_bar("Spd", 2, 2, 75, 25,
       me->p_ship.s_maxspeed,
       cur_max,
       me->p_speed,
       1);
    }

  if (fr ||
      (old_ful != me->p_fuel))
    {
      db_bar("Ful", 82, 2, 75, 25,
       me->p_ship.s_maxfuel,
       me->p_ship.s_maxfuel,
       me->p_fuel,
       0);
    }

  if (fr ||
      (old_shl != me->p_shield))
    {
      db_bar("Shl", 162, 2, 75, 25,
       me->p_ship.s_maxshield,
       me->p_ship.s_maxshield,
       me->p_shield,
       0);
    }

  if (fr ||
      (old_dam != me->p_damage))
    {
      db_bar("Dam", 242, 2, 75, 25,
       me->p_ship.s_maxdamage,
       me->p_ship.s_maxdamage,
       me->p_damage,
       1);
    }

  if (me->p_ship.s_type == STARBASE)
    {
      if (fr ||
    (old_wpn != me->p_wtemp))
  {
    db_bar("Wpn", 322, 2, 75, 25,
     me->p_ship.s_maxwpntemp / 10,
     me->p_ship.s_maxwpntemp / 10,
     me->p_wtemp / 10,
     1);
  }

      if (fr ||
    (old_egn != me->p_etemp))
  {
    W_ClearArea(tstatw, 324, 32, 78, W_Textheight);

    label[0] = 'E';
    label[1] = 'g';
    label[2] = 'n';
    label[3] = ':';
    label[4] = ' ';
    label_len = 5 + db_itoa(&label[5], me->p_etemp / 10);
    label[label_len++] = '/';
    label_len += db_itoa(&label[label_len],
             me->p_ship.s_maxegntemp / 10);

    if (me->p_etemp > (me->p_ship.s_maxegntemp / 2))
      {
        W_WriteText(tstatw,
        324, 32,
        W_White, label, label_len, W_BoldFont);
      }
    else
      {
        W_WriteText(tstatw,
        324, 32,
        W_Grey, label, label_len, W_RegularFont);
      }
  }
    }
  else
    {
      if (fr ||
    (old_egn != me->p_etemp))
  {
    db_bar("Egn", 322, 2, 75, 25,
     me->p_ship.s_maxegntemp / 10,
     me->p_ship.s_maxegntemp / 10,
     me->p_etemp / 10,
     1);
  }

      if (fr ||
    (old_wpn != me->p_wtemp))
  {
    W_ClearArea(tstatw, 324, 32, 78, W_Textheight);

    label[0] = 'W';
    label[1] = 'p';
    label[2] = 'n';
    label[3] = ':';
    label[4] = ' ';
    label_len = 5 + db_itoa(&label[5], me->p_wtemp / 10);
    label[label_len++] = '/';
    label_len += db_itoa(&label[label_len],
             me->p_ship.s_maxwpntemp / 10);

    if (me->p_wtemp > (me->p_ship.s_maxwpntemp / 2))
      {
        W_WriteText(tstatw,
        324, 32,
        W_White, label, label_len, W_BoldFont);
      }
    else
      {
        W_WriteText(tstatw,
        324, 32,
        W_Grey, label, label_len, W_RegularFont);
      }
  }
    }

  if (fr ||
      (old_arm != me->p_armies) ||
      (old_cur_arm != cur_arm))
    {
      W_ClearArea(tstatw, 402, 2, 98, W_Textheight);

      if (cur_arm > 0)
  {
    label[0] = 'A';
    label[1] = 'r';
    label[2] = 'm';
    label[3] = 'i';
    label[4] = 'e';
    label[5] = 's';
    label[6] = ':';
    label[7] = ' ';
    label_len = 8 + db_itoa(&label[8], me->p_armies);
    label[label_len++] = '/';
    label_len += db_itoa(&label[label_len], cur_arm);

    if (me->p_armies >= cur_arm)
      {
        W_WriteText(tstatw,
        402, 2,
        W_Red, label, label_len, W_BoldFont);
      }
    else if (me->p_armies > 0)
      {
        W_WriteText(tstatw,
        402, 2,
        W_Yellow, label, label_len, W_BoldFont);
      }
    else
      {
        W_WriteText(tstatw,
        402, 2,
        W_Green, label, label_len, W_BoldFont);
      }
  }
    }

  if (fr ||
      (old_kills != me->p_kills))
    {
      W_ClearArea(tstatw, 402, 4 + W_Textheight, 98, W_Textheight);

      if (me->p_kills > 0.0)
  {
    label[0] = ' ';
    label[1] = 'K';
    label[2] = 'i';
    label[3] = 'l';
    label[4] = 'l';
    label[5] = 's';
    label[6] = ':';
    label[7] = ' ';
    label_len = 8 + db_ftoa(&label[8], me->p_kills);

    if (cur_arm > 4)
      {
        W_WriteText(tstatw,
        402, 4 + W_Textheight,
        W_White, label, label_len, W_BoldFont);
      }
    else if (cur_arm > 1)
      {
        W_WriteText(tstatw,
        402, 4 + W_Textheight,
        W_White, label, label_len, W_RegularFont);
      }
    else
      {
        W_WriteText(tstatw,
        402, 4 + W_Textheight,
        W_Grey, label, label_len, W_RegularFont);
      }
  }

      old_kills = me->p_kills;
    }

  old_spd = me->p_speed;
  old_cur_max = cur_max;
  old_shl = me->p_shield;
  old_dam = me->p_damage;
  old_arm = me->p_armies;
  old_cur_arm = cur_arm;
  old_wpn = me->p_wtemp;
  old_egn = me->p_etemp;
  old_ful = me->p_fuel;
}
Exemple #8
0
void undo_score()
{
    if(drawExtra)
	W_ClearArea(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 
		    extraImage->width, extraImage->height);
}
Exemple #9
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(); */
}
Exemple #10
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));
    }
}