jeremyosborne | 2008-04-04 02:36:38 +0200 (Fri, 04 Apr 2008) | 1 line

Minor Bugfix: All game configuration settings now reference the world config 
structure, not the individual config variables found in config.c.
------------------------------------------------------------------------
 rumble | 2008-03-22 13:27:00 +0100 (Sat, 22 Mar 2008) | 1 line

Added lib/world/qst/ directory, index, index.mini, and 0.qst.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:27:51 +0100 (Sat, 08 Mar 2008) | 3 lines

Bugfix: the include directory (for .h files) is now referenced correctly in the
depend statement.
Deletion: listrent.c removed as a separate utility.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:08:51 +0100 (Sat, 08 Mar 2008) | 1 line

Enhancement: utils/ Makefile will now use a depends file, and looks for dependen
cies in the ../ directory (shrinks the necessary information to make each utilit
y).
------------------------------------------------------------------------
 Rumble | 2008-03-06 23:39:35 +0100 (Thu, 06 Mar 2008) | 1 line

Made TBA specific changes. do_cheat, removed help level checking, and advance to
level 32.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:37:12 +0100 (Thu, 06 Mar 2008) | 1 line

Minor Update: Changed header of Makefile.in to read 'tbaMUD' and also added in a
ttribution for the changes. (Thanks seqwith.)
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:31:07 +0100 (Thu, 06 Mar 2008) | 4 lines

Changed Makefile.in to use glob expressions when building the objects. This 
translates into no longer a need to update Makefile.in whenever a new .c file 
is added to the mud code. Other Makefile.* have not yet been changed (and 
need review, anyway).

All CXREF cruft left in Makefile.in has been removed. tbaMUD is now using 
Doxygen. Technically, CXREF provides a bit more auto-documentation than Doxygen
does, however the tbaMUD (and legacy circle code) has never been marked-up with 
the special CXREF codes required to effectively use the program. Since Doxygen 
is easier to use, and provides almost as much functionality as CXREF, CXREF 
support has been dropped.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:31:02 +0100 (Thu, 06 Mar 2008) | 1 line

Bug Fix: asciiflag_conv* functions now can handle a negative numeric value.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:16:06 +0100 (Thu, 06 Mar 2008) | 1 line

Bug fix/enhancement: Charmed mobs (specifically charmed mobs with a ->master) 
will no longer attempt to wander off.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:13:38 +0100 (Thu, 06 Mar 2008) | 6 lines

Based on the compiler warning about mag_materials being an unused function, and
the clone spell being unused.

Bug fix: Clone can now be cast. It is an 'ignore' target spell.

Fix and Modification: Clone, being an effectively unused spell that is only used
by mortal Magic Users at level 30, is now implemented as very simple example of
how to use mag_materials(). The item required by mag_materials is vnum 161, 
which in stock tbaMUD is some sacrificial entrails.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:43:09 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix for "Did you mean:" including DG commands.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:29:18 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix: do_simple_move slightly rewritten to handle Leave triggers that purge a
 door.

Documentation: do_simple_move documented.
------------------------------------------------------------------------
 Laoris | 2008-03-01 08:22:12 +0100 (Sat, 01 Mar 2008) | 1 line

Trial run of columnizer function on commands list to see how people like it.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-26 22:36:17 +0100 (Tue, 26 Feb 2008) | 1 line

asciimap, an in game automap, along with a couple of minor bug fixes to do with
the automap, patched in (Thanks Jamdog).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:08:05 +0100 (Fri, 22 Feb 2008) | 1 line

Minor update: Relocate local variable declaration to the top of ACMD(do_help)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:04:37 +0100 (Fri, 22 Feb 2008) | 6 lines

Checked in the following placeholders for do_gen_tog:
#define SCMD_AUTOLOOT   24
#define SCMD_AUTOGOLD   25
#define SCMD_AUTOSPLIT  26
#define SCMD_AUTOSAC    27
#define SCMD_AUTOASSIST 28
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 03:57:06 +0100 (Fri, 22 Feb 2008) | 1 line

The Autoquest patch, along with a couple of minor bug fixes, has been integrated
into tbaMUD. (Thanks Jamdog, Kenneth Ray and Morgaelin.)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 21:46:45 +0100 (Mon, 18 Feb 2008) | 2 lines

Minor Fix:
Casted NOWHERE, NOTHING, NOBODY and NOFLAG as IDXTYPE for the signed short int 
index types.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 03:36:16 +0100 (Mon, 18 Feb 2008) | 7 lines

Added a new atoidx() conversion function for dealing with string to IDXTYPE 
conversions (in utils.c, prototype exported through utils.h).
Added IDXTYPE_MIN and IDXTYPE_MAX defines (in structs.h).
Replaced atoi references with atoidx in do_oasis_zedit (in zedit.c).
------------------------------------------------------------------------
 Rumble | 2008-02-18 01:44:13 +0100 (Mon, 18 Feb 2008) | 1 line

Fixed direction mapping to give readable directions instead of sub commands. 
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:26:15 +0100 (Mon, 18 Feb 2008) | 5 lines

Since general olc editing are automatically saved to disk, 'shutdown reboot' has
been changed to not-autosave by default. (Small change made to do_shutdown in 
act.wizard.c).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:12:12 +0100 (Mon, 18 Feb 2008) | 3 lines

Changed:
struct attack_hit_type moved to fight.h
attack_hit_text exported through fight.h
------------------------------------------------------------------------
 jeremyosborne | 2008-02-17 22:32:51 +0100 (Sun, 17 Feb 2008) | 7 lines

- do_file heads or tails files correctly and has also been enhanced to return 
file info (act.wizard.c)
- defines made for common log files created by autorun, and those used by 
do_file (db.h)
- utility functions added: file_head(), file_tail(), file_sizeof(), and 
file_numlines() (defined utils.c and exported through utils.h)
------------------------------------------------------------------------
 Rumble | 2008-02-16 23:24:05 +0100 (Sat, 16 Feb 2008) | 1 line

Fixed export command. (thanks Kyle)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-16 22:42:46 +0100 (Sat, 16 Feb 2008) | 1 line

Files are now tagged as executable. Should be able to be checked out from subver
sion and executed without running chmod.
------------------------------------------------------------------------
 Rumble | 2008-02-15 17:03:06 +0100 (Fri, 15 Feb 2008) | 1 line

 Fixed strcat() writing out of bounds in cedit.c since strdup() only malloc() 
strlen(str)+1 bytes. (thanks Buggo) and moved attack_hit_text back.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-13 20:41:02 +0100 (Wed, 13 Feb 2008) | 1 line

Event queue function definitions, global variables and defines doxygenated.
------------------------------------------------------------------------
 Rumble | 2008-02-12 00:23:38 +0100 (Tue, 12 Feb 2008) | 1 line

Updated levels command to use an arg/range and added color parsing to greetings.
 (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-11 21:06:10 +0100 (Mon, 11 Feb 2008) | 1 line

Doxygen comments completed for weather.c
------------------------------------------------------------------------
 Rumble | 2008-02-11 03:52:50 +0100 (Mon, 11 Feb 2008) | 1 line

Corrected several 64-bit warnings. (thanks Buggo)
------------------------------------------------------------------------
 Rumble | 2008-02-10 22:56:56 +0100 (Sun, 10 Feb 2008) | 1 line

Added get_flag_by_name allowing for new trigedit variable checks like 
%actor.pref(FLAG)% checks. (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-08 21:22:26 +0100 (Fri, 08 Feb 2008) | 3 lines

COMPLETE: tbaMUD code re-org of global and local scope function and variable 
declarations. There may be a few things that I did not catch (some non extern 
keyword declarations of function prototypes within other functions, for 
example).

BUG FIX: Unused functions encrypt_hex() and decrypt_hex() removed from mail.c.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 23:31:09 +0100 (Tue, 05 Feb 2008) | 2 lines

Continued clean-up of 'extern' references to functions and variables.
BUG UNCOVERED: set_title() in class.c incorrectly handles the const nature of 
the char * returned from title_female and title_male.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 19:38:17 +0100 (Tue, 05 Feb 2008) | 3 lines

More work on mud clean-up.
New file: spec_procs.h
Created this file to house the legacy special procedures (spec_procs.c and 
castle.c) and special feature assignment in general.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 00:59:44 +0100 (Tue, 05 Feb 2008) | 3 lines

- Minor Bugfix: Fixed parse error in mobact.c
- Minor Bugfix: act.h is now included in all of the act functions. Forgot to do
that the first time :(
- Additions: ban.h has been added as the external entry point into the ban.c 
globals and functions. Files needing ban.h have been updated.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 20:02:11 +0100 (Mon, 04 Feb 2008) | 1 line

All act*.c functions, defines and globals have been prototyped/declared in 
act.h. The file act.h does not contain every ACMD, only those ACMDs and 
utility functions available within the act*.c files.
------------------------------------------------------------------------
 Rumble | 2008-02-04 17:59:47 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed the last few flags missed for the 128 bit conversion.
------------------------------------------------------------------------
 Laoris | 2008-02-04 07:27:56 +0100 (Mon, 04 Feb 2008) | 3 lines

Adding a column formatter for lists.  Accepts printf-like arguments.
Only used by medit right now.

------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 07:09:19 +0100 (Mon, 04 Feb 2008) | 2 lines

- Changed the 'struct queue' to 'struct dg_queue' to avoid namespace conflicts.
- Ongoing cleanup to mud project.
------------------------------------------------------------------------
 Rumble | 2008-02-04 00:07:09 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed run_autowiz which ran twice on advancement.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 03:46:22 +0100 (Sun, 03 Feb 2008) | 1 line

act.h created and added. This header will be the external entry point for the 
functions, function subcommands and variables within the act*.c files. It is 
not designed to be the entry point for all ACMD functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 02:44:29 +0100 (Sun, 03 Feb 2008) | 1 line

Merge of another part of the code cleanup, the dg script stuff.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 08:56:03 +0100 (Sat, 02 Feb 2008) | 1 line

Modularizing and organizing files continues. Committing comm.c and comm.h 
because they are hairy, and I don't want to do them over if my hard drive 
crashes.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 07:05:08 +0100 (Sat, 02 Feb 2008) | 4 lines

- Marking all file scope functions as 'static'
- Reorganization of the global variables and functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 10:20:47 +0100 (Thu, 31 Jan 2008) | 1 line

* Protected the conf.h.* system config files from multiple calls.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:56:18 +0100 (Thu, 31 Jan 2008) | 1 line

* Removed extraneous references to TRUE / FALSE and YES / NO defines.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:46:20 +0100 (Thu, 31 Jan 2008) | 2 lines

* BUGFIX: NUM_POSITIONS set to 8 (was incorrectly set to 15 before)
* Migrated NUM_* settings from oasis.h to more appropriate locations near where
they are defined. (For Example: NUM_POSITIONS moved to structs.h next to the 
POSITION_* defines.)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 03:58:28 +0100 (Thu, 31 Jan 2008) | 1 line

Added Appendix A - Coder Support. Right now, it simply speaks to the fact that 
we have included doxygen config files, are working to document the source code, 
and provides a rudimentary "do this" guide to create the doxygen cross 
references.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-30 07:12:07 +0100 (Wed, 30 Jan 2008) | 2 lines

- All .h files now have doxygen recognized headers, and the format is slightly 
altered to ease editing of headers.
- Protected all .h files from multiple calls. (Standard format is #ifndef _HEADE
R_H_ #define _HEADER_H_ .... #endif)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 11:18:14 +0100 (Tue, 29 Jan 2008) | 1 line

constants.h, structs.h and utils.h now protected from multiple includes. This is
 sometimes overkill, but good practice overall.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:38:18 +0100 (Tue, 29 Jan 2008) | 1 line

Updated documentation for constants.c and constants.h.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:15:25 +0100 (Tue, 29 Jan 2008) | 3 lines

The standard Doxygen configuration doxyfiles (config files) for tbaMUD. One is 
to be used with the Graphviz DOT (dox_withGraphs), one is designed to be used if
Graphviz is not available.

Now just need a short document describing the usage of doxygen.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:11:36 +0100 (Tue, 29 Jan 2008) | 1 line

Minor document correction in struct dex_app_tpe.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 20:53:51 +0100 (Mon, 28 Jan 2008) | 1 line

*bugfix* do_drink command: When a container is empty, the correct, "It is 
empty." message is now displayed.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 07:58:15 +0100 (Mon, 28 Jan 2008) | 3 lines

Merging changes to trunk for:
* utils.h, utils.c and structs.h doxygen comments
* adding file dox_withGraphs.doxyfile
This commit is contained in:
Rumble 2008-04-12 01:31:58 +00:00
parent 70f648c85b
commit ebc985f010
120 changed files with 9028 additions and 4364 deletions

305
src/db.c
View file

@ -25,6 +25,17 @@
#include "oasis.h"
#include "dg_scripts.h"
#include "dg_event.h"
#include "act.h"
#include "ban.h"
#include "spec_procs.h"
#include "genzon.h"
#include "genolc.h"
#include "genobj.h" /* for free_object_strings */
#include "config.h" /* for the default config values. */
#include "fight.h"
#include "modify.h"
#include "shop.h"
#include "quest.h"
/* declarations of most of the 'global' variables */
struct config_data config_info; /* Game configuration list. */
@ -42,8 +53,16 @@ struct index_data *obj_index; /* index table for object file */
struct obj_data *obj_proto; /* prototypes for objs */
obj_rnum top_of_objt = 0; /* top of object index table */
struct zone_data *zone_table; /* zone table */
zone_rnum top_of_zone_table = 0;/* top element of zone tab */
struct zone_data *zone_table; /* zone table */
zone_rnum top_of_zone_table = 0;/* top element of zone tab */
/* begin previously located in players.c */
struct player_index_element *player_table = NULL; /* index to plr file */
int top_of_p_table = 0; /* ref to top of table */
int top_of_p_file = 0; /* ref of size of p file */
long top_idnum = 0; /* highest idnum in use */
/* end previously located in players.c */
struct message_list fight_messages[MAX_MESSAGES]; /* fighting messages */
struct index_data **trig_index; /* index table for triggers */
@ -53,18 +72,20 @@ long max_mob_id = MOB_ID_BASE; /* for unique mob id's */
long max_obj_id = OBJ_ID_BASE; /* for unique obj id's */
int dg_owner_purged; /* For control of scripts */
struct aq_data *aquest_table; /* Autoquests table */
qst_rnum total_quests = 0; /* top of autoquest table */
struct shop_data *shop_index; /* index table for shops */
int top_shop = -1; /* top of shop table */
int no_mail = 0; /* mail disabled? */
int mini_mud = 0; /* mini-mud mode? */
int no_rent_check = 0; /* skip rent check on boot? */
time_t boot_time = 0; /* time of mud boot */
int circle_restrict = 0; /* level of game restriction */
int no_mail = 0; /* mail disabled? */
int mini_mud = 0; /* mini-mud mode? */
int no_rent_check = 0; /* skip rent check on boot? */
time_t boot_time = 0; /* time of mud boot */
int circle_restrict = 0; /* level of game restriction */
room_rnum r_mortal_start_room; /* rnum of mortal start room */
room_rnum r_immort_start_room; /* rnum of immort start room */
room_rnum r_frozen_start_room; /* rnum of frozen start room */
int converting = FALSE;
char *credits = NULL; /* game credits */
char *news = NULL; /* mud news */
@ -86,93 +107,41 @@ struct help_index_element *help_table = NULL;
struct social_messg *soc_mess_list = NULL; /* list of socials */
int top_of_socialt = -1; /* number of socials */
struct time_info_data time_info;/* the infomation about the time */
struct time_info_data time_info; /* the infomation about the time */
struct weather_data weather_info; /* the infomation about the weather */
struct player_special_data dummy_mob; /* dummy spec area for mobs */
struct reset_q_type reset_q; /* queue of zones to be reset */
struct reset_q_type reset_q; /* queue of zones to be reset */
/* local functions */
int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits);
int check_object_spell_number(struct obj_data *obj, int val);
int check_object_level(struct obj_data *obj, int val);
void setup_dir(FILE *fl, int room, int dir);
void index_boot(int mode);
void discrete_load(FILE *fl, int mode, char *filename);
int check_object(struct obj_data *);
void parse_room(FILE *fl, int virtual_nr);
void parse_mobile(FILE *mob_f, int nr);
char *parse_object(FILE *obj_f, int nr);
void load_zones(FILE *fl, char *zonename);
void assign_mobiles(void);
void assign_objects(void);
void assign_rooms(void);
void assign_the_shopkeepers(void);
int is_empty(zone_rnum zone_nr);
void reset_zone(zone_rnum zone);
int file_to_string(const char *name, char *buf);
int file_to_string_alloc(const char *name, char **buf);
void reboot_wizlists(void);
ACMD(do_reboot);
void boot_world(void);
int count_alias_records(FILE *fl);
int count_hash_records(FILE *fl);
bitvector_t asciiflag_conv(char *flag);
void parse_simple_mob(FILE *mob_f, int i, int nr);
void interpret_espec(const char *keyword, const char *value, int i, int nr);
void parse_espec(char *buf, int i, int nr);
void parse_enhanced_mob(FILE *mob_f, int i, int nr);
void get_one_line(FILE *fl, char *buf);
void check_start_rooms(void);
void renum_world(void);
void renum_zone_table(void);
void log_zone_error(zone_rnum zone, int cmd_no, const char *message);
void reset_time(void);
char fread_letter(FILE *fp);
void free_followers(struct follow_type *k);
void load_default_config( void );
void load_config( void );
void free_extra_descriptions(struct extra_descr_data *edesc);
bitvector_t asciiflag_conv_aff(char *flag);
/* external functions */
void paginate_string(char *str, struct descriptor_data *d);
struct time_info_data *mud_time_passed(time_t t2, time_t t1);
void free_alias(struct alias_data *a);
void load_messages(void);
void mag_assign_spells(void);
void update_obj_file(void); /* In objsave.c */
void sort_commands(void);
void sort_spells(void);
void load_banned(void);
void read_invalid_list(void);
void boot_the_shops(FILE *shop_f, char *filename, int rec_count);
int hsort(const void *a, const void *b);
void prune_crlf(char *txt);
void destroy_shops(void);
void free_object_strings(struct obj_data *obj);
void free_object_strings_proto(struct obj_data *obj);
void clean_llog_entries(void);
void create_command_list(void);
void build_player_index(void);
void clean_pfiles(void);
int add_to_save_list(zone_vnum, int type);
int save_all(void);
extern zone_rnum real_zone_by_thing(room_vnum vznum);
/* declaration of local (file scope) variables */
static int converting = FALSE;
/* external vars */
extern struct descriptor_data *descriptor_list;
extern const char *unused_spellname; /* spell_parser.c */
extern int no_specials;
extern int scheck;
extern int bitwarning;
extern int bitsavetodisk;
extern struct player_index_element *player_table;
extern int top_of_p_table;
extern long top_idnum;
extern int display_closed_doors;
/* external ASCII Player Files vars */
extern int auto_pwipe;
/* Local (file scope) utility functions */
static int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits);
static int check_object_spell_number(struct obj_data *obj, int val);
static int check_object_level(struct obj_data *obj, int val);
static int check_object(struct obj_data *);
static void load_zones(FILE *fl, char *zonename);
static int file_to_string(const char *name, char *buf);
static int file_to_string_alloc(const char *name, char **buf);
static int count_alias_records(FILE *fl);
static void parse_simple_mob(FILE *mob_f, int i, int nr);
static void interpret_espec(const char *keyword, const char *value, int i, int nr);
static void parse_espec(char *buf, int i, int nr);
static void parse_enhanced_mob(FILE *mob_f, int i, int nr);
static void get_one_line(FILE *fl, char *buf);
static void check_start_rooms(void);
static void renum_zone_table(void);
static void log_zone_error(zone_rnum zone, int cmd_no, const char *message);
static void reset_time(void);
static char fread_letter(FILE *fp);
static void free_followers(struct follow_type *k);
static void load_default_config( void );
static void free_extra_descriptions(struct extra_descr_data *edesc);
static bitvector_t asciiflag_conv_aff(char *flag);
static int hsort(const void *a, const void *b);
/* routines for booting the system */
char *fread_action(FILE *fl, int nr)
@ -473,9 +442,13 @@ void boot_world(void)
log("Loading shops.");
index_boot(DB_BOOT_SHP);
}
log("Loading quests.");
index_boot(DB_BOOT_QST);
}
void free_extra_descriptions(struct extra_descr_data *edesc)
static void free_extra_descriptions(struct extra_descr_data *edesc)
{
struct extra_descr_data *enext;
@ -582,6 +555,9 @@ void destroy_db(void)
/* Shops */
destroy_shops();
/* Quests */
destroy_quests();
/* Zones */
#define THIS_CMD zone_table[cnt].cmd[itr]
@ -706,6 +682,8 @@ void boot_db(void)
assign_objects();
log(" Rooms.");
assign_rooms();
log(" Questmasters.");
assign_the_quests();
}
log("Assigning spell and skill levels.");
@ -742,7 +720,6 @@ void boot_db(void)
#if 1
{
int i;
extern SPECIAL(shop_keeper);
for (i = 0 ; i < top_of_objt; i++) {
if (obj_proto[i].script == (struct script_data *)&shop_keeper) {
@ -768,7 +745,7 @@ void boot_db(void)
}
/* reset the time in the game from file */
void reset_time(void)
static void reset_time(void)
{
time_t beginning_of_time = 0;
FILE *bgtime;
@ -776,7 +753,7 @@ void reset_time(void)
if ((bgtime = fopen(TIME_FILE, "r")) == NULL)
log("No time file '%s' starting from the beginning.", TIME_FILE);
else {
fscanf(bgtime, "%ld\n", &beginning_of_time);
fscanf(bgtime, "%ld\n", (long *)&beginning_of_time);
fclose(bgtime);
}
@ -825,14 +802,14 @@ void save_mud_time(struct time_info_data *when)
if ((bgtime = fopen(TIME_FILE, "w")) == NULL)
log("SYSERR: Can't write to '%s' time file.", TIME_FILE);
else {
fprintf(bgtime, "%ld\n", mud_time_to_secs(when));
fprintf(bgtime, "%ld\n", (long)mud_time_to_secs(when));
fclose(bgtime);
}
}
/* Thanks to Andrey (andrey@alex-ua.com) for this bit of code, although I did
* add the 'goto' and changed some "while()" into "do { } while()". -gg */
int count_alias_records(FILE *fl)
static int count_alias_records(FILE *fl)
{
char key[READ_SIZE], next_key[READ_SIZE];
char line[READ_SIZE], *scan;
@ -914,6 +891,9 @@ void index_boot(int mode)
case DB_BOOT_TRG:
prefix = TRG_PREFIX;
break;
case DB_BOOT_QST:
prefix = QST_PREFIX;
break;
default:
log("SYSERR: Unknown subcommand %d to index_boot!", mode);
exit(1);
@ -954,7 +934,7 @@ void index_boot(int mode)
/* Exit if 0 records, unless this is shops */
if (!rec_count) {
if (mode == DB_BOOT_SHP)
if (mode == DB_BOOT_SHP || mode == DB_BOOT_QST)
return;
log("SYSERR: boot error - 0 records counted in %s/%s.", prefix,
index_filename);
@ -995,6 +975,11 @@ void index_boot(int mode)
size[0] = sizeof(struct help_index_element) * rec_count;
log(" %d entries, %d bytes.", rec_count, size[0]);
break;
case DB_BOOT_QST:
CREATE(aquest_table, struct aq_data, rec_count);
size[0] = sizeof(struct aq_data) * rec_count;
log(" %d entries, %d bytes.", rec_count, size[0]);
break;
}
rewind(db_index);
@ -1010,6 +995,7 @@ void index_boot(int mode)
case DB_BOOT_OBJ:
case DB_BOOT_MOB:
case DB_BOOT_TRG:
case DB_BOOT_QST:
discrete_load(db_file, mode, buf2);
break;
case DB_BOOT_ZON:
@ -1040,7 +1026,7 @@ void discrete_load(FILE *fl, int mode, char *filename)
int nr = -1, last;
char line[READ_SIZE];
const char *modes[] = {"world", "mob", "obj", "ZON", "SHP", "HLP", "trg"};
const char *modes[] = {"world", "mob", "obj", "ZON", "SHP", "HLP", "trg", "qst"};
/* modes positions correspond to DB_BOOT_xxx in db.h */
for (;;) {
@ -1083,6 +1069,9 @@ void discrete_load(FILE *fl, int mode, char *filename)
case DB_BOOT_OBJ:
strlcpy(line, parse_object(fl, nr), sizeof(line));
break;
case DB_BOOT_QST:
parse_quest(fl, nr);
break;
}
} else {
log("SYSERR: Format error in %s file %s near %s #%d", modes[mode],
@ -1093,7 +1082,7 @@ void discrete_load(FILE *fl, int mode, char *filename)
}
}
char fread_letter(FILE *fp)
static char fread_letter(FILE *fp)
{
char c;
do {
@ -1114,7 +1103,8 @@ bitvector_t asciiflag_conv(char *flag)
else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A'));
if (!isdigit(*p))
/* Allow the first character to be a minus sign */
if (!isdigit(*p) && (*p != '-' || p != flag))
is_num = FALSE;
}
@ -1124,7 +1114,7 @@ bitvector_t asciiflag_conv(char *flag)
return (flags);
}
bitvector_t asciiflag_conv_aff(char *flag)
static bitvector_t asciiflag_conv_aff(char *flag)
{
bitvector_t flags = 0;
int is_num = TRUE;
@ -1136,7 +1126,8 @@ bitvector_t asciiflag_conv_aff(char *flag)
else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A' + 1));
if (!isdigit(*p))
/* Allow the first character to be a minus sign */
if (!isdigit(*p) && (*p != '-' || p != flag))
is_num = FALSE;
}
@ -1317,7 +1308,7 @@ void setup_dir(FILE *fl, int room, int dir)
}
/* make sure the start rooms exist & resolve their vnums to rnums */
void check_start_rooms(void)
static void check_start_rooms(void)
{
if ((r_mortal_start_room = real_room(CONFIG_MORTAL_START)) == NOWHERE) {
log("SYSERR: Mortal start room does not exist. Change in config.c.");
@ -1348,6 +1339,11 @@ void renum_world(void)
real_room(world[room].dir_option[door]->to_room);
}
/** This is not the same ZCMD as used elsewhere. GRUMBLE... namespace conflict
* @todo refactor this particular ZCMD and remove this redefine. */
#ifdef ZCMD
#undef ZCMD
#endif
#define ZCMD zone_table[zone].cmd[cmd_no]
/* Resolve vnums into rnums in the zone reset tables. In English: Once all of
@ -1356,7 +1352,7 @@ void renum_world(void)
* is running. This does make adding any room, mobile, or object a little more
* difficult while the game is running. Assumes NOWHERE == NOBODY == NOTHING.
* Assumes sizeof(room_rnum) >= (sizeof(mob_rnum) and sizeof(obj_rnum)) */
void renum_zone_table(void)
static void renum_zone_table(void)
{
int cmd_no;
room_rnum a, b, c, olda, oldb, oldc;
@ -1415,7 +1411,7 @@ void renum_zone_table(void)
}
}
void parse_simple_mob(FILE *mob_f, int i, int nr)
static void parse_simple_mob(FILE *mob_f, int i, int nr)
{
int j, t[10];
char line[READ_SIZE];
@ -1510,7 +1506,7 @@ void parse_simple_mob(FILE *mob_f, int i, int nr)
#define RANGE(low, high) \
(num_arg = MAX((low), MIN((high), (num_arg))))
void interpret_espec(const char *keyword, const char *value, int i, int nr)
static void interpret_espec(const char *keyword, const char *value, int i, int nr)
{
int num_arg = 0, matched = FALSE;
@ -1569,7 +1565,7 @@ void interpret_espec(const char *keyword, const char *value, int i, int nr)
#undef BOOL_CASE
#undef RANGE
void parse_espec(char *buf, int i, int nr)
static void parse_espec(char *buf, int i, int nr)
{
char *ptr;
@ -1581,7 +1577,7 @@ void parse_espec(char *buf, int i, int nr)
interpret_espec(buf, ptr, i, nr);
}
void parse_enhanced_mob(FILE *mob_f, int i, int nr)
static void parse_enhanced_mob(FILE *mob_f, int i, int nr)
{
char line[READ_SIZE];
@ -1946,7 +1942,7 @@ char *parse_object(FILE *obj_f, int nr)
#define Z zone_table[zone]
/* load the zone table and command tables */
void load_zones(FILE *fl, char *zonename)
static void load_zones(FILE *fl, char *zonename)
{
static zone_rnum zone = 0;
int cmd_no, num_of_cmds = 0, line_num = 0, tmp, error;
@ -2077,7 +2073,7 @@ void load_zones(FILE *fl, char *zonename)
}
#undef Z
void get_one_line(FILE *fl, char *buf)
static void get_one_line(FILE *fl, char *buf)
{
if (fgets(buf, READ_SIZE, fl) == NULL) {
log("SYSERR: error reading help file: not terminated with $?");
@ -2174,7 +2170,7 @@ void load_help(FILE * fl, char *name)
}
}
int hsort(const void *a, const void *b)
static int hsort(const void *a, const void *b)
{
const struct help_index_element *a1, *b1;
@ -2409,7 +2405,7 @@ void zone_update(void)
}
}
void log_zone_error(zone_rnum zone, int cmd_no, const char *message)
static void log_zone_error(zone_rnum zone, int cmd_no, const char *message)
{
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: zone file: %s", message);
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: ...offending cmd: '%c' cmd in zone #%d, line %d",
@ -2720,7 +2716,7 @@ char *fread_string(FILE *fl, const char *error)
}
/* Called to free all allocated follow_type structs */
void free_followers(struct follow_type *k)
static void free_followers(struct follow_type *k)
{
if (!k)
return;
@ -2747,6 +2743,8 @@ void free_char(struct char_data *ch)
free(ch->player_specials->poofin);
if (ch->player_specials->poofout)
free(ch->player_specials->poofout);
if (ch->player_specials->saved.completed_quests)
free(ch->player_specials->saved.completed_quests);
if (GET_HOST(ch))
free(GET_HOST(ch));
if (IS_NPC(ch))
@ -2843,7 +2841,7 @@ void free_obj(struct obj_data *obj)
* interested in and not a copy. If someone is reading a global copy we're
* trying to replace, give everybody using it a different copy so as to avoid
* special cases. */
int file_to_string_alloc(const char *name, char **buf)
static int file_to_string_alloc(const char *name, char **buf)
{
int temppage;
char temp[MAX_STRING_LENGTH];
@ -2875,7 +2873,7 @@ int file_to_string_alloc(const char *name, char **buf)
}
/* read contents of a text file, and place in buf */
int file_to_string(const char *name, char *buf)
static int file_to_string(const char *name, char *buf)
{
FILE *fl;
char tmp[READ_SIZE + 3];
@ -2996,6 +2994,10 @@ void init_char(struct char_data *ch)
ch->player.long_descr = NULL;
ch->player.description = NULL;
GET_NUM_QUESTS(ch) = 0;
ch->player_specials->saved.completed_quests = NULL;
GET_QUEST(ch) = -1;
ch->player.time.birth = time(0);
ch->player.time.logon = time(0);
ch->player.time.played = 0;
@ -3044,6 +3046,7 @@ void init_char(struct char_data *ch)
GET_COND(ch, i) = (GET_LEVEL(ch) == LVL_IMPL ? -1 : 24);
GET_LOADROOM(ch) = NOWHERE;
GET_SCREEN_WIDTH(ch) = PAGE_WIDTH;
}
/* returns the real number of the room with given virtual number */
@ -3149,7 +3152,7 @@ zone_rnum real_zone(zone_vnum vnum)
}
/* Extend later to include more checks and add checks for unknown bitvectors. */
int check_object(struct obj_data *obj)
static int check_object(struct obj_data *obj)
{
char objname[MAX_INPUT_LENGTH + 32];
int error = FALSE, y;
@ -3205,7 +3208,6 @@ int check_object(struct obj_data *obj)
break;
case ITEM_NOTE:
if (obj->ex_description) {
extern char *find_exdesc(char *word, struct extra_descr_data *list);
char onealias[MAX_INPUT_LENGTH],*next_name;
next_name = any_one_arg(obj->name, onealias);
do {
@ -3228,7 +3230,7 @@ int check_object(struct obj_data *obj)
return (error);
}
int check_object_spell_number(struct obj_data *obj, int val)
static int check_object_spell_number(struct obj_data *obj, int val)
{
int error = FALSE;
const char *spellname;
@ -3262,7 +3264,7 @@ int check_object_spell_number(struct obj_data *obj, int val)
return (error);
}
int check_object_level(struct obj_data *obj, int val)
static int check_object_level(struct obj_data *obj, int val)
{
int error = FALSE;
@ -3273,7 +3275,7 @@ int check_object_level(struct obj_data *obj, int val)
return (error);
}
int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits)
static int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits)
{
unsigned int flagnum;
bool error = FALSE;
@ -3284,64 +3286,14 @@ int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatam
for (flagnum = namecount; flagnum < sizeof(bitvector_t) * 8; flagnum++)
if ((1 << flagnum) & bits) {
log("SYSERR: %s has unknown %s flag, bit %d (0 through %d known).", whatami, whatbits, flagnum, namecount - 1);
log("SYSERR: %s has unknown %s flag, bit %d (0 through %d known).", whatami, whatbits, flagnum, (int)namecount - 1);
error = TRUE;
}
return (error);
}
/* External variables from config.c */
extern int pk_allowed;
extern int pt_allowed;
extern int level_can_shout;
extern int holler_move_cost;
extern int tunnel_size;
extern int max_exp_gain;
extern int max_exp_loss;
extern int max_npc_corpse_time;
extern int max_pc_corpse_time;
extern int idle_void;
extern int idle_rent_time;
extern int idle_max_level;
extern int dts_are_dumps;
extern int load_into_inventory;
extern int track_through_doors;
extern int no_mort_to_immort;
extern int free_rent;
extern int max_obj_save;
extern int min_rent_cost;
extern int auto_save;
extern int autosave_time;
extern int crash_file_timeout;
extern int rent_file_timeout;
extern room_vnum mortal_start_room;
extern room_vnum immort_start_room;
extern room_vnum frozen_start_room;
extern room_vnum donation_room_1;
extern room_vnum donation_room_2;
extern room_vnum donation_room_3;
extern ush_int DFLT_PORT;
extern const char *DFLT_IP;
extern const char *DFLT_DIR;
extern const char *LOGNAME;
extern int max_playing;
extern int max_filesize;
extern int max_bad_pws;
extern int siteok_everyone;
extern int nameserver_is_slow;
extern int use_new_socials;
extern int auto_save_olc;
extern const char *MENU;
extern const char *WELC_MESSG;
extern const char *START_MESSG;
extern int use_autowiz;
extern int min_wizlist_lev;
extern const char *OK;
extern const char *NOPERSON;
extern const char *NOEFFECT;
void load_default_config( void )
static void load_default_config( void )
{
/* This function is called only once, at boot-time. We assume config_info is
* empty. -Welcor */
@ -3366,6 +3318,9 @@ void load_default_config( void )
CONFIG_TRACK_T_DOORS = track_through_doors;
CONFIG_NO_MORT_TO_IMMORT = no_mort_to_immort;
CONFIG_DISP_CLOSED_DOORS = display_closed_doors;
CONFIG_MAP = map_option;
CONFIG_MAP_SIZE = default_map_size;
CONFIG_MINIMAP_SIZE = default_minimap_size;
/* Rent / crashsave options. */
CONFIG_FREE_RENT = free_rent;
@ -3425,7 +3380,7 @@ void load_config( void )
load_default_config();
snprintf(buf, sizeof(buf), "%s/%s", DFLT_DIR, CONFIG_CONFFILE);
snprintf(buf, sizeof(buf), "%s/%s", CONFIG_DFLT_DIR, CONFIG_CONFFILE);
if ( !(fl = fopen(CONFIG_CONFFILE, "r")) && !(fl = fopen(buf, "r")) ) {
snprintf(buf, sizeof(buf), "No %s file, using defaults", CONFIG_CONFFILE);
perror(buf);
@ -3488,6 +3443,10 @@ void load_config( void )
CONFIG_DFLT_IP = NULL;
} else if (!str_cmp(tag, "dflt_port"))
CONFIG_DFLT_PORT = num;
else if (!str_cmp(tag, "default_map_size"))
CONFIG_MAP_SIZE = num;
else if (!str_cmp(tag, "default_minimap_size"))
CONFIG_MINIMAP_SIZE = num;
break;
case 'f':
@ -3558,6 +3517,8 @@ void load_config( void )
CONFIG_MIN_WIZLIST_LEV = num;
else if (!str_cmp(tag, "mortal_start_room"))
CONFIG_MORTAL_START = num;
else if (!str_cmp(tag, "map_option"))
CONFIG_MAP = num;
break;
case 'n':