Esempio n. 1
0
long
recallplayer(void)
{
	long    loc = 0L;	/* location in player file */
	int     loop;		/* loop counter */
	int     ch;		/* input */

	clear();
	mvprintw(10, 0, "What was your character's name ? ");
	getstring(Databuf, SZ_NAME);
	truncstring(Databuf);

	if ((loc = findname(Databuf, &Player)) >= 0L)
		/* found character */
	{
		Echo = FALSE;

		for (loop = 0; loop < 2; ++loop) {
			/* prompt for password */
			mvaddstr(11, 0, "Password ? ");
			getstring(Databuf, SZ_PASSWORD);
			if (strcmp(Databuf, Player.p_password) == 0)
				/* password good */
			{
				Echo = TRUE;

				if (Player.p_status != S_OFF)
					/* player did not exit normally last
					 * time */
				{
					clear();
					addstr("Your character did not exit normally last time.\n");
					addstr("If you think you have good cause to have your character saved,\n");
					printw("you may quit and mail your reason to 'root'.\n");
					addstr("Otherwise, continuing spells certain death.\n");
					addstr("Do you want to quit ? ");
					ch = getanswer("YN", FALSE);
					if (ch == 'Y') {
						Player.p_status = S_HUNGUP;
						writerecord(&Player, loc);
						cleanup(TRUE);
					}
					death("Stupidity");
				}
				return (loc);
			} else
				mvaddstr(12, 0, "No good.\n");
		}

		Echo = TRUE;
	} else
		mvaddstr(11, 0, "Not found.\n");

	more(13);
	return (-1L);
}
Esempio n. 2
0
/**
 * Print a single package which:
 *  (a) is the target of one or more relevant predependencies.
 *  (b) has itself no unsatisfied pre-dependencies.
 *
 * If such a package is present output is the Packages file entry,
 * which can be massaged as appropriate.
 *
 * Exit status:
 *  0 = a package printed, OK
 *  1 = no suitable package available
 *  2 = error
 */
void predeppackage(const char *const *argv) {
  static struct varbuf vb;

  struct pkgiterator *it;
  struct pkginfo *pkg = NULL, *startpkg, *trypkg;
  struct dependency *dep;
  struct deppossi *possi, *provider;

  if (*argv)
    badusage(_("--%s takes no arguments"), cipaction->olong);

  modstatdb_init(admindir,msdbrw_readonly);
  /* We use clientdata->istobe to detect loops. */
  clear_istobes();

  dep = NULL;
  it = pkg_db_iter_new();
  while (!dep && (pkg = pkg_db_iter_next(it))) {
    /* Ignore packages user doesn't want. */
    if (pkg->want != want_install)
      continue;
    /* Ignore packages not available. */
    if (!pkg->files)
      continue;
    pkg->clientdata->istobe= itb_preinstall;
    for (dep= pkg->available.depends; dep; dep= dep->next) {
      if (dep->type != dep_predepends) continue;
      if (depisok(dep, &vb, NULL, true))
        continue;
      /* This will leave dep non-NULL, and so exit the loop. */
      break;
    }
    pkg->clientdata->istobe= itb_normal;
    /* If dep is NULL we go and get the next package. */
  }
  pkg_db_iter_free(it);

  if (!dep)
    exit(1); /* Not found. */
  assert(pkg);
  startpkg= pkg;
  pkg->clientdata->istobe= itb_preinstall;

  /* OK, we have found an unsatisfied predependency.
   * Now go and find the first thing we need to install, as a first step
   * towards satisfying it. */
  do {
    /* We search for a package which would satisfy dep, and put it in pkg. */
    for (possi = dep->list, pkg = NULL;
         !pkg && possi;
         possi=possi->next) {
      trypkg= possi->ed;
      if (trypkg->files && versionsatisfied(&trypkg->available,possi)) {
        if (trypkg->clientdata->istobe == itb_normal) { pkg= trypkg; break; }
      }
      if (possi->verrel != dvr_none) continue;
      for (provider=possi->ed->available.depended;
           !pkg && provider;
           provider=provider->next) {
        if (provider->up->type != dep_provides) continue;
        trypkg= provider->up->up;
        if (!trypkg->files)
          continue;
        if (trypkg->clientdata->istobe == itb_normal) { pkg= trypkg; break; }
      }
    }
    if (!pkg) {
      varbufreset(&vb);
      describedepcon(&vb,dep);
      varbufaddc(&vb,0);
      fprintf(stderr, _("dpkg: cannot see how to satisfy pre-dependency:\n %s\n"),vb.buf);
      ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to %.250s)"),
             dep->up->name,startpkg->name);
    }
    pkg->clientdata->istobe= itb_preinstall;
    for (dep= pkg->available.depends; dep; dep= dep->next) {
      if (dep->type != dep_predepends) continue;
      if (depisok(dep, &vb, NULL, true))
        continue;
      /* This will leave dep non-NULL, and so exit the loop. */
      break;
    }
  } while (dep);

  /* OK, we've found it - pkg has no unsatisfied pre-dependencies! */
  writerecord(stdout, _("<standard output>"), pkg, &pkg->available);

  m_output(stdout, _("<standard output>"));
}
Esempio n. 3
0
void
changestats(bool ingameflag)
{
	static char flag[2] =	/* for printing values of bools */
	{ 'F', 'T' };
	struct player *playerp;	/* pointer to structure to alter */
	const char *prompt;	/* pointer to prompt string */
	int c;			/* input */
	int today;		/* day of year of today */
	int temp;		/* temporary variable */
	long loc;		/* location in player file */
	time_t now;		/* time now */
	double dtemp;		/* temporary variable */
	bool *bptr;		/* pointer to bool item to change */
	double *dptr;		/* pointer to double item to change */
	short *sptr;		/* pointer to short item to change */

	clear();

	for (;;) {
		/* get name of player to examine/alter */
		mvaddstr(5, 0, "Which character do you want to look at ? ");
		getstring(Databuf, SZ_DATABUF);
		truncstring(Databuf);

		if (Databuf[0] == '\0')
			userlist(ingameflag);
		else
			break;
	}

	loc = -1L;

	if (!ingameflag)
		/* use 'Player' structure */
		playerp = &Player;
	else if (strcmp(Databuf, Player.p_name) == 0) {
		/* alter/examine current player */
		playerp = &Player;
		loc = Fileloc;
	} else
		/* use 'Other' structure */
		playerp = &Other;

	/* find player on file */
	if (loc < 0L && (loc = findname(Databuf, playerp)) < 0L) {
		/* didn't find player */
		clear();
		mvaddstr(11, 0, "Not found.");
		return;
	}

	time(&now);
	today = localtime(&now)->tm_yday;

	clear();

	for (;;) {
		/* print player structure, and prompt for action */
		mvprintw(0, 0, "A:Name         %s\n", playerp->p_name);

		if (Wizard)
			printw("B:Password     %s\n", playerp->p_password);
		else
			addstr("B:Password     XXXXXXXX\n");

		printw(" :Login        %s\n", playerp->p_login);

		printw("C:Experience   %.0f\n", playerp->p_experience);
		printw("D:Level        %.0f\n", playerp->p_level);
		printw("E:Strength     %.0f\n", playerp->p_strength);
		printw("F:Sword        %.0f\n", playerp->p_sword);
		printw(" :Might        %.0f\n", playerp->p_might);
		printw("G:Energy       %.0f\n", playerp->p_energy);
		printw("H:Max-Energy   %.0f\n", playerp->p_maxenergy);
		printw("I:Shield       %.0f\n", playerp->p_shield);
		printw("J:Quickness    %.0f\n", playerp->p_quickness);
		printw("K:Quicksilver  %.0f\n", playerp->p_quksilver);
		printw(" :Speed        %.0f\n", playerp->p_speed);
		printw("L:Magic Level  %.0f\n", playerp->p_magiclvl);
		printw("M:Mana         %.0f\n", playerp->p_mana);
		printw("N:Brains       %.0f\n", playerp->p_brains);

		if (Wizard || playerp->p_specialtype != SC_VALAR)
			mvaddstr(0, 40, descrstatus(playerp));

		mvprintw(1, 40, "O:Poison       %0.3f\n", playerp->p_poison);
		mvprintw(2, 40, "P:Gold         %.0f\n", playerp->p_gold);
		mvprintw(3, 40, "Q:Gem          %.0f\n", playerp->p_gems);
		mvprintw(4, 40, "R:Sin          %0.3f\n", playerp->p_sin);
		if (Wizard) {
			mvprintw(5, 40, "S:X-coord      %.0f\n", playerp->p_x);
			mvprintw(6, 40, "T:Y-coord      %.0f\n", playerp->p_y);
		} else {
			mvaddstr(5, 40, "S:X-coord      ?\n");
			mvaddstr(6, 40, "T:Y-coord      ?\n");
		}

		mvprintw(7, 40, "U:Age          %ld\n", playerp->p_age);
		mvprintw(8, 40, "V:Degenerated  %d\n", playerp->p_degenerated);

		mvprintw(9, 40, "W:Type         %d (%s)\n",
		    playerp->p_type, descrtype(playerp, FALSE) + 1);
		mvprintw(10, 40, "X:Special Type %d\n", playerp->p_specialtype);
		mvprintw(11, 40, "Y:Lives        %d\n", playerp->p_lives);
		mvprintw(12, 40, "Z:Crowns       %d\n", playerp->p_crowns);
		mvprintw(13, 40, "0:Charms       %d\n", playerp->p_charms);
		mvprintw(14, 40, "1:Amulets      %d\n", playerp->p_amulets);
		mvprintw(15, 40, "2:Holy Water   %d\n", playerp->p_holywater);

		temp = today - playerp->p_lastused;
		if (temp < 0)
			/* last year */
			temp += 365;
		mvprintw(16, 40, "3:Lastused     %d  (%d)\n", playerp->p_lastused, temp);

		mvprintw(18, 8, "4:Palantir %c  5:Blessing %c  6:Virgin %c  7:Blind %c",
		    flag[playerp->p_palantir],
		    flag[playerp->p_blessing],
		    flag[playerp->p_virgin],
		    flag[playerp->p_blindness]);

		if (!Wizard)
			mvprintw(19, 8, "8:Ring    %c",
			    flag[playerp->p_ring.ring_type != R_NONE]);
		else
			mvprintw(19, 8, "8:Ring    %d  9:Duration %d",
			    playerp->p_ring.ring_type, playerp->p_ring.ring_duration);

		if (!Wizard
		    && (ingameflag || strcmp(Login, playerp->p_login) != 0)) {
			/* in game or not examining own character */
			if (ingameflag) {
				more(LINES - 1);
				clear();
				return;
			} else
				cleanup(TRUE);
			/* NOTREACHED */
		}

		mvaddstr(20, 0, "!:Quit       ?:Delete");
		mvaddstr(21, 0, "What would you like to change ? ");

		if (Wizard)
			c = getanswer(" ", TRUE);
		else
			/* examining own player; allow to change name and password */
			c = getanswer("!BA", FALSE);

		switch (c) {
		case 'A':	/* change name */
		case 'B':	/* change password */
			if (!Wizard) {
				/* prompt for password */
				mvaddstr(23, 0, "Password ? ");
				Echo = FALSE;
				getstring(Databuf, 9);
				Echo = TRUE;
				if (strcmp(Databuf, playerp->p_password) != 0)
					continue;
			}
			if (c == 'A') {
				/* get new name */
				mvaddstr(23, 0, "New name: ");
				getstring(Databuf, SZ_NAME);
				truncstring(Databuf);
				if (Databuf[0] != '\0')
					if (Wizard || findname(Databuf, &Other) < 0L)
						strcpy(playerp->p_name, Databuf);
			} else {
				/* get new password */
				if (!Wizard)
					Echo = FALSE;

				do {
					/* get two copies of new password until they match */
					/* get first copy */
					mvaddstr(23, 0, "New password ? ");
					getstring(Databuf, SZ_PASSWORD);
					if (Databuf[0] == '\0')
						break;

					/* get second copy */
					mvaddstr(23, 0, "One more time ? ");
					getstring(playerp->p_password, SZ_PASSWORD);
				} while (strcmp(playerp->p_password, Databuf) != 0);

				Echo = TRUE;
			}

			continue;

		case 'C':	/* change experience */
			prompt = "experience";
			dptr = &playerp->p_experience;
			goto DALTER;

		case 'D':	/* change level */
			prompt = "level";
			dptr = &playerp->p_level;
			goto DALTER;

		case 'E':	/* change strength */
			prompt = "strength";
			dptr = &playerp->p_strength;
			goto DALTER;

		case 'F':	/* change swords */
			prompt = "sword";
			dptr = &playerp->p_sword;
			goto DALTER;

		case 'G':	/* change energy */
			prompt = "energy";
			dptr = &playerp->p_energy;
			goto DALTER;

		case 'H':	/* change maximum energy */
			prompt = "max energy";
			dptr = &playerp->p_maxenergy;
			goto DALTER;

		case 'I':	/* change shields */
			prompt = "shield";
			dptr = &playerp->p_shield;
			goto DALTER;

		case 'J':	/* change quickness */
			prompt = "quickness";
			dptr = &playerp->p_quickness;
			goto DALTER;

		case 'K':	/* change quicksilver */
			prompt = "quicksilver";
			dptr = &playerp->p_quksilver;
			goto DALTER;

		case 'L':	/* change magic */
			prompt = "magic level";
			dptr = &playerp->p_magiclvl;
			goto DALTER;

		case 'M':	/* change mana */
			prompt = "mana";
			dptr = &playerp->p_mana;
			goto DALTER;

		case 'N':	/* change brains */
			prompt = "brains";
			dptr = &playerp->p_brains;
			goto DALTER;

		case 'O':	/* change poison */
			prompt = "poison";
			dptr = &playerp->p_poison;
			goto DALTER;

		case 'P':	/* change gold */
			prompt = "gold";
			dptr = &playerp->p_gold;
			goto DALTER;

		case 'Q':	/* change gems */
			prompt = "gems";
			dptr = &playerp->p_gems;
			goto DALTER;

		case 'R':	/* change sin */
			prompt = "sin";
			dptr = &playerp->p_sin;
			goto DALTER;

		case 'S':	/* change x coord */
			prompt = "x";
			dptr = &playerp->p_x;
			goto DALTER;

		case 'T':	/* change y coord */
			prompt = "y";
			dptr = &playerp->p_y;
			goto DALTER;

		case 'U':	/* change age */
			mvprintw(23, 0, "age = %ld; age = ", playerp->p_age);
			dtemp = infloat();
			if (dtemp != 0.0)
				playerp->p_age = (long)dtemp;
			continue;

		case 'V':	/* change degen */
			mvprintw(23, 0, "degen = %d; degen = ", playerp->p_degenerated);
			dtemp = infloat();
			if (dtemp != 0.0)
				playerp->p_degenerated = (int)dtemp;
			continue;

		case 'W':	/* change type */
			prompt = "type";
			sptr = &playerp->p_type;
			goto SALTER;

		case 'X':	/* change special type */
			prompt = "special type";
			sptr = &playerp->p_specialtype;
			goto SALTER;

		case 'Y':	/* change lives */
			prompt = "lives";
			sptr = &playerp->p_lives;
			goto SALTER;

		case 'Z':	/* change crowns */
			prompt = "crowns";
			sptr = &playerp->p_crowns;
			goto SALTER;

		case '0':	/* change charms */
			prompt = "charm";
			sptr = &playerp->p_charms;
			goto SALTER;

		case '1':	/* change amulet */
			prompt = "amulet";
			sptr = &playerp->p_amulets;
			goto SALTER;

		case '2':	/* change holy water */
			prompt = "holy water";
			sptr = &playerp->p_holywater;
			goto SALTER;

		case '3':	/* change last-used */
			prompt = "last-used";
			sptr = &playerp->p_lastused;
			goto SALTER;

		case '4':	/* change palantir */
			prompt = "palantir";
			bptr = &playerp->p_palantir;
			goto BALTER;

		case '5':	/* change blessing */
			prompt = "blessing";
			bptr = &playerp->p_blessing;
			goto BALTER;

		case '6':	/* change virgin */
			prompt = "virgin";
			bptr = &playerp->p_virgin;
			goto BALTER;

		case '7':	/* change blindness */
			prompt = "blindness";
			bptr = &playerp->p_blindness;
			goto BALTER;

		case '8':	/* change ring type */
			prompt = "ring-type";
			sptr = &playerp->p_ring.ring_type;
			goto SALTER;

		case '9':	/* change ring duration */
			prompt = "ring-duration";
			sptr = &playerp->p_ring.ring_duration;
			goto SALTER;

		case '!':	/* quit, update */
			if (Wizard &&
			    (!ingameflag || playerp != &Player)) {
				/* turn off status if not modifying self */
				playerp->p_status = S_OFF;
				playerp->p_tampered = T_OFF;
			}

			writerecord(playerp, loc);
			clear();
			return;

		case '?':	/* delete player */
			if (ingameflag && playerp == &Player)
				/* cannot delete self */
				continue;

			freerecord(playerp, loc);
			clear();
			return;

		default:
			continue;
		}
DALTER:
		mvprintw(23, 0, "%s = %f; %s = ", prompt, *dptr, prompt);
		dtemp = infloat();
		if (dtemp != 0.0)
			*dptr = dtemp;
		continue;

SALTER:
		mvprintw(23, 0, "%s = %d; %s = ", prompt, *sptr, prompt);
		dtemp = infloat();
		if (dtemp != 0.0)
			*sptr = (short)dtemp;
		continue;

BALTER:
		mvprintw(23, 0, "%s = %c; %s = ", prompt, flag[*bptr],
		    prompt);
		c = getanswer("\nTF", TRUE);
		if (c == 'T')
			*bptr = TRUE;
		else if (c == 'F')
			*bptr = FALSE;
		continue;
	}
}
Esempio n. 4
0
/**
 * Print a single package which:
 *  (a) is the target of one or more relevant predependencies.
 *  (b) has itself no unsatisfied pre-dependencies.
 *
 * If such a package is present output is the Packages file entry,
 * which can be massaged as appropriate.
 *
 * Exit status:
 *  0 = a package printed, OK
 *  1 = no suitable package available
 *  2 = error
 */
int
predeppackage(const char *const *argv)
{
  static struct varbuf vb;

  struct pkgiterator *it;
  struct pkginfo *pkg = NULL, *startpkg, *trypkg;
  struct dependency *dep;
  struct deppossi *possi, *provider;

  if (*argv)
    badusage(_("--%s takes no arguments"), cipaction->olong);

  modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
  /* We use clientdata->istobe to detect loops. */
  clear_istobes();

  dep = NULL;
  it = pkg_db_iter_new();
  while (!dep && (pkg = pkg_db_iter_next_pkg(it))) {
    /* Ignore packages user doesn't want. */
    if (pkg->want != PKG_WANT_INSTALL)
      continue;
    /* Ignore packages not available. */
    if (!pkg->files)
      continue;
    pkg->clientdata->istobe = PKG_ISTOBE_PREINSTALL;
    for (dep= pkg->available.depends; dep; dep= dep->next) {
      if (dep->type != dep_predepends) continue;
      if (depisok(dep, &vb, NULL, NULL, true))
        continue;
      /* This will leave dep non-NULL, and so exit the loop. */
      break;
    }
    pkg->clientdata->istobe = PKG_ISTOBE_NORMAL;
    /* If dep is NULL we go and get the next package. */
  }
  pkg_db_iter_free(it);

  if (!dep)
    return 1; /* Not found. */
  assert(pkg);
  startpkg= pkg;
  pkg->clientdata->istobe = PKG_ISTOBE_PREINSTALL;

  /* OK, we have found an unsatisfied predependency.
   * Now go and find the first thing we need to install, as a first step
   * towards satisfying it. */
  do {
    /* We search for a package which would satisfy dep, and put it in pkg. */
    for (possi = dep->list, pkg = NULL;
         !pkg && possi;
         possi=possi->next) {
      struct deppossi_pkg_iterator *possi_iter;

      possi_iter = deppossi_pkg_iter_new(possi, wpb_available);
      while (!pkg && (trypkg = deppossi_pkg_iter_next(possi_iter))) {
        if (trypkg->files &&
            trypkg->clientdata->istobe == PKG_ISTOBE_NORMAL &&
            versionsatisfied(&trypkg->available, possi)) {
          pkg = trypkg;
          break;
        }
        for (provider = possi->ed->depended.available;
             !pkg && provider;
             provider = provider->next) {
          if (provider->up->type != dep_provides)
            continue;
          if (!pkg_virtual_deppossi_satisfied(possi, provider))
            continue;
          trypkg = provider->up->up;
          if (!trypkg->files)
            continue;
          if (trypkg->clientdata->istobe == PKG_ISTOBE_NORMAL) {
            pkg = trypkg;
            break;
          }
        }
      }
      deppossi_pkg_iter_free(possi_iter);
    }
    if (!pkg) {
      varbuf_reset(&vb);
      describedepcon(&vb,dep);
      varbuf_end_str(&vb);
      notice(_("cannot see how to satisfy pre-dependency:\n %s"), vb.buf);
      ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to %.250s)"),
             pkgbin_name(dep->up, &dep->up->available, pnaw_nonambig),
             pkgbin_name(startpkg, &startpkg->available, pnaw_nonambig));
    }
    pkg->clientdata->istobe = PKG_ISTOBE_PREINSTALL;
    for (dep= pkg->available.depends; dep; dep= dep->next) {
      if (dep->type != dep_predepends) continue;
      if (depisok(dep, &vb, NULL, NULL, true))
        continue;
      /* This will leave dep non-NULL, and so exit the loop. */
      break;
    }
  } while (dep);

  /* OK, we've found it - pkg has no unsatisfied pre-dependencies! */
  writerecord(stdout, _("<standard output>"), pkg, &pkg->available);

  m_output(stdout, _("<standard output>"));

  return 0;
}
Esempio n. 5
0
int
main(int argc, char **argv)
{
	bool noheader = FALSE;	/* set if don't want header */
	bool headeronly = FALSE; /* set if only want header */
	bool examine = FALSE;	/* set if examine a character */
	time_t seconds;		/* for time of day */
	double dtemp;		/* for temporary calculations */

	initialstate();		/* init globals */

	/* process arguments */
	while (--argc && (*++argv)[0] == '-')
		switch ((*argv)[1]) {
		case 's':	/* short */
			noheader = TRUE;
			break;

		case 'H':	/* Header */
			headeronly = TRUE;
			break;

		case 'a':	/* all users */
			activelist();
			cleanup(TRUE);
			/* NOTREACHED */

		case 'p':	/* purge old players */
			purgeoldplayers();
			cleanup(TRUE);
			/* NOTREACHED */

		case 'S':	/* set 'Wizard' */
			Wizard = !getuid();
			break;

		case 'x':	/* examine */
			examine = TRUE;
			break;

		case 'm':	/* monsters */
			monstlist();
			cleanup(TRUE);
			/* NOTREACHED */

		case 'b':	/* scoreboard */
			scorelist();
			cleanup(TRUE);
			/* NOTREACHED */
		}

	if (!isatty(0))		/* don't let non-tty's play */
		cleanup(TRUE);
	/* NOTREACHED */

	playinit();		/* set up to catch signals, init curses */

	if (examine) {
		changestats(FALSE);
		cleanup(TRUE);
		/* NOTREACHED */
	}

	if (!noheader) {
		titlelist();
		purgeoldplayers();	/* clean up old characters */
	}

	if (headeronly)
		cleanup(TRUE);
	/* NOTREACHED */

	do {
		/* get the player structure filled */
		Fileloc = -1L;

		mvaddstr(22, 17, "Do you have a character to run [Q = Quit] ? ");

		switch (getanswer("NYQ", FALSE)) {
		case 'Y':
			Fileloc = recallplayer();
			break;

		case 'Q':
			cleanup(TRUE);
			/* NOTREACHED */

		default:
			Fileloc = rollnewplayer();
			break;
		}
		clear();
	} while (Fileloc < 0L);

	if (Player.p_level > 5.0)
		/* low level players have long timeout */
		Timeout = TRUE;

	/* update some important player statistics */
	strcpy(Player.p_login, Login);
	time(&seconds);
	Player.p_lastused = localtime(&seconds)->tm_yday;
	Player.p_status = S_PLAYING;
	writerecord(&Player, Fileloc);

	Statptr = &Stattable[Player.p_type];	/* initialize pointer */

	/* catch interrupts */
#ifdef  BSD41
	sigset(SIGINT, interrupt);
#endif
#ifdef  BSD42
	signal(SIGINT, interrupt);
#endif
#ifdef  SYS3
	signal(SIGINT, interrupt);
#endif
#ifdef  SYS5
	signal(SIGINT, interrupt);
#endif

	altercoordinates(Player.p_x, Player.p_y, A_FORCED);	/* set some flags */

	clear();

	for (;;) {
		/* loop forever, processing input */

		adjuststats();	/* cleanup stats */

		if (Throne && Player.p_crowns == 0 && Player.p_specialtype != SC_KING) {
			/* not allowed on throne -- move */
			mvaddstr(5, 0, "You're not allowed in the Lord's Chamber without a crown.\n");
			altercoordinates(0.0, 0.0, A_NEAR);
		}

		checktampered();	/* check for energy voids, etc. */

		if (Player.p_status != S_CLOAKED
		/* not cloaked */
		    && (dtemp = fabs(Player.p_x)) == fabs(Player.p_y)
		/* |x| = |y| */
		    && !Throne) {
			/* not on throne */
			dtemp = sqrt(dtemp / 100.0);
			if (floor(dtemp) == dtemp) {
				/* |x| / 100 == n*n; at a trading post */
				tradingpost();
				clear();
			}
		}

		checkbattle();	/* check for player to player battle */
		neatstuff();	/* gurus, medics, etc. */

		if (Player.p_status == S_CLOAKED) {
			/* costs 3 mana per turn to be cloaked */
			if (Player.p_mana > 3.0)
				Player.p_mana -= 3.0;
			else {
				/* ran out of mana, uncloak */
				Player.p_status = S_PLAYING;
				Changed = TRUE;
			}
		}

		if (Player.p_status != S_PLAYING && Player.p_status != S_CLOAKED) {
			/* change status back to S_PLAYING */
			Player.p_status = S_PLAYING;
			Changed = TRUE;
		}

		if (Changed) {
			/* update file only if important stuff has changed */
			writerecord(&Player, Fileloc);
			Changed = FALSE;
			continue;
		}

		readmessage();	/* read message, if any */

		displaystats();	/* print statistics */

		move(6, 0);

		if (Throne)
			/* maybe make king, print prompt, etc. */
			throneroom();

		/* print status line */
		addstr("1:Move  2:Players  3:Talk  4:Stats  5:Quit  ");
		if (Player.p_level >= MEL_CLOAK && Player.p_magiclvl >= ML_CLOAK)
			addstr("6:Cloak  ");
		if (Player.p_level >= MEL_TELEPORT && Player.p_magiclvl >= ML_TELEPORT)
			addstr("7:Teleport  ");
		if (Player.p_specialtype >= SC_COUNCIL || Wizard)
			addstr("8:Intervene  ");

		procmain();	/* process input */
	}
}