Mercurial > hg > early-roguelike
annotate rogue4/command.c @ 229:50b89f165a34
Use uniform return types for functions related to options.
Functions for printing options now return void. Functions for setting
options now return int. Argument types still vary, though converting
all the option pointers to void* would be possible.
author | John "Elwin" Edwards |
---|---|
date | Sun, 06 Mar 2016 14:45:18 -0500 |
parents | 1b73a8641b37 |
children | e52a8a7ad4c5 |
rev | line source |
---|---|
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
1 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
2 * Read and execute the user commands |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
3 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
4 * @(#)command.c 4.31 (Berkeley) 4/6/82 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
5 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
8 * All rights reserved. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
9 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
11 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
12 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
13 #include <stdlib.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
14 #include <curses.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 #include <ctype.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 #include <stdlib.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
17 #include <string.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
18 #include "rogue.h" |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 char countch, direction, newcount = FALSE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 |
215 | 22 void call(void); |
23 void d_level(void); | |
24 void help(void); | |
25 void identify(void); | |
26 void illcom(char ch); | |
27 void search(void); | |
28 void u_level(void); | |
29 | |
30 #ifdef WIZARD | |
31 extern void add_pass(void); | |
32 extern void create_obj(void); | |
33 extern bool passwd(void); | |
34 extern void show_map(void); | |
35 #endif | |
36 | |
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 * command: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 * Process the user commands |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
40 */ |
215 | 41 void |
42 command(void) | |
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 register char ch; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 register int ntimes = 1; /* Number of player moves */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 if (on(player, ISHASTE)) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
48 ntimes++; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
49 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
50 * Let the daemons start up |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
51 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
52 do_daemons(BEFORE); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
53 do_fuses(BEFORE); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
54 while (ntimes--) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 * these are illegal things for the player to be, so if any are |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 * set, someone's been poking in memeory |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
59 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
60 if (on(player, ISSLOW|ISCANC|ISGREED|ISINVIS|ISMEAN|ISREGEN)) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 auto_save(-1); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
63 look(TRUE); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 if (!running) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
65 door_stop = FALSE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
66 status(); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
67 lastscore = purse; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
68 move(hero.y, hero.x); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
69 if (!((running || count) && jump)) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
70 refresh(); /* Draw screen */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
71 take = 0; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
72 after = TRUE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
73 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
74 * Read command or continue run |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
75 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
76 #ifdef WIZARD |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
77 if (wizard) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
78 noscore = TRUE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
79 #endif |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
80 if (!no_command) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
81 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
82 if (running) ch = runch; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
83 else if (count) ch = countch; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
84 else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
85 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
86 ch = readchar(); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
87 if (mpos != 0 && !running) /* Erase message if its there */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 msg(""); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
89 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
90 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
92 ch = '.'; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
93 if (no_command) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
94 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
95 if (--no_command == 0) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
96 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
97 msg("you can move again"); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
98 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
100 else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
101 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|