From: Rick Bird Date: Sun, 3 Apr 2011 00:08:57 +0000 (-0400) Subject: 1) Moved rest of hooks in local files over to module accessible functions. X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=d48eebe3488fb7286d0a7b5c090c643dbba49a63;p=cobramush.git 1) Moved rest of hooks in local files over to module accessible functions. 2) Removed all local.dst files and updated Makefile generation scripts --- diff --git a/Makefile.SH b/Makefile.SH index d35e6ca..f0e7afb 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -52,7 +52,7 @@ $make_set_make CC=$cc CCFLAGS=$optimize -I.. -I../hdrs -Wall -Wno-comment -Wno-parentheses -Wno-switch -Werror $ccflags $warnings LDFLAGS=$ldflags -CLIBS=-ltdl $libs $cryptlib $libssl $libcrypto $libmysqlclient +CLIBS=-lltdl $libs $cryptlib $libssl $libcrypto $libmysqlclient INSTALL=$install INSTALLDIR=$installdir CP=$cp diff --git a/src/Makefile.SH b/src/Makefile.SH index cd4612c..a5d985f 100644 --- a/src/Makefile.SH +++ b/src/Makefile.SH @@ -60,11 +60,11 @@ CFLAGS=$(CCFLAGS) $(RDEFS) $(IDEFS) # List of C files, used for make depend: C_FILES=access.c atr_tab.c attrib.c boolexp.c bsd.c bufferq.c \ - chunk.c cmdlocal.c cmds.c \ + chunk.c cmds.c \ command.c compress.c conf.c cque.c create.c cron.c db.c destroy.c division.c extchat.c \ - extmail.c filecopy.c flaglocal.c flags.c funcrypt.c function.c \ - fundb.c fundiv.c funlist.c funlocal.c funmath.c funmisc.c funstr.c funtime.c \ - funufun.c game.c help.c htab.c ident.c local.c lock.c log.c look.c \ + extmail.c filecopy.c flags.c funcrypt.c function.c \ + fundb.c fundiv.c funlist.c funmath.c funmisc.c funstr.c funtime.c \ + funufun.c game.c help.c htab.c ident.c lock.c log.c look.c \ malias.c match.c memcheck.c move.c modules.c mushlua.c mushlua_wrap.c mycrypt.c mymalloc.c mysocket.c \ myssl.c notify.c parse.c pcre.c player.c plyrlist.c \ predicat.c privtab.c prog.o ptab.c rob.c rplog.c services.c set.c shs.c \ @@ -86,11 +86,11 @@ H_FILES = ../config.h ../confmagic.h ../hdrs/ansi.h ../hdrs/atr_tab.h \ # .o versions of above - these are used in the build COMMON_O_FILES=access.o atr_tab.o attrib.o boolexp.o bufferq.o \ - chunk.o cmdlocal.o cmds.o \ + chunk.o cmds.o \ command.o compress.o conf.o cque.o create.o cron.o db.o destroy.o division.o extchat.o \ - extmail.o filecopy.o flaglocal.o flags.o funcrypt.o function.o \ - fundb.o funlist.o fundiv.o funlocal.o funmath.o funmisc.o funstr.o funtime.o \ - funufun.o game.o help.o htab.o ident.o local.o lock.o log.o look.o \ + extmail.o filecopy.o flags.o funcrypt.o function.o \ + fundb.o funlist.o fundiv.o funmath.o funmisc.o funstr.o funtime.o \ + funufun.o game.o help.o htab.o ident.o lock.o log.o look.o \ malias.o match.o memcheck.o move.o modules.o mushlua.o mushlua_wrap.o mycrypt.o mymalloc.o \ mysocket.o myssl.o notify.o parse.o pcre.o player.o plyrlist.o predicat.o privtab.o \ prog.o ptab.o rob.o rplog.o services.o set.o shs.o sig.o speech.o sql.o strdup.o \ @@ -144,53 +144,11 @@ buildinf: @echo "#define RDEFS \"$(RDEFS)\"" >> ../hdrs/buildinf.h @echo "#define IDEFS \"$(IDEFS)\"" >> ../hdrs/buildinf.h -# If funlocal.c doesn't exist, we want to build it from -# funlocal.dst. -funlocal.c: funlocal.dst - @if [ ! -f funlocal.c ]; then \ - cp funlocal.dst funlocal.c; \ - else \ - echo "********************************************************"; \ - echo "NOTE! funlocal.dst has been changed. You may need to incorporate these" ; \ - echo "changes into your funlocal.c. Edit or touch funlocal.c to prevent this message"; \ - echo "********************************************************"; \ - fi - -flaglocal.c: flaglocal.dst - @if [ ! -f flaglocal.c ]; then \ - cp flaglocal.dst flaglocal.c; \ - else \ - echo "********************************************************"; \ - echo "NOTE! flaglocal.dst has been changed. You may need to incorporate these" ; \ - echo "changes into your flaglocal.c. Edit or touch flaglocal.c to prevent this message"; \ - echo "********************************************************"; \ - fi - -cmdlocal.c: cmdlocal.dst - @if [ ! -f cmdlocal.c ]; then \ - cp cmdlocal.dst cmdlocal.c; \ - else \ - echo "********************************************************"; \ - echo "NOTE! cmdlocal.dst has been changed. You may need to incorporate these" ; \ - echo "changes into your cmdlocal.c. Edit or touch cmdlocal.c to prevent this message"; \ - echo "********************************************************"; \ - fi mushlua_wrap.c: mushlua.i @echo "Generating mushlua_wrap.c" swig -o mushlua_wrap.c -lua mushlua.i -local.c: local.dst - @if [ ! -f local.c ]; then \ - cp local.dst local.c; \ - else \ - echo "********************************************************"; \ - echo "NOTE! local.dst has been changed. You may need to incorporate these" ; \ - echo "changes into your local.c. Edit or touch local.c to prevent this message"; \ - echo "********************************************************"; \ - fi - - ../po/pennmush.pot: $(C_FILES) $(H_FILES) xgettext -d pennmush -kT -o ../po/pennmush.pot $(C_FILES) $(H_FILES) @@ -200,7 +158,7 @@ etags: ctags: ctags *.c -depend: funlocal.c cmdlocal.c local.c flaglocal.c +depend: makedepend -fMakefile.SH -w10 -- -I../hdrs -I.. $(CFLAGS) -- $(C_FILES) $(H_FILES) perl ../utils/fixdepend.pl Makefile.SH @@ -228,7 +186,7 @@ clean: -rm -f a.out core gmon.out $(OUTFILES) distclean: clean - -rm -f *~ *.orig *.rej *.bak funlocal.c cmdlocal.c flaglocal.c local.c \#* + -rm -f *~ *.orig *.rej *.bak \#* test_compress: comp_h.c $(CC) $(CFLAGS) -o test_compress -DSTANDALONE comp_h.c @@ -424,27 +382,6 @@ chunk.o: ../hdrs/switches.h chunk.o: ../hdrs/intrface.h chunk.o: ../hdrs/log.h chunk.o: ../hdrs/mymalloc.h -cmdlocal.o: ../hdrs/copyrite.h -cmdlocal.o: ../config.h -cmdlocal.o: ../hdrs/conf.h -cmdlocal.o: ../options.h -cmdlocal.o: ../hdrs/mushtype.h -cmdlocal.o: ../hdrs/htab.h -cmdlocal.o: ../hdrs/externs.h -cmdlocal.o: ../hdrs/compile.h -cmdlocal.o: ../hdrs/dbdefs.h -cmdlocal.o: ../hdrs/mushdb.h -cmdlocal.o: ../hdrs/flags.h -cmdlocal.o: ../hdrs/ptab.h -cmdlocal.o: ../hdrs/division.h -cmdlocal.o: ../hdrs/chunk.h -cmdlocal.o: ../hdrs/bufferq.h -cmdlocal.o: ../confmagic.h -cmdlocal.o: ../hdrs/parse.h -cmdlocal.o: ../hdrs/command.h -cmdlocal.o: ../hdrs/boolexp.h -cmdlocal.o: ../hdrs/switches.h -cmdlocal.o: ../hdrs/cmds.h cmds.o: ../hdrs/copyrite.h cmds.o: ../config.h cmds.o: ../hdrs/conf.h @@ -773,22 +710,6 @@ extmail.o: ../hdrs/pueblo.h extmail.o: ../hdrs/log.h extmail.o: ../hdrs/lock.h extmail.o: ../hdrs/dbio.h -flaglocal.o: ../hdrs/copyrite.h -flaglocal.o: ../config.h -flaglocal.o: ../hdrs/conf.h -flaglocal.o: ../options.h -flaglocal.o: ../hdrs/mushtype.h -flaglocal.o: ../hdrs/htab.h -flaglocal.o: ../hdrs/externs.h -flaglocal.o: ../hdrs/compile.h -flaglocal.o: ../hdrs/dbdefs.h -flaglocal.o: ../hdrs/mushdb.h -flaglocal.o: ../hdrs/flags.h -flaglocal.o: ../hdrs/ptab.h -flaglocal.o: ../hdrs/division.h -flaglocal.o: ../hdrs/chunk.h -flaglocal.o: ../hdrs/bufferq.h -flaglocal.o: ../confmagic.h flags.o: ../config.h flags.o: ../hdrs/conf.h flags.o: ../hdrs/copyrite.h @@ -955,25 +876,6 @@ funlist.o: ../hdrs/attrib.h funlist.o: ../hdrs/command.h funlist.o: ../hdrs/switches.h funlist.o: ../hdrs/lock.h -funlocal.o: ../hdrs/copyrite.h -funlocal.o: ../config.h -funlocal.o: ../hdrs/conf.h -funlocal.o: ../options.h -funlocal.o: ../hdrs/mushtype.h -funlocal.o: ../hdrs/htab.h -funlocal.o: ../hdrs/externs.h -funlocal.o: ../hdrs/compile.h -funlocal.o: ../hdrs/dbdefs.h -funlocal.o: ../hdrs/mushdb.h -funlocal.o: ../hdrs/flags.h -funlocal.o: ../hdrs/ptab.h -funlocal.o: ../hdrs/division.h -funlocal.o: ../hdrs/chunk.h -funlocal.o: ../hdrs/bufferq.h -funlocal.o: ../confmagic.h -funlocal.o: ../hdrs/parse.h -funlocal.o: ../hdrs/boolexp.h -funlocal.o: ../hdrs/function.h funmath.o: ../hdrs/copyrite.h funmath.o: ../config.h funmath.o: ../hdrs/conf.h @@ -1193,27 +1095,6 @@ ident.o: ../hdrs/switches.h ident.o: ../hdrs/ident.h ident.o: ../hdrs/mysocket.h ident.o: ../hdrs/mymalloc.h -local.o: ../hdrs/copyrite.h -local.o: ../config.h -local.o: ../hdrs/conf.h -local.o: ../options.h -local.o: ../hdrs/mushtype.h -local.o: ../hdrs/htab.h -local.o: ../hdrs/dbio.h -local.o: ../hdrs/externs.h -local.o: ../hdrs/compile.h -local.o: ../hdrs/dbdefs.h -local.o: ../hdrs/mushdb.h -local.o: ../hdrs/flags.h -local.o: ../hdrs/ptab.h -local.o: ../hdrs/division.h -local.o: ../hdrs/chunk.h -local.o: ../hdrs/bufferq.h -local.o: ../confmagic.h -local.o: ../hdrs/parse.h -local.o: ../hdrs/command.h -local.o: ../hdrs/boolexp.h -local.o: ../hdrs/switches.h lock.o: ../hdrs/copyrite.h lock.o: ../config.h lock.o: ../hdrs/conf.h diff --git a/src/bsd.c b/src/bsd.c index 11350bc..0e4aebe 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -476,6 +476,10 @@ main(int argc, char **argv) FILE *id; #endif FILE *newerr; + struct module_entry_t *m; + void (*handle)(); + + /* read the configuration file */ if (argc < 2) { @@ -647,8 +651,10 @@ main(int argc, char **argv) #endif dump_database(); - - local_shutdown(); + + /* Replacement for local_shutdown */ + MODULE_ITER(m) + MODULE_FUNC_NOARGS(handle, m->handle, "module_shutdown"); #ifdef RPMODE_SYS rplog_shutdown(); @@ -2940,7 +2946,7 @@ dump_messages(DESC *d, dbref player, int isnew) do_look_around(player); if (Haven(player)) notify(player, T("Your HAVEN flag is set. You cannot receive pages.")); - local_connect(player, isnew, num); + /* Replacement for local_connect */ MODULE_ITER(m) MODULE_FUNC(handle, m->handle, "module_connect", player, isnew, num); @@ -3850,6 +3856,10 @@ announce_disconnect(dbref player) char tbuf1[BUFFER_LEN]; dbref zone, obj; int j; + struct module_entry_t *m; + void (*handle)(dbref, int); + + loc = Location(player); if (!GoodObject(loc)) @@ -3946,7 +3956,11 @@ announce_disconnect(dbref player) set_flag_internal(player, "GOING"); set_flag_internal(player, "GOING_TWICE"); } - local_disconnect(player, num); + /* Replacement for local_disconnect */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_disconnect", player, num); + + } /** Set an motd message. @@ -5759,6 +5773,9 @@ static int do_su_exit(DESC *d) { void do_reboot(dbref player, int flag) { + struct module_entry_t *m; + void (*handle)(); + if (player == NOTHING) { flag_broadcast(0, 0, T @@ -5794,7 +5811,9 @@ do_reboot(dbref player, int flag) #if !defined(COMPILE_CONSOLE) && defined(INFO_SLAVE) kill_info_slave(); #endif - local_shutdown(); + /* Replacement for local_shutdown */ + MODULE_ITER(m) + MODULE_FUNC_NOARGS(handle, m->handle, "module_shutdown"); end_all_logs(); #ifndef WIN32 execl("netmush", "netmush", confname, NULL); diff --git a/src/cmdlocal.dst b/src/cmdlocal.dst deleted file mode 100644 index bca7a19..0000000 --- a/src/cmdlocal.dst +++ /dev/null @@ -1,80 +0,0 @@ -/*----------------------------------------------------------------- - * Local stuff - * - * This file contains custom stuff, and some of the items here are - * called from within PennMUSH at specific times. - */ - -/* Here are some includes you're likely to need or want. - */ -#include "copyrite.h" -#include "config.h" -#include -#include "conf.h" -#include "externs.h" -#include "parse.h" -#include "htab.h" -#include "flags.h" -#include "command.h" -#include "cmds.h" -#include "confmagic.h" - -extern HASHTAB htab_reserved_aliases; - -/* Called during the command init sequence before any commands are - * added (including local_commands, below). This is where you - * want to reserve any strings that you *don't* want any command - * to alias to (because you want to preserve it for matching exits - * or globals) - */ -void -reserve_aliases() -{ -#ifdef EXAMPLE - /* Example: Don't alias any commands to cardinal directions. - * Remove the #ifdef EXAMPLE and #endif to use this code - */ - reserve_alias("W"); - reserve_alias("E"); - reserve_alias("S"); - reserve_alias("N"); - reserve_alias("NW"); - reserve_alias("NE"); - reserve_alias("SW"); - reserve_alias("SE"); - reserve_alias("U"); - reserve_alias("D"); -#endif -} - -#ifdef EXAMPLE -COMMAND (cmd_local_silly) { - if (SW_ISSET(sw, SWITCH_NOISY)) - notify_format(player, "Noisy silly with %s", arg_left); - notify_format(player, "SillyCommand %s", arg_left); -} -#endif - - -/* Called during the command init sequence. - * This is where you'd put calls to command_add to insert a local - * command into the command hash table. Any command you add here - * will be auto-aliased for you. - * The way to call command_add is illustrated below. The arguments are: - * Name of the command, a string ("@SILLY") - * Command parsing modifiers, a bitmask (see hdrs/command.h) - * Flags to restrict command to, a string ("TRUST") or NULL - * (Someone with *any* one of these flags can use the command) - * Powers to restrict command to, a string ("Site Privilege") or NULL - * (Someone with this power can use the command) - * Switches the command can take, a string or NULL ("NOISY NOEVAL") - * Hardcoded function the command should call (cmd_local_silly) - */ -void -local_commands() -{ -#ifdef EXAMPLE - command_add("@SILLY", CMD_T_ANY, NULL, NULL, "NOISY NOEVAL", - cmd_local_silly); -#endif -} diff --git a/src/command.c b/src/command.c index c6882ba..d0adc1f 100644 --- a/src/command.c +++ b/src/command.c @@ -638,7 +638,7 @@ command_init_preconfig(void) ptab_init(&ptab_command); hashinit(&htab_reserved_aliases, 16, sizeof(COMMAND_INFO)); - reserve_aliases(); +/* reserve_aliases(); this can now be handeled in respective modules */ ptab_start_inserts(&ptab_command); for (cmd = commands; cmd->name; cmd++) { ptab_insert(&ptab_command, cmd->name, @@ -653,7 +653,7 @@ command_init_preconfig(void) ptab_insert(&ptab_command_perms, c->name, c); ptab_end_inserts(&ptab_command_perms); - local_commands(); + /* no longer needed with modules. local_commands(); */ } /** Initialize commands (after reading config file). diff --git a/src/create.c b/src/create.c index 12bfdea..ad8dc65 100644 --- a/src/create.c +++ b/src/create.c @@ -9,6 +9,7 @@ #include "copyrite.h" #include "config.h" #include +#include #include "conf.h" #include "externs.h" #include "mushdb.h" @@ -23,6 +24,9 @@ #include "game.h" #include "command.h" #include "confmagic.h" +#include "modules.h" + +extern struct module_entry_t *module_list; static dbref parse_linkable_room(dbref player, const char *room_name); static dbref check_var_link(const char *dest_name); @@ -92,6 +96,10 @@ dbref do_real_open(dbref player, const char *direction, const char *linkto, dbref pseudo) { + struct module_entry_t *m; + void (*handle)(dbref); + + dbref loc = (pseudo != NOTHING) ? pseudo : (IsExit(player) ? Source(player) : Location(player)); @@ -154,7 +162,10 @@ do_real_open(dbref player, const char *direction, const char *linkto, } } current_state.exits++; - local_data_create(new_exit); + /* Replacement for local_data_create */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_create", new_exit); + return new_exit; } return NOTHING; @@ -388,6 +399,8 @@ do_link(dbref player, const char *name, const char *room_name, int preserve) dbref do_dig(dbref player, const char *name, char **argv, int tport) { + struct module_entry_t *m; + void (*handle)(dbref); dbref room; /* we don't need to know player's location! hooray! */ @@ -418,7 +431,11 @@ do_dig(dbref player, const char *name, char **argv, int tport) do_real_open(player, argv[2], "here", room); } current_state.rooms++; - local_data_create(room); + + /* Replacement for local_data_create */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_create", room); + if (tport) { /* We need to use the full command, because we need NO_TEL * and Z_TEL checking */ @@ -443,6 +460,8 @@ do_dig(dbref player, const char *name, char **argv, int tport) dbref do_create(dbref player, char *name, int cost) { + struct module_entry_t *m; + void (*handle)(dbref); dbref loc; dbref thing; @@ -491,7 +510,10 @@ do_create(dbref player, char *name, int cost) /* and we're done */ notify_format(player, "Created: Object %s.", unparse_dbref(thing)); current_state.things++; - local_data_create(thing); + /* Replacement for local_data_create */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_create", thing); + return thing; } return NOTHING; @@ -556,6 +578,8 @@ clone_object(dbref player, dbref thing, const char *newname, int preserve) dbref do_clone(dbref player, char *name, char *newname, int preserve) { + struct module_entry_t *m; + void (*handle)(dbref , dbref); dbref clone, thing; char dbnum[BUFFER_LEN]; @@ -595,7 +619,10 @@ do_clone(dbref player, char *name, char *newname, int preserve) else moveto(clone, Location(player)); current_state.things++; - local_data_clone(clone, thing); + /* Replacement for local_data_clone */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_clone", clone,thing); + real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; @@ -608,7 +635,9 @@ do_clone(dbref player, char *name, char *newname, int preserve) Exits(clone) = NOTHING; notify_format(player, T("Cloned: Room #%d."), clone); current_state.rooms++; - local_data_clone(clone, thing); + /* local_data_clone replacement */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_clone", clone,thing); real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; @@ -660,8 +689,10 @@ do_clone(dbref player, char *name, char *newname, int preserve) if (Warnings(clone) || DPBITS(clone)) notify(player, T("Warning: @CLONE/PRESERVE on an exit with powers or warnings.")); notify_format(player, T("Cloned: Exit #%d."), clone); - local_data_clone(clone, thing); - return clone; + /* Replacement for local_data_clone */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_clone", clone,thing); + return clone; } } return NOTHING; @@ -778,6 +809,9 @@ void copy_zone(dbref executor, dbref zmo) { dbref copy_room(dbref room, dbref newowner) { dbref new_room; + struct module_entry_t *m; + void (*handle)(dbref); + /* Copy room and all its shit but not exits or zone */ new_room = new_object(); @@ -817,7 +851,10 @@ dbref copy_room(dbref room, dbref newowner) { /* spruce up more later.. just copying basic room for now */ current_state.rooms++; - local_data_create(room); + + /* Replacement for local_data_create */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_create", room); return new_room; } diff --git a/src/db.c b/src/db.c index 93ec80b..6289a68 100644 --- a/src/db.c +++ b/src/db.c @@ -18,6 +18,7 @@ #include #endif #include +#include #include "conf.h" #include "dbio.h" #include "externs.h" @@ -35,6 +36,9 @@ #include "htab.h" #include "extmail.h" #include "confmagic.h" +#include "modules.h" + +extern struct module_entry_t *module_list; #ifdef WIN32 #pragma warning( disable : 4761) /* disable warning re conversion */ @@ -2143,6 +2147,9 @@ clear_objdata(dbref thing) void create_minimal_db(void) { + struct module_entry_t *m; + void (*handle)(dbref); + dbref start_room, god, master_room, master_division; int desc_flags = AF_VISUAL | AF_NOPROG | AF_PREFIXMATCH; @@ -2181,7 +2188,10 @@ create_minimal_db(void) PUSH(god, Contents(start_room)); add_player(god); s_Pennies(god, START_BONUS); - local_data_create(god); + + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_create", god); + current_state.players++; set_name(master_room, "Master Room"); diff --git a/src/destroy.c b/src/destroy.c index 86992fb..888db1c 100644 --- a/src/destroy.c +++ b/src/destroy.c @@ -58,6 +58,7 @@ #include #include #include +#include #include "copyrite.h" #include "conf.h" @@ -73,8 +74,10 @@ #include "flags.h" #include "lock.h" #include "confmagic.h" +#include "modules.h" +extern struct module_entry_t *module_list; dbref first_free = NOTHING; /**< Object at top of free list */ @@ -607,10 +610,16 @@ undestroy(dbref player, dbref thing) void free_object(dbref thing) { + struct module_entry_t *m; + void (*handle)(dbref); + dbref i, loc; if (!GoodObject(thing)) return; - local_data_free(thing); + + /* Replacement for data_free */ + MODULE_ITER(m) + MODULE_FUNC(handle, m->handle, "module_data_free", thing); switch (Typeof(thing)) { case TYPE_DIVISION: @@ -1027,13 +1036,19 @@ do_purge(dbref player) void dbck(void) { + struct module_entry_t *m; + void (*handle)(); + check_fields(); check_contents(); check_locations(); check_connected_rooms(); check_zones(); check_divisions(); - local_dbck(); + + /* Replacement for local_dbck */ + MODULE_ITER(m) + MODULE_FUNC_NOARGS(handle, m->handle, "module_dbck"); } /* Do division integrity checks */ diff --git a/src/flaglocal.dst b/src/flaglocal.dst deleted file mode 100644 index dc87986..0000000 --- a/src/flaglocal.dst +++ /dev/null @@ -1,41 +0,0 @@ -/*----------------------------------------------------------------- - * Local flags - * - * This file is reserved for local flags that you may wish - * to hack into PennMUSH. - * This file will not be overwritten when you update - * to a new distribution, so it's preferable to add new flags - * here and leave flag.c alone. - * - * YOU ARE RESPONSIBLE FOR SEEING THAT YOU DO THIS RIGHT - - * It's probably smarter to have God @flag/add rather than - * do it here, as @flag/add does extensive checks for safety, - * and add_flag() doesn't! Remember that flags are saved in the - * database, so flags added here won't overwrite flags that - * are already defined. When in doubt, use @flag. - * - * It is explicitly safe to try to add_flag() an existing flag. - * It won't do anything, but it won't be harmful. - * - */ - -/* Here are some includes you're likely to need or want. - */ -#include "copyrite.h" -#include "config.h" -#include -#include "conf.h" -#include "externs.h" -#include "flags.h" -#include "confmagic.h" - -void local_flags(void); - - -void -local_flags() -{ -#ifdef EXAMPLE - add_flag("BIG", 'B', TYPE_PLAYER | TYPE_THING, F_ANY, F_ANY); -#endif -} diff --git a/src/flags.c b/src/flags.c index ed65b22..60fe595 100644 --- a/src/flags.c +++ b/src/flags.c @@ -788,8 +788,6 @@ flag_add_additional(void) flag_add(hashfind("FLAG", &htab_flagspaces), "CHAN_FIRSTMATCH", f); if (!match_flag("CHAN_MATCHFIRST")) flag_add(hashfind("FLAG", &htab_flagspaces), "CHAN_MATCHFIRST", f); - - local_flags(); } /** Extract object type from old-style flag value. diff --git a/src/function.c b/src/function.c index 147e43a..d85e0b1 100644 --- a/src/function.c +++ b/src/function.c @@ -29,7 +29,6 @@ #include "confmagic.h" static void func_hash_insert(const char *name, FUN *func); -extern void local_functions(void); static int apply_restrictions(unsigned int result, const char *restriction); USERFN_ENTRY *userfn_tab; /**< Table of user-defined functions */ @@ -852,7 +851,7 @@ init_func_hashtab(void) for (ftp = flist; ftp->name; ftp++) { function_add(ftp->name, ftp->fun, ftp->minargs, ftp->maxargs, ftp->flags); } - local_functions(); + /* local_functions() no longer needed with modules */ } /** Function initization to perform after reading the config file. diff --git a/src/funlocal.dst b/src/funlocal.dst deleted file mode 100644 index 53c780a..0000000 --- a/src/funlocal.dst +++ /dev/null @@ -1,45 +0,0 @@ -/*----------------------------------------------------------------- - * Local functions - * - * This file is reserved for local functions that you may wish - * to hack into PennMUSH. Read parse.h for information on adding - * functions. This file will not be overwritten when you update - * to a new distribution, so it's preferable to add new functions - * here and leave the other fun*.c files alone. - * - */ - -/* Here are some includes you're likely to need or want. - * If your functions are doing math, include , too. - */ -#include "copyrite.h" -#include "config.h" -#include -#include "conf.h" -#include "externs.h" -#include "parse.h" -#include "confmagic.h" -#include "boolexp.h" -#include "function.h" - -void local_functions(void); - -/* Here you can use the new add_function instead of hacking into function.c - * Example included :) - */ - -#ifdef EXAMPLE -FUNCTION(local_fun_silly) -{ - safe_format(buff, bp, "Silly%sSilly", args[0]); -} - -#endif - -void -local_functions() -{ -#ifdef EXAMPLE - function_add("SILLY", local_fun_silly, 1, 1, FN_REG); -#endif -} diff --git a/src/game.c b/src/game.c index c516547..dc4cb1c 100644 --- a/src/game.c +++ b/src/game.c @@ -356,7 +356,7 @@ dump_database_internal(void) #endif return 1; } else { - local_dump_database(); + /* Replacement local_dump_database */ MODULE_ITER(m) MODULE_FUNC_NOARGS(handle, m->handle, "module_dump_database"); @@ -804,7 +804,7 @@ init_game_config(const char *conf) memset(¤t_state, 0, sizeof current_state); /* Load all the config file stuff except restrict_* */ - local_configs(); + /* local_configs() replacement */ MODULE_ITER(m) MODULE_FUNC_NOARGS(handler, m->handle, "module_configs"); @@ -855,7 +855,7 @@ init_game_postdb(const char *conf) start_cron(); /* Start the MUSH Cron Daemon */ #endif /* CRON */ /* Call Local Startup */ - local_startup(); + /* local_startup() replacement */ MODULE_ITER(m) MODULE_FUNC_NOARGS(handle, m->handle, "module_startup"); diff --git a/src/local.dst b/src/local.dst deleted file mode 100644 index b38bcea..0000000 --- a/src/local.dst +++ /dev/null @@ -1,267 +0,0 @@ -/*----------------------------------------------------------------- - * Local stuff - * - * This file contains custom stuff, and some of the items here are - * called from within PennMUSH at specific times. - */ - -/* Here are some includes you're likely to need or want. - */ -#include "copyrite.h" -#include "config.h" -#include -#include "conf.h" -#include "dbio.h" -#include "externs.h" -#include "parse.h" -#include "htab.h" -#include "command.h" -#include "confmagic.h" - -extern HASHTAB htab_reserved_aliases; - -/* Called after all MUSH init is done. - */ -void -local_startup(void) -{ -} - -/* Add you own runtime configuration options here, and you can set - * them in mush.cnf. - */ -void -local_configs() -{ -#ifdef EXAMPLE - /* For each config parameter you add, you should initialize it as a - * static variable here (or a global variable elsewhere in your - * code) - */ - static int config_example = 1; - static char config_string[BUFFER_LEN]; -#endif - - /* Initial size of this hashtable should be close to the number of - * add_config()'s you plan to do. - */ - hashinit(&local_options, 4, sizeof(COBRA_CONF)); - -#ifdef EXAMPLE - /* Call add_config for each config parameter you want to add. - * Note the use of &config_example for simple types (bool, int), - * but just config_string for strings. - */ - add_config("use_example", cf_bool, &config_example, sizeof config_example, - "cosmetic"); - add_config("some_string", cf_str, config_string, sizeof config_string, - "cosmetic"); -#endif -} - - -/* Wrap any calls to stdio functions in local_dump_database() and stuff - * it calls in the OUTPUT() macro, which does error checking so we can - * report problems with a save so it's caught before damage is - * done and you loose a db. . putref(), putstring(), and such don't need - * them. - * For example: - * - * putref(fp, 18); - * OUTPUT(putc('\n', fp)); - */ - -/* Called when the database will be saved - * This is called JUST before we dump the - * database to disk - * Use to save any in-memory structures - * back to disk - */ -void -local_dump_database(void) -{ -} - -/* Called when the MUSH is shutting down. - * The DB has been saved and descriptors closed - * The log files are still open though. - */ -void -local_shutdown(void) -{ -} - -/* Called when the MUSH is performing a dbck database check, - * at the end of the check. A good place to add any regular - * consistency checking you require. - */ -void -local_dbck(void) -{ -} - -/* This is called exactly once a second - * After the MUSH has done all it's stuff - */ -void -local_timer(void) -{ -} - -/* Called when a player connects. If this is a new creation, - * isnew will be true. num gives the number of connections by - * that player (so if num > 1, this is a multiple connect). - */ -void -local_connect(dbref player __attribute__ ((__unused__)), - int isnew __attribute__ ((__unused__)), - int num __attribute__ ((__unused__))) -{ -} - -/* Called when a player disconnects. If num > 1, this is - * a partial disconnect. - */ -void -local_disconnect(dbref player __attribute__ ((__unused__)), - int num __attribute__ ((__unused__))) -{ -} - - -/* For serious hackers only */ - -/* Those who are depraved enough to do so (Like me), can always - * abuse this as a new and better way of Always Doing Stuff - * to objects. - * Like, say you want to put out a message on the admin - * channel every time an object is destroyed, do so in the - * local_data_destroy() routine. - */ - -/* Called when a object is created with @create (or @dig, @link) - * This is done AFTER object-specific setup, so the types - * etc will already be set, and object-specific initialization - * will be done. - * Note that the game will ALWAYS set the LocData to NULL before - * this routine is called. - */ - -/* For a well-commented example of how to use this code, - * see: ftp://bimbo.hive.no/pub/PennMUSH/coins.tar.gz - */ - -void -local_data_create(dbref object __attribute__ ((__unused__))) -{ -} - -/* Called when an object is cloned. Since clone is a rather - * specific form of creation, it has it's own function. - * Note that local_data_create() is NOT called for this object - * first, but the system will always set LocData to NULL first. - * Clone is the 'new' object, while source is the one it's - * being copied from. - */ - -void -local_data_clone(dbref clone __attribute__ ((__unused__)), - dbref source __attribute__ ((__unused__))) -{ -} - -/* Called when a object is REALLY destroyed, not just set - * Going. - */ - -void -local_data_free(dbref object __attribute__ ((__unused__))) -{ -} - -/* Initiation of objects after a reload or dumping to disk should - * be handled in local_dump_database() and local_startup(). - */ - - -/* This function is called *before* most standard interaction checks, - * and can override them. You probably want to do as little as possible - * here and do most of the work in local_can_interact_last instead. - * If this returns NOTHING, it means 'go on to more checks' - */ -int -local_can_interact_first(dbref from __attribute__ ((__unused__)), - dbref to __attribute__ ((__unused__)), int type - __attribute__ ((__unused__))) -{ - - return NOTHING; -} - -/* This one is called *after* most standard interaction checks. */ -int -local_can_interact_last(dbref from __attribute__ ((__unused__)), - dbref to __attribute__ ((__unused__)), int type - __attribute__ ((__unused__))) -{ - /* from is where the message is coming from, in theory. It makes sense - * for sound, but think of it as light rays for visiblity or matching. - * The rays come *from* someone standing in a room, and go *to* the person - * looking around. - */ - -#ifdef NEVER - /* Various examples follow */ - - switch (type) { - case INTERACT_SEE: - /* Someone standing in a room, or doing - * @verb type stuff that's @bar, @obar, and @abar - */ - - /* Probably a good idea */ - if (See_All(to)) - return 1; - - break; - - case INTERACT_PRESENCE: - /* Someone arriving or leaving, connecting or disconnecting, - * and (for objects) growing or losing ears. - */ - - /* To prevent spying, always notice presence */ - return 1; - - break; - - case INTERACT_HEAR: - /* People talking */ - - /* Telepathy example. Players who can hear telepathy get @set - * HEAR_TELEPATHY, players currently using telepathy should be - * @set USE_TELEPATHY. */ - - if (has_flag_by_name(from, "USE_TELEPATHY", NOTYPE)) - return has_flag_by_name(to, "HEAR_TELEPATHY", NOTYPE); - - break; - - case INTERACT_MATCH: - /* Matching object names so you can pick them up, go through exits, - etc. */ - - break; - } - - /* Splits the universe in half, half FOO and half not. */ - return (has_flag_by_name(to, "FOO", NOTYPE) == - has_flag_by_name(from, "FOO", NOTYPE)); - - -#endif /* NEVER */ - - /* You want to return NOTHING if you haven't made up your mind */ - return NOTHING; - -} diff --git a/src/player.c b/src/player.c index 72fc8dc..7742243 100644 --- a/src/player.c +++ b/src/player.c @@ -464,7 +464,7 @@ make_player(const char *name, const char *password, const char *host, current_state.players++; - local_data_create(player); + /* Replacement for local_data_create */ MODULE_ITER(m) MODULE_FUNC(handle, m->handle, "module_data_create", player); diff --git a/src/timer.c b/src/timer.c index f661c76..95aed0a 100644 --- a/src/timer.c +++ b/src/timer.c @@ -300,8 +300,7 @@ dispatch(void) rplog_reset(); #endif - local_timer(); - + /* Replacement for local_timer */ MODULE_ITER(m) MODULE_FUNC_NOARGS(handle, m->handle, "module_timer"); } diff --git a/src/utils.c b/src/utils.c index 25bc7d6..9cbbfe6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -32,6 +32,7 @@ #include #include /* For GetCurrentProcessId() */ #endif +#include #include "conf.h" #include "match.h" @@ -45,6 +46,10 @@ #include "parse.h" #include "lock.h" #include "confmagic.h" +#include "modules.h" + + +extern struct module_entry_t *module_list; dbref find_entrance(dbref door); void initialize_mt(void); @@ -791,6 +796,8 @@ int can_interact(dbref from, dbref to, int type) { int lci; + struct module_entry_t *m; + int (*handle)(dbref, dbref, int); /* This shouldn't even be checked for rooms and garbage, but we're * paranoid. Trying to stop interaction with yourself will not work 99% @@ -802,9 +809,14 @@ can_interact(dbref from, dbref to, int type) return 1; /* This function can override standard checks! */ - lci = local_can_interact_first(from, to, type); - if (lci != NOTHING) - return lci; + /* This doohicky is the replacement for local_can_interact_first */ + MODULE_ITER(m) { + handle = MODULE_FUNCRET(m->handle, "module_can_interact_first") + if(handle) { + if((lci = handle(from, to , type)) != NOTHING) + return lci; + } + } /* Standard checks */ @@ -822,9 +834,13 @@ can_interact(dbref from, dbref to, int type) if ((from == Location(to)) || (to == Location(from)) || controls(to, from)) return 1; - lci = local_can_interact_last(from, to, type); - if (lci != NOTHING) - return lci; + MODULE_ITER(m) { + handle = MODULE_FUNCRET(m->handle, "module_can_interact_first") + if(handle) { + if((lci = handle(from, to , type)) != NOTHING) + return lci; + } + } return 1; }