-
Notifications
You must be signed in to change notification settings - Fork 1
/
db.h
165 lines (127 loc) · 5.05 KB
/
db.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* ************************************************************************
* file: db.h , Database module. Part of DIKUMUD *
* Usage: Loading/Saving chars booting world. *
************************************************************************* */
/* data files used by the game system */
#define DFLT_DIR "lib" /* default data directory */
#define WORLD_FILE "tinyworld.wld" /* room definitions */
#define MOB_FILE "tinyworld.mob" /* monster prototypes */
#define OBJ_FILE "tinyworld.obj" /* object prototypes */
#define ZONE_FILE "tinyworld.zon" /* zone defs & command tables */
#define CREDITS_FILE "credits" /* for the 'credits' command */
#define NEWS_FILE "news" /* for the 'news' command */
#define MOTD_FILE "motd" /* messages of today */
#define PLAYER_FILE "players" /* the player database */
#define TIME_FILE "time" /* game calendar information */
#define IDEA_FILE "ideas" /* for the 'idea'-command */
#define TYPO_FILE "typos" /* 'typo' */
#define BUG_FILE "bugs" /* 'bug' */
#define MESS_FILE "messages" /* damage message */
#define SOCMESS_FILE "actions" /* messgs for social acts */
#define HELP_KWRD_FILE "help_table" /* for HELP <keywrd> */
#define HELP_PAGE_FILE "help" /* for HELP <CR> */
#define INFO_FILE "info" /* for INFO */
#define WIZLIST_FILE "wizlist" /* for WIZLIST */
#define POSEMESS_FILE "poses" /* for 'pose'-command */
/* public procedures in db.c */
void boot_db(void);
void save_char(struct char_data *ch, sh_int load_room);
int create_entry(char *name);
void zone_update(void);
void init_char(struct char_data *ch);
void clear_char(struct char_data *ch);
void clear_object(struct obj_data *obj);
void reset_char(struct char_data *ch);
void free_char(struct char_data *ch);
int real_room(int virtual);
char *fread_string(FILE *fl);
int real_object(int virtual);
int real_mobile(int virtual);
#define REAL 0
#define VIRTUAL 1
struct obj_data *read_object(int nr, int type);
struct char_data *read_mobile(int nr, int type);
#define MENU \
"\n\rWelcome to DikuMUD\n\r\n\
0) Exit from DikuMud.\n\r\
1) Enter the game.\n\r\
2) Enter description.\n\r\
3) Read the background story\n\r\
4) Change password.\n\r\n\r\
Make your choice: "
#define GREETINGS \
"\n\r\n\r \
DikuMUD I (GAMMA 0.0)\n\r\n\r \
Created by\n\r \
Hans Henrik Staerfeldt, Katja Nyboe,\n\r \
Tom Madsen, Michael Seifert, and Sebastian Hammer\n\r\n\r"
#define WELC_MESSG \
"\n\rWelcome to the land of DikuMUD. May your visit here be... Interesting.\
\n\r\n\r"
#define STORY \
"This will soon be the background story of DIKU-MUD.\n\r\n\r"
/* structure for the reset commands */
struct reset_com
{
char command; /* current command */
bool if_flag; /* if TRUE: exe only if preceding exe'd */
int arg1; /* */
int arg2; /* Arguments to the command */
int arg3; /* */
/*
* Commands: *
* 'M': Read a mobile *
* 'O': Read an object *
* 'G': Give obj to mob *
* 'P': Put obj in obj *
* 'G': Obj to char *
* 'E': Obj to char equip *
* 'D': Set state of door *
*/
};
/* zone definition structure. for the 'zone-table' */
struct zone_data
{
char *name; /* name of this zone */
int lifespan; /* how long between resets (minutes) */
int age; /* current age of this zone (minutes) */
int top; /* upper limit for rooms in this zone */
int reset_mode; /* conditions for reset (see below) */
struct reset_com *cmd; /* command table for reset */
/*
* Reset mode: *
* 0: Don't reset, and don't update age. *
* 1: Reset if no PC's are located in zone. *
* 2: Just reset. *
*/
};
/* element in monster and object index-tables */
struct index_data
{
int virtual; /* virtual number of this mob/obj */
long pos; /* file position of this field */
int number; /* number of existing units of this mob/obj */
int (*func)(); /* special procedure for this mob/obj */
};
/* for queueing zones for update */
struct reset_q_element
{
int zone_to_reset; /* ref to zone_data */
struct reset_q_element *next;
};
/* structure for the update queue */
struct reset_q_type
{
struct reset_q_element *head;
struct reset_q_element *tail;
} reset_q;
struct player_index_element
{
char *name;
int nr;
};
struct help_index_element
{
char *keyword;
long pos;
};