Mercurial > hg > early-roguelike
view xrogue/command.c @ 175:10c273a62228
srogue: remove md_droppriv() and md_resetpriv().
These partial privilege-dropping functions are no longer needed.
author | John "Elwin" Edwards |
---|---|
date | Sat, 01 Aug 2015 16:31:03 -0400 |
parents | a0a57cf42810 |
children | f54901b9c39b |
line wrap: on
line source
/* command.c - Read and execute the user commands XRogue: Expeditions into the Dungeons of Doom Copyright (C) 1991 Robert Pietkivitch All rights reserved. Based on "Advanced Rogue" Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T All rights reserved. Based on "Rogue: Exploring the Dungeons of Doom" Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman All rights reserved. See the file LICENSE.TXT for full copyright and licensing information. */ #include <curses.h> #include <ctype.h> #include <signal.h> #include <stdlib.h> #include <string.h> #include "mach_dep.h" #include "rogue.h" /* * command: * Process the user commands */ command() { unsigned int ch; struct linked_list *item; unsigned int countch = 0, direction = 0, newcount = FALSE; int segment = 1; int monst_limit, monst_current; monst_limit = monst_current = 1; while (playing) { /* * Let the daemons start up, but only do them once a round * (round = 10 segments). */ if (segment >= 10) { do_daemons(BEFORE); do_fuses(BEFORE); } after = TRUE; do { /* One more tick of the clock. */ if (segment >= 10 && after && (++turns % DAYLENGTH) == 0) { daytime ^= TRUE; if (levtype == OUTSIDE) { if (daytime) msg("A bright star flares above the horizon."); else msg("The bright star travels beyond the horizon."); } light(&hero); } /* * Don't bother with these updates unless the player's going * to do something. */ if (player.t_action == A_NIL && player.t_no_move <= 1) { look(after, FALSE); lastscore = purse; wmove(cw, hero.y, hero.x); if (!((running || count) && jump)) { status(FALSE); } } /* Draw the screen */ if (!((running || count) && jump)) { wmove(cw, hero.y, hero.x); draw(cw); } after = TRUE; /* * Read command or continue run */ if (--player.t_no_move <= 0) { take = 0; /* Nothing here to start with */ player.t_no_move = 0; /* Be sure we don't go too negative */ if (!running) door_stop = FALSE; /* Was the player being held? */ if (player.t_action == A_FREEZE) { player.t_action = A_NIL; msg("You can move again."); } if (player.t_action != A_NIL) ch = player.t_action; else if (running) { char scratch; /* If in a corridor or maze, if we are at a turn with * only one way to go, turn that way. */ scratch = winat(hero.y, hero.x); if ((scratch==PASSAGE||scratch==DOOR||levtype==MAZELEV) && off(player, ISHUH) && off(player, ISBLIND)) { int y, x; if (getdelta(runch, &y, &x) == TRUE) { corr_move(y, x); } } ch = runch; } else if (count) ch = countch; else { ch = wgetch(cw); if (mpos != 0 && !running) /* Erase message if its there */ msg(""); } /* * check for prefixes */ if (isascii(ch) && isdigit(ch)) { count = 0; newcount = TRUE; while (isascii(ch) && isdigit(ch)) { count = count * 10 + (ch - '0'); ch = wgetch(cw); } countch = ch; /* * turn off count for commands which don't make sense * to repeat */ switch (ch) { case 'h': case 'j': case 'k': case 'l': case 'y': case 'u': case 'b': case 'n': case 'H': case 'J': case 'K': case 'L': case 'Y': case 'U': case 'B': case 'N': case C_SEARCH: case '.': break; default: count = 0; } } /* Save current direction */ if (!running) { /* If running, it is already saved */ switch (ch) { case 'h': case 'j': case 'k': case 'l': case 'y': case 'u': case 'b': case 'n':