home · contact · privacy
Commands are now to be managed by a Command DB, not by passing around arbitrary strings.
[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 /* Give short description of command ("dsc_short"), get long descrption. */
34 extern char * get_command_longdsc(struct World * world, char * dsc_short);
35
36
37
38 /* Read in CommandDB from file "config/commands" to world.cmd_db. */
39 extern void init_command_db(struct World * world);
40
41
42
43 /* Free all memory allocated with init_command_db. */
44 extern void free_command_db(struct World * world);
45
46
47
48 #endif