-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.h
554 lines (484 loc) · 17.1 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/*
* ************************************************************************
* File: db.h Part of CircleMUD *
* Usage: header file for database handling * *
*
* All rights reserved. See license.doc for complete information. * *
*
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
***********************************************************************
*/
#ifndef DB_H
#define DB_H
/* arbitrary constants used by index_boot() (must be unique) */
#define DB_BOOT_WLD 0
#define DB_BOOT_MOB 1
#define DB_BOOT_OBJ 2
#define DB_BOOT_ZON 3
#define DB_BOOT_SHP 4
#define DB_BOOT_HLP 5
#define DB_BOOT_TRG 6
#if defined(CIRCLE_MACINTOSH)
#define LIB_WORLD ":world:"
#define LIB_TEXT ":text:"
#define LIB_TEXT_HELP ":text:help:"
#define LIB_MISC ":misc:"
#define LIB_ETC ":etc:"
#define LIB_PLRTEXT ":plrtext:"
#define LIB_PLROBJS ":plrobjs:"
#define LIB_PLRALIAS ":plralias:"
#define LIB_HOUSE ":house:"
#define LIB_PLRVARS ":plrvars:"
#define SLASH ":"
#define LIB_PLRALIAS ":plralias:"
#define LIB_PLRPOOFS ":plrpoofs:"
#define LIB_PLRSHOPS ":plrshops:"
#define LIB_CRASHPROOF ":crashproof:"
#define LIB_QUESTCARDS ":questcards:"
#define LIB_EXPLORED ":explored:"
#elif defined(CIRCLE_AMIGA) || defined(CIRCLE_UNIX) || defined(CIRCLE_WINDOWS) || defined(CIRCLE_ACORN)
#define LIB_WORLD "world/"
#define LIB_TEXT "text/"
#define LIB_TEXT_HELP "text/help/"
#define LIB_MISC "misc/"
#define LIB_ETC "etc/"
#define LIB_PLRTEXT "plrtext/"
#define LIB_PLROBJS "plrobjs/"
#define LIB_HOUSE "house/"
#define LIB_PLRVARS "plrvars/"
#define SLASH "/"
#define LIB_PLRALIAS "plralias/"
#define LIB_PLRPOOFS "plrpoofs/"
#define LIB_PLRSHOPS "plrshops/"
#define LIB_CRASHPROOF "crashproof/"
#define LIB_QUESTCARDS "questcards/"
#define LIB_EXPLORED "explored/"
#else
#error "Unknown path components."
#endif
#define ARTI_DIR LIB_MISC"arti/"
#define ZON_SUFFIX ".zon"
#define MOB_SUFFIX ".mob"
#define OBJ_SUFFIX ".obj"
#define WLD_SUFFIX ".wld"
#define SHP_SUFFIX ".shp"
#define TRG_SUFFIX ".trg"
#define SUF_OBJS "objs"
#define SUF_TEXT "text"
#define SUF_ALIAS "alias"
#define SUF_POOFS "poofs"
#define SUF_MEM "mem"
#define SUF_IGNORE "ignore"
#if defined(CIRCLE_AMIGA)
#define FASTBOOT_FILE "/.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "/.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "/pause" /* autorun: don't restart mud */
#elif defined(CIRCLE_MACINTOSH)
#define FASTBOOT_FILE "::.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "::.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "::pause" /* autorun: don't restart mud */
#else
#define FASTBOOT_FILE "../.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "../.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "../pause" /* autorun: don't restart mud */
#endif
/* names of various files and directories */
#define INDEX_FILE "index" /* index of world files */
#define MINDEX_FILE "index.mini" /* ... and for mini-mud-mode */
#if 0
#define WLD_PREFIX LIB_WORLD "wld" SLASH /* room definitions */
#define MOB_PREFIX LIB_WORLD "mob" SLASH /* monster prototypes */
#define OBJ_PREFIX LIB_WORLD "obj" SLASH /* object prototypes */
#define ZON_PREFIX LIB_WORLD "zon" SLASH /* zon defs & command tables */
#define SHP_PREFIX LIB_WORLD "shp" SLASH /* shop definitions */
#define TRG_PREFIX LIB_WORLD "trg" SLASH /* shop definitions */
#endif
#define HLP_PREFIX LIB_TEXT "help" SLASH /* for HELP <keyword> */
#define HELP_FILE "help.hlp" /* help file */
#define STARTUP_FILE LIB_TEXT "startup" /* startup screen */
#define CREDITS_FILE LIB_TEXT "credits" /* for the 'credits' command */
#define NEWS_FILE LIB_TEXT "news" /* for the 'news' command */
#define MOTD_FILE LIB_TEXT "motd" /* messages of the day / mortal */
#define IMOTD_FILE LIB_TEXT "imotd" /* messages of the day / immort */
#define GREETINGS_FILE LIB_TEXT "greetings" /* The opening screen. */
#define HELP_PAGE_FILE LIB_TEXT_HELP "screen" /* for HELP <CR> */
#define INFO_FILE LIB_TEXT "info" /* for INFO */
#define WIZLIST_FILE LIB_TEXT "wizlist" /* for WIZLIST */
#define IMMLIST_FILE LIB_TEXT "immlist" /* for IMMLIST */
#define BACKGROUND_FILE LIB_TEXT "background" /* for the background story */
#define POLICIES_FILE LIB_TEXT "policies" /* player policies/rules */
#define HANDBOOK_FILE LIB_TEXT "handbook" /* handbook for new immorts */
#define CONTEXT_HELP_FILE LIB_TEXT "contexthelp" /* context help for olc */
#define VEHICLE_FILE LIB_TEXT "vehicles"
#define PLRSHOP_OWNERS_FILE LIB_PLRSHOPS "playershops"
//#define IDEA_FILE LIB_MISC"ideas"
//#define TYPO_FILE LIB_MISC"typos"
//#define BUG_FILE LIB_MISC"bugs"
#define IDEA_FILE "/home/game/site/mud/ideas.html"
#define TYPO_FILE "/home/game/site/mud/typos.html"
#define BUG_FILE "/home/game/site/mud/bugs.html"
#define TIME_FILE LIB_MISC "time" /* time file for saving time */
#define HOST_LIST_FILE LIB_MISC "host_list" /* host lists file for meta server */
#define MESS_FILE LIB_MISC "messages" /* damage messages */
#define SOCMESS_FILE_NEW LIB_MISC "socials" /* messgs for social acts */
#define SOCMESS_FILE LIB_MISC "socials" /* messages for social acts */
#define XNAME_FILE LIB_MISC "xnames" /* invalid name substrings */
#define FOREST_FILE LIB_MISC "forest"
#define TP_FILE LIB_MISC "tradepoints" /* Tradepoints File */
#define GOLD_FILE LIB_MISC "gold_count" /* File for tallying Gold across days */
#define CONFIG_FILE LIB_ETC "config" /* OasisOLC * GAME CONFIG FL */
#define PLAYER_FILE LIB_ETC "players" /* the player database */
#define MAIL_FILE LIB_ETC "plrmail" /* for the mudmail system */
#define NOTE_FILE LIB_ETC "plrnotes.txt"
#define IDEAS_FILE LIB_ETC "plrideas.txt"
#define NEWSNOTE_FILE LIB_ETC "plrnews.txt"
#define PENALTY_FILE LIB_ETC "plrpenalty.txt"
#define CHANGES_FILE LIB_ETC "plrchanges.txt"
#define BAN_FILE LIB_ETC "badsites" /* for the siteban system */
#define HCONTROL_FILE LIB_ETC "hcontrol" /* for the house system */
#define CLAN_FILE LIB_ETC "clans" /* clan file */
#define QIC_FILE LIB_ETC "qicdb" /* qic database */
#define CLAN_DIR LIB_ETC "/clan/"
#define CLAN_INDEX_FILE CLAN_DIR "clan_index"
#define ASSEMBLIES_FILE LIB_ETC "assemblies" /* Assemblies engine */
#define PLR_PREFIX "pfiles"
#define BACKUP_PREFIX "pfiles/backup"
#define PLR_INDEX_FILE "pfiles/plr_index"
#define SLASH "/"
#define PLR_SUFFIX ""
#define PINDEX_DELETED (1 << 0)
#define PINDEX_NODELETE (1 << 1)
#define PINDEX_SELFDELETE (1 << 2)
#define PINDEX_FIXSKILLS (1 << 3)
#define NOTE_NOTE 0
#define NOTE_IDEA 1
#define NOTE_PENALTY 2
#define NOTE_NEWS 3
#define NOTE_CHANGES 4
//#define NO_EXTRANEOUS_TRIGGERS TRUE
#define DG_ALLOW_GODS TRUE
//#define R_EXIT(r, rdir) ((r)->dir_option[(rdir)])
#define USE_CREATE_CHAR 0
#define MAX_HELPENTRY_LENGTH 32384
extern NOTE_DATA *note_list;
extern NOTE_DATA *idea_list;
extern NOTE_DATA *penalty_list;
extern NOTE_DATA *news_list;
extern NOTE_DATA *changes_list;
extern int TEMP_LOAD_CHAR;
/* public procedures in db.c */
float bytesToSize(int by);
const char *bytesToUnit(int b);
void boot_db(void);
void destroy_db(void);
//mord ? ?
void zone_update(void);
room_rnum real_room(room_vnum vnum);
char *fread_string(FILE * fl, const char *error);
string *fread_string_s(FILE *fl, const char *error);
void save_mud_time(struct time_info_data *when);
//mord ? ?
void free_text_files(void);
//mord ? ?
zone_rnum real_zone(zone_vnum vnum);
//mord
room_rnum real_room(room_vnum vnum);
//mord
mob_rnum real_mobile(mob_vnum vnum);
//mord
obj_rnum real_object(obj_vnum vnum);
//mord
bitvector_t asciiflag_conv(char *flag);
void sprintbits(int data, char *dest);
void half_chop(char *string, char *arg1, char *arg2);
void char_to_store(Character *ch);
int store_to_char(const char *name, Character *ch);
#if USE_CREATE_CHAR
Character *create_char(void);
#endif
Character *read_mobile(mob_vnum nr);
int vnum_mobile(char *searchname, Character *ch);
struct obj_data *create_obj(obj_rnum proto);
void clear_object(struct obj_data *obj);
void free_obj(struct obj_data *obj, int extracted);
void obj_data_to_pool(struct obj_data *obj);
void free_obj_q(struct obj_data *obj);
void free_obj_q_delayed(struct obj_data *obj);
void free_obj_forget(struct obj_data *obj);
struct obj_data *read_object(obj_vnum nr, int type);
int vnum_object(char *searchname, Character *ch, int type);
int my_obj_save_to_disk(FILE * fp, struct obj_data *obj, int locate);
bool str_prefix( const char *astr, const char *bstr );
void fixskills(Character *ch);
/*
* Read a letter from a file.
*/
char fread_letter( FILE *fp );
int interpolate( int level, int value_00, int value_32 );
long number_mm( void );
int number_door( void );
int number_percent( void );
char *fread_word( FILE *fp );
int fread_number( FILE *fp );
extern int sunlight; /* What state the sun is at */
extern int OBJ_INNATE;
extern int OBJ_INNATE_MESSAGE;
#define REAL 0
#define VIRTUAL 1
/* 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; /* */
int arg4;
int line; /* line number this command appears on */
char *sarg1; /* string argument */
char *sarg2; /* string argument */
/*
* 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 * 'T': Trigger command *
*/
char SetCommand(char c) {
command = c;
return command;
}
reset_com() :
command(0),
if_flag(0),
arg1(0),
arg2(0),
arg3(0),
arg4(0),
line(0),
sarg1(NULL),
sarg2(NULL) {}
~reset_com() {
/* first see if any vars were defined in this zone */
if (command == 'V') {
if (sarg1)
free(sarg1);
if (sarg2)
free(sarg2);
}
}
};
/* zone definition structure. for the 'zone-table' */
class Zone {
public:
char *name; /* name of this zone */
int lifespan; /* how long between resets (minutes) */
int age; /* current age of this zone (minutes) */
room_vnum bot; /* starting room number for this zone */
room_vnum top; /* upper limit for rooms in this zone */
int dimension;
int num_players; /* how many players are in this zone currently? */
int reset_mode; /* conditions for reset (see below) */
zone_vnum number; /* virtual number of this zone */
vector<reset_com> cmd; /* command table for reset */
int pressure; /* How is the pressure (Mb) */
int change; /* How fast and what way does it change */
int sky; /* How is the sky */
char *builders; /* for OLC. OBuild like extention, *
* part of OLC+ */
long zone_flags; /* Zone Flags */
int idle_time; /* How long has it been idle */
int write_zone();
room_vnum Bot() {
return bot;
}
room_vnum Top() {
return top;
}
/*
* Reset mode: * 0: Don't reset, and
* don't update age. * 1: Reset if no PC's are located in zone. *
* 2: Just reset. *
*/
Zone() {
name =NULL;
lifespan = 30;
age = 0;
bot = 0;
top = 99;
dimension = D_ALL;
reset_mode = 2;
number = NOWHERE;
pressure = 1021;
change = 1;
sky = SKY_CLOUDLESS;
builders = NULL;
zone_flags = 0;
idle_time = 0;
num_players = 0;
}
Zone(const char * n, zone_vnum vn, room_vnum b, room_vnum t) {
name =NULL;
lifespan = 30;
age = 0;
bot = 0;
top = 99;
dimension = D_ALL;
reset_mode = 2;
number = NOWHERE;
pressure = 1021;
change = 1;
sky = SKY_CLOUDLESS;
builders = NULL;
zone_flags = 0;
idle_time = 0;
/* now set these */
bot=b;
top = t;
number = vn;
if (n)
name = strdup(n);
reset_com rc = reset_com();
rc.command = 'S';
cmd.push_back(rc);
num_players = 0;
}
void Destroy() {
if (this->name != NULL)
free(this->name);
this->name = NULL;
if (this->builders != NULL)
free(this->builders);
this->builders = NULL;
}
~Zone() {}
}
;
/** genzon.c - at the bottom - Mord**/
/** Zone compare **/
bool operator< (const Zone &a,const Zone &b);
bool operator> (const Zone &a,const Zone &b);
bool operator== (const Zone &a,const Zone &b);
/** zone data to int compare **/
bool operator< (const Zone &z,const zone_vnum b);
bool operator> (const Zone &z,const zone_vnum b);
bool operator== (const Zone &z,const zone_vnum b);
/* Bitvector for 'zone flags' */
#define Z_IDLE (1 << 0) /* Idle zone flag */
#define Z_SYSTEM (1 << 1) /* A zone that should not be idled */
/* for queueing zones for update */
struct reset_q_element {
zone_rnum zone_to_reset; /* ref to Zone */
struct reset_q_element *next;
reset_q_element() {
zone_to_reset=0;
next=NULL;
}
}
;
/* structure for the update queue */
struct reset_q_type {
struct reset_q_element *head;
struct reset_q_element *tail;
reset_q_type() {
head=NULL;
tail = NULL;
}
}
;
struct help_index_element {
char *keywords;
char *entry;
int min_level;
int duplicate;
int id;
int entries; /* How many key words there are */
help_index_element() :
keywords(NULL),
entry(NULL),
min_level(0),
duplicate(0),
id(0),
entries(0) {}
}
;
void the_free_help(void);
void free_help(struct help_index_element *help);
extern unsigned int top_of_helpt;
/* don't change these */
#define BAN_NOT 0
#define BAN_NEW 1
#define BAN_SELECT 2
#define BAN_ALL 3
#define BAN_NAME 4
#define BANNED_SITE_LENGTH 50
struct ban_list_element {
char site[BANNED_SITE_LENGTH + 1];
int type;
time_t date;
char name[MAX_NAME_LENGTH + 1];
struct ban_list_element *next;
};
/* global buffering system */
#ifndef __DB_C__
extern struct config_data config_info;
extern int top_of_world;
extern player_special_data dummy_mob;
extern struct social_messg *soc_mess_list;
extern int top_of_socialt;
extern obj_rnum top_of_objt;
//extern mob_rnum top_of_mobt;
extern zone_rnum top_of_zone_table;
extern map<mob_vnum, struct index_data*> mob_index;
extern map<obj_rnum, struct index_data> obj_index;
extern struct shop_data *shop_index;
extern int top_shop;
extern index_data **trig_index;
extern struct trig_data *trigger_list;
extern unsigned int top_of_trigt;
extern long max_mob_id;
extern long max_obj_id;
extern int dg_owner_purged;
extern vector <Room *> world_vnum;
//extern map<mob_vnum, Character *> mob_proto;
extern map<obj_rnum, struct obj_data> obj_proto;
//extern Zone *zone_table;
extern vector <Zone> zone_table;
#endif /* __DB_C__ */
extern Descriptor *descriptor_list;
extern Character *character_list;
typedef map<long, obj_data *> obj_list_type;
typedef obj_list_type::iterator olt_it;
//extern struct htree_node *mob_htree;
//extern struct htree_node *obj_htree;
extern map<obj_vnum,obj_rnum> obj_vTor;
extern obj_list_type object_list;
extern obj_list_type dead_obj; /* delayed obj removal */
void strip_string(char *buffer);
int read_xap_objects(FILE * fl, Character *ch);
float mob_hitpoint_multi(int chclass);
void generate_weapon(OBJ_DATA *obj);
void add_char_to_list(Character *ch);
void clearAllZones();
#define CUR_WORLD_VERSION 1
#define CUR_ZONE_VERSION 3
#define HIGHEST_VNUM 99900
#define MAX_WORLD 99900
typedef list <Character*> CharacterList;
typedef CharacterList::iterator CharacterListIterator;
typedef list <Descriptor*> DescriptorList;
typedef DescriptorList::iterator DescriptorListIterator;
typedef vector <Room *>::iterator WorldIterator;
typedef map<mob_vnum, Character *>::iterator mp_iter;
typedef map<mob_vnum, struct index_data *>::iterator mi_iter;
bool MobProtoExists(mob_vnum nv);
Character * GetMobProto(mob_vnum vn);
void SetMobProto(mob_vnum vn, Character *c);
int GetMobProtoCount();
mob_vnum DeleteMobProto(mob_vnum vn);
bool MobIndexExists(mob_vnum nv);
struct index_data * GetMobIndex(mob_vnum vn);
void SetMobIndex(mob_vnum vn, struct index_data *c);
int GetMobIndexCount();
mob_vnum DeleteMobIndex(mob_vnum vn);
#include "playerindex.h"
#endif