Mercurial > hg > early-roguelike
view arogue5/command.c @ 88:07c4d4883ef2
rogue3: begin porting to autoconf.
Rogue V3 can now be built with './configure && make'. This is
preliminary: 'make install' does not work yet.
| author | John "Elwin" Edwards |
|---|---|
| date | Sat, 24 Aug 2013 13:36:13 -0700 |
| parents | ad2cb9a07aaa |
| children | dfeed24bb616 |
line wrap: on
line source
/* * Read and execute the user commands * * 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 <stdlib.h> #include <string.h> #include <limits.h> #include <ctype.h> #include <signal.h> #include "mach_dep.h" #include "rogue.h" /* * command: * Process the user commands */ command() { register char ch; register int ntimes = 1; /* Number of player moves */ static char countch, direction, newcount = FALSE; struct linked_list *item; bool an_after = FALSE; if (on(player, ISHASTE)) { ntimes++; turns--; /* correct for later */ } if (on(player, ISSLOW) || on(player, ISDANCE)) { if (player.t_turn != TRUE) { ntimes--; turns++; an_after = TRUE; } player.t_turn ^= TRUE; } /* * Let the daemons start up */ do_daemons(BEFORE); do_fuses(BEFORE); while (ntimes-- > 0) { /* One more tick of the clock. */ if ((++turns % DAYLENGTH) == 0) { daytime ^= TRUE; if (levtype == OUTSIDE) { if (daytime) msg("The sun rises above the horizon"); else msg("The sun sinks below the horizon"); } light(&hero); } look(after, FALSE); if (!running) door_stop = FALSE; lastscore = purse; wmove(cw, hero.y, hero.x); if (!((running || count) && jump)) { status(FALSE); wmove(cw, hero.y, hero.x); draw(cw); /* Draw screen */ } take = 0; after = TRUE; /* * Read command or continue run */ if (!no_command) { if (running) { /* If in a corridor or maze, if we are at a turn with only one * way to go, turn that way. */ if ((winat(hero.y, hero.x) == PASSAGE || 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 = readchar(); if (mpos != 0 && !running) /* Erase message if its there */ msg(""); } } else ch = '.'; if (no_command) { if (--no_command == 0) msg("You can move again."); } else { /* * check for prefixes */ if (isdigit(ch)) { count = 0; newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); if (count > 255) count = 255; ch = readchar(); } 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 'q': case 'r': case 's': case 'f': case 't': case 'C': case 'I': case '.': case 'z': case 'p': 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': case 'H': case 'J': case 'K': case 'L': case 'Y': case 'U': case 'B': case 'N': runch = tolower(ch); } /* Perform the action */ switch (ch) { case 'f': if (!on(player, ISBLIND)) { door_stop = TRUE; firstmove = TRUE; } if (count && !newcount) ch = direction; else ch = readchar(); switch (ch) { case 'h': case 'j': case 'k': case 'l': case 'y': case 'u': case 'b': case 'n': ch = toupper(ch); } direction = ch; } newcount = FALSE; /* * execute a command */ if (count && !running) count--; switch (ch) { case '!' : shell(); when 'h' : do_move(0, -1);
