home · contact · privacy
Use command IDs from command DB as what is recorded in record file.
[plomrogue] / src / command_db.h
1 /* command.h
2  *
3  * The Command DB collects all commands the user can give. It only contains
4  * identifiers and descriptions of commands, not the functions executing these
5  * commands. Coupling with those happens elsewhere.
6  */
7
8 #ifndef COMMAND_DB_H
9 #define COMMAND_DB_H
10
11
12
13 #include <stdint.h> /* for uint8_t */
14 struct World;
15
16
17
18 struct Command
19 {
20     uint8_t id;       /* unique identifier of command */
21     char * dsc_short; /* short string name of command to be used internally */
22     char * dsc_long;  /* long string description of command for the  user */
23 };
24
25 struct CommandDB
26 {
27     uint8_t n;             /* number of Command structs in database*/
28     struct Command * cmds; /* pointer to first Command struct in database */
29 };
30
31
32
33 /* Is "id" the ID of command whose dsc_short is "shortdsc"? Answer in binary. */
34 extern uint8_t is_command_id_shortdsc(struct World * world,
35                                       uint8_t id, char * shortdsc);
36
37 /* Give short description of command ("dsc_short"), get its ID. */
38 extern uint8_t get_command_id(struct World * world, char * dsc_short);
39
40 /* Give short description of command ("dsc_short"), get long description. */
41 extern char * get_command_longdsc(struct World * world, char * dsc_short);
42
43
44
45 /* Read in CommandDB from file "config/commands" to world.cmd_db. */
46 extern void init_command_db(struct World * world);
47
48 /* Free all memory allocated with init_command_db. */
49 extern void free_command_db(struct World * world);
50
51
52
53 #endif