Пример #1
0
inline void clearLocal(void)
/*
 * Clear the local map (intelligently rather than just simply wiping
 * the map).
 */
{
  if (W_FastClear)
    {
      W_ClearWindow(w);
      clearcount = 0;
      clearlcount = 0;
    }
  else
    {

#ifndef WIN32
      while (clearcount)
  {
    clearcount--;
    /* XFIX */
    W_CacheClearArea(w, clearzone[0][clearcount],
       clearzone[1][clearcount], clearzone[2][clearcount],
         clearzone[3][clearcount]);

    /* W_ClearArea(w, clearzone[0][clearcount], * *
     * clearzone[1][clearcount], clearzone[2][clearcount], * *
     * clearzone[3][clearcount]); */
  }
      while (clearlcount)
  {
    clearlcount--;
    /* XFIX */
    W_CacheLine(w, clearline[0][clearlcount], clearline[1][clearlcount],
          clearline[2][clearlcount], clearline[3][clearlcount],
          backColor);
    /* W_MakeLine(w, clearline[0][clearlcount], * *
     * clearline[1][clearlcount], clearline[2][clearlcount], * *
     * clearline[3][clearlcount], backColor); */
  }
      /* XFIX */
      W_FlushClearAreaCache(w);
      W_FlushLineCaches(w);
#else
      // Much more efficient way of clearing -- X programmers take note!
      W_ClearAreas(w, clearzone[0], clearzone[1], clearzone[2], clearzone[3], clearcount);
      clearcount = 0;
      if (tpline != -1)
  {
    /* Fixup for SAC's integer linedraw */
    W_MakeTractLine(w, clearline[0][tpline], clearline[1][tpline],
         clearline[2][tpline], clearline[3][tpline], backColor);
    W_MakeTractLine(w, clearline[0][tpline + 1], clearline[1][tpline + 1],
       clearline[2][tpline + 1], clearline[3][tpline + 1], backColor);
    tpline = -1;
  }
      W_MakeLines(w, clearline[0], clearline[1], clearline[2], clearline[3], clearlcount, backColor);
      clearlcount = 0;
#endif
    }
}
Пример #2
0
makeNewGuy(void)
/* Make the dude with name tempname and password password1. Move to state
 * ST_DONE. */
{
  char   *s;

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

  /* same routine! */
  checkpassword();
}
Пример #3
0
/* generic player/planet update */
plstat()
{
    int i;
    char buf[100];

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

    plstat2();
}
Пример #4
0
void    redrawTstats(void)
{
  if (newDashboard)        /* 6/2/93 LAB */
    db_redraw(1);
  else
    {
      W_ClearWindow(tstatw);
      stline(1);         /* This is for refresh. We *
              *
              * * redraw player stats too
              */
      updateMaxStats(1);       /* <isae> Seperated it */
    }
}
Пример #5
0
void    redrawStats(void)
{
  int     i;

  W_ClearWindow(statwin);
  initStats();
  for (i = 0; i < NUM_SLIDERS; i++)
    {
      sliders[i].lastVal = 0;
    }
  for (i = 0; i < NUM_SLIDERS; i++)
    {
      W_WriteText(statwin, TX_OFF(sliders[i].label_length), TY_OFF(i),
		  textColor, sliders[i].label, sliders[i].label_length,
		  W_RegularFont);
      box(0, BX_OFF() - 1, BY_OFF(i) - 1, SL_WID + 2, SL_HEI + 2, borderColor);
      sliders[i].lastVal = 0;
    }
}
Пример #6
0
checkpassword(void)
/* Check dude's password. If he is ok, move to state ST_DONE. */
{
  char   *s;

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

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

    terminate(0);
  }
    }
  if (loginAccept == 0)
    {
      if (!autolog)
  {
    s = "Bad password!";
    W_WriteText(w, 100, 100, textColor, s, strlen(s), W_BoldFont);
    (void) W_EventsPending();
    sleep(3);
    W_ClearWindow(w);
  }
      else
  noautologin();
      *tempname = 0;
      state = ST_GETNAME;
      return;
    }
  STRNCPY(me->p_name, tempname, sizeof(tempname));
  keeppeace = (me->p_stats.st_flags / ST_KEEPPEACE) & 1;
  state = ST_DONE;
}
/* 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);
	}
    }
}
Пример #8
0
static void
redrawTeam(W_Window win, int teamNo, int *lastnum)
{
    char    buf[BUFSIZ];
    int     num = numShips(teamNo);

    /* Only redraw if number of players has changed */
    if (*lastnum == num)
	return;

    drawIcon();

    W_ClearWindow(win);
    W_DrawImageNoClip(teamWin[teamNo], 0, 0, 0, teaminfo[teamNo].shield_logo,
                shipCol[teamNo + 1]);
    (void) sprintf(buf, "%d", num);
    W_MaskText(win, 5, 46, shipCol[teamNo + 1], buf, strlen(buf),
	       W_BigFont);
    if (!(tournMask & (1 << teamNo)))
      W_DrawImage(win, 0, 0, 0, getImage(I_NOENTRY), W_Red);
    *lastnum = num;
}
Пример #9
0
void
drawIcon(void)
{
    if (!iconified) {
	me_messages = 0;
	team_messages = 0;
	all_messages = 0;
    }
	iconified = 1;
    if (!infoIcon) {
        W_DrawImageNoClip(iconWin, 0, 0, 0, getImage(I_ICON), W_White);
    } else {			/* code for information icon 1/15 [BDyess] */
	int     side, bottom, top, digits, x, i;
	char    buf[50];
	W_Image *iconimage = getImage(I_ICON);

	W_ClearWindow(iconWin);
	side = iconimage->width / number_of_teams;
	bottom = 0 + side;
	top = 0;
	W_MakeLine(iconWin, 0, bottom, iconimage->width,bottom,W_White);
	for (i = 0; i <= number_of_teams; i++) {	/* draw the vertical
							   lines */
	    x = i * side;
	    x = (x > iconimage->width) ? iconimage->width : x;
	    W_MakeLine(iconWin, x, bottom, x, top, W_White);
	}
	for (i = 0; i < number_of_teams; i++) {
	    sprintf(buf, "%d", numShips(i));
	    digits = strlen(buf);
	    W_WriteText(iconWin, i * side + side / 2 - digits * W_Textwidth / 2,
			bottom - side / 2 - W_Textheight / 2,
			shipCol[i + 1], buf, digits, W_RegularFont);
	}
	if (me->p_status == PALIVE) {
#define TOP iconimage->height-10
	    if (me->p_flags & PFGREEN)
		W_FillArea(iconWin, 0, TOP, iconimage->width,
			   iconimage->height, W_Green);
	    else if (me->p_flags & PFYELLOW)
		W_FillArea(iconWin, 0, TOP,
			   iconimage->width, iconimage->height,
			   W_Yellow);
	    else if (me->p_flags & PFRED)
		W_FillArea(iconWin, 0, TOP,
			   iconimage->width, iconimage->height,
			   W_Red);
	}
	if (me_messages) {
	    sprintf(buf, "Personal: %d", me_messages);
	    W_WriteText(iconWin, 1, bottom + 2, W_White, buf, strlen(buf),
			W_RegularFont);
	}
	if (team_messages) {
	    sprintf(buf, "Team:     %d", team_messages);
	    W_WriteText(iconWin, 1, bottom + 2 + W_Textheight, W_White, buf,
			strlen(buf), W_RegularFont);
	}
	if (all_messages) {
	    sprintf(buf, "All:      %d", all_messages);
	    W_WriteText(iconWin, 1, bottom + 2 + 2 * W_Textheight, W_White, buf,
			strlen(buf), W_RegularFont);
	}
	if (me->p_status == POUTFIT) {
	    sprintf(buf, "Time left: %d", autoQuit - elapsed);
	    W_WriteText(iconWin, 1, bottom + 2 + W_Textheight, W_White, buf,
			strlen(buf), W_RegularFont);
	}
    }
}
Пример #10
0
getname(char *defname, char *defpasswd)

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

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

  MZERO(mystats, sizeof(struct stats));

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

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

  lasttime = time(NULL);

  if (ghoststart)
    return;

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

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

      if (!autolog)
  {

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

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

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

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

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

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

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

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

#ifdef HAVE_XPM
    W_GalacticBgd(GHOST_PIX);
#endif

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

    terminate(0);
  }

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

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

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

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

      default:
        break;
      }

    loginproced(ch, defname);

  }

      laststate = state;
    }
}
Пример #11
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 */
}
Пример #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
loaddude(void)
{
  char    ppwd[16];

  STRNCPY(ppwd, "\0\0\0", 4);
  if (strncmp(tempname, "Guest", 5) == 0 || strncmp(tempname, "guest", 5) == 0)
    {
      loginAccept = -1;
      sendLoginReq(tempname, ppwd, login, 0);
      state = ST_DONE;
      me->p_pos = -1;
      me->p_stats.st_tticks = 1;     /* prevent overflow */
      STRNCPY(me->p_name, tempname, sizeof(tempname));
      while (loginAccept == -1)
  {
    socketPause();
    readFromServer(NULL);
    if (isServerDead())
      {
        printf("Server is hosed.\n");

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

        terminate(0);
      }
  }
      if (loginAccept == 0)
  {
    char *s = "Server refuses guest login, use another name.";
    W_WriteText(w, 100, 70, textColor, s, strlen(s), W_BoldFont);
    (void) W_EventsPending();
    sleep(3);
    W_ClearWindow(w);
    state = ST_GETNAME;
    *tempname = 0;
#ifdef AUTOKEY
    if (autoKey)
      W_AutoRepeatOn();
#endif
  }
      return;
    }
  /* Ask about the user */
  loginAccept = -1;
  sendLoginReq(tempname, ppwd, login, 1);
  while (loginAccept == -1)
    {
      socketPause();
      readFromServer(NULL);
      if (isServerDead())
  {
    printf("Server is hosed.\n");

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

    terminate(0);
  }
    }
  *password1 = *password2 = 0;
  if (loginAccept == 0)
    {
      state = ST_MAKEPASS1;
    }
  else
    {
      state = ST_GETPASS;
    }
}
Пример #14
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;
    }
}
Пример #15
0
void
        fillmacro(void)
{
  register int row, i;
  char    macromessage[MACROLEN];

  W_ClearWindow(macroWin);
  sprintf(macromessage, "Packages active:  NBT%s%s\0",
    (UseNewMacro ? ", NEWMACRO" : ""),
    (UseSmartMacro ? ", SMARTMACRO" : ""));

  W_WriteText(macroWin, 2, 1, textColor,
        macromessage, strlen(macromessage), W_RegularFont);

  sprintf(macromessage, "Currently showing: %s\0",
    (maclevel ? "Macros" : "RCDS"));

  W_WriteText(macroWin, 2, 2, textColor,
        macromessage, strlen(macromessage), W_RegularFont);


  if (maclevel == 0)
    {
      W_WriteText(macroWin, 2, 4, W_Yellow,
      "Key     Distress Name", 21, W_RegularFont);
      filldist(1);
      return;
    }

  /* 4 column macro window. This may be changed depending on font size */
  for (row = 4, i = 0; i < macrocnt; row++, i++)
    {
      if (macro[i].key <= 128)
  sprintf(macromessage, "%c \0", macro[i].key);
      else
  sprintf(macromessage, "^%c\0", macro[i].key - 96);
      if (macro[i].type == NEWMMOUSE)
  {
    switch (macro[i].who)
      {
      case MACRO_PLAYER:
        strcat(macromessage, " PL MS ");
        break;
      case MACRO_TEAM:
        strcat(macromessage, " TM MS ");
        break;
      default:
        strcat(macromessage, " SELF  ");
        break;
      }
  }
      else
  {
    switch (macro[i].who)
      {
      case 'T':
        strcat(macromessage, " TEAM  ");
        break;
      case 'A':
        strcat(macromessage, " ALL   ");
        break;
      case 'F':
        strcat(macromessage, " FED   ");
        break;
      case 'R':
        strcat(macromessage, " ROM   ");
        break;
      case 'K':
        strcat(macromessage, " KLI   ");
        break;
      case 'O':
        strcat(macromessage, " ORI   ");
        break;
      case 'M':
        strcat(macromessage, " MOO   ");
        break;

#ifdef TOOLS
      case '!':
        strcat(macromessage, " SHELL ");
        break;
#endif

#ifdef NEWMACRO
      case '\0':
        strcat(macromessage, " SPEC  ");
        break;
#endif

      default:
        strcat(macromessage, " ----  ");
        break;
      }
  }
      strcat(macromessage, macro[i].string);
      macromessage[MAXMACRO] = '\0';
      W_WriteText(macroWin, 2, row, textColor,
      macromessage, strlen(macromessage), W_RegularFont);
    }
}
Пример #16
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);	
}
Пример #17
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);
    }
}
Пример #19
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);
  }
    }
}
Пример #20
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;
}
Пример #21
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);
    }
}
Пример #22
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);
}