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

14
lib/world/qst/0.qst Normal file
View file

@ -0,0 +1,14 @@
#0
Undefined~
Quest definition is incomplete.~
There is no information on this quest.
~
You have completed the quest.
~
You have abandoned the quest.
~
-1 -1 0 -1 -1 -1 -1
0 0 0 34 -1 -1 1
0 0 65535
S
$~

2
lib/world/qst/index Normal file
View file

@ -0,0 +1,2 @@
0.qst
$

2
lib/world/qst/index.mini Normal file
View file

@ -0,0 +1,2 @@
0.qst
$

View file

@ -24,7 +24,7 @@ OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \ castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \ house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \ objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \
spells.o utils.o weather.o players.o spells.o utils.o weather.o players.o quest.o qedit.o genqst.o
default: .accepted default: .accepted
$(MAKE) ../bin/circle $(MAKE) ../bin/circle
@ -192,3 +192,12 @@ utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \ weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c $(CC) -c $(CFLAGS) weather.c
quest.o: quest.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h \
comm.h db.h screen.h quest.h
$(CC) -c $(CFLAGS) quest.c
qedit.o: qedit.c conf.h sysdep.h structs.h utils.h comm.h db.h oasis.h \
improved-edit.h screen.h genolc.h genzon.h interpreter.h quest.h
$(CC) -c $(CFLAGS) qedit.c
genqst.o: genqst.c conf.h sysdep.h structs.h utils.h db.h quest.h \
genolc.h genzon.h
$(CC) -c $(CFLAGS) genqst.c

View file

@ -26,7 +26,7 @@ OBJFILES = o.comm act.o.comm act.o.informative act.o.movement act.o.item \
o.castle o.class o.config o.constants o.db o.fight o.graph o.handler \ o.castle o.class o.config o.constants o.db o.fight o.graph o.handler \
o.house o.interpreter o.limits o.magic o.mail o.mobact o.modify \ o.house o.interpreter o.limits o.magic o.mail o.mobact o.modify \
o.objsave o.random o.shop o.spec_assign o.spec_procs \ o.objsave o.random o.shop o.spec_assign o.spec_procs \
o.spell_parser o.spells o.utils o.weather o.players o.spell_parser o.spells o.utils o.weather o.players o.quest o.qedit o.genqst
default: all default: all
@ -153,3 +153,15 @@ o.utils: c.utils h.conf h.sysdep h.structs h.utils h.comm h.screen h.spells \
o.weather: c.weather h.conf h.sysdep h.structs h.utils h.comm h.handler \ o.weather: c.weather h.conf h.sysdep h.structs h.utils h.comm h.handler \
h.interpreter h.db h.interpreter h.db
$(CC) -c $(CFLAGS) c.weather $(CC) -c $(CFLAGS) c.weather
o.players: c.players h.conf h.sysdep h.structs h.utils h.db h.handler \
h.pfdefaults h.dg_scripts h.comm h.interpreter h.genolc h.config h.spells
$(CC) -c $(CFLAGS) c.players
o.quest: c.quest h.conf h.sysdep h.structs h.utils h.interpreter h.handler \
h.comm h.db h.screen h.quest
$(CC) -c $(CFLAGS) quest.c
o.qedit: c.qedit h.conf h.sysdep h.structs h.utils h.comm h.db h.oasis \
h.improved-edit h.screen h.genolc h.genzon h.interpreter h.quest
$(CC) -c $(CFLAGS) qedit.c
o.genqst: c.genqst h.conf h.sysdep h.structs h.utils h.db h.quest \
h.genolc h.genzon
$(CC) -c $(CFLAGS) genqst.c

View file

@ -78,7 +78,10 @@ Dep_circledexe = \
spec_procs.obj\ spec_procs.obj\
spec_assign.obj\ spec_assign.obj\
utils.obj\ utils.obj\
weather.obj weather.obj\
quest.obj\
qedit.obj\
genqst.obj
circle.exe : $(Dep_circledexe) circle.exe : $(Dep_circledexe)
$(TLINK32) @&&| $(TLINK32) @&&|
@ -119,7 +122,10 @@ spell_parser.obj+
spec_procs.obj+ spec_procs.obj+
spec_assign.obj+ spec_assign.obj+
utils.obj+ utils.obj+
weather.obj weather.obj+
quest.obj+
qedit.obj+
genqst.obj
$<,$* $<,$*
C:\BC5\LIB\bidsfi.lib+ C:\BC5\LIB\bidsfi.lib+
C:\BC5\LIB\import32.lib+ C:\BC5\LIB\import32.lib+
@ -306,6 +312,21 @@ weather.obj : weather.c
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c $(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c
| |
quest.obj : quest.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ quest.c
|
qedit.obj : qedit.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ qedit.c
|
genqst.obj : genqst.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ genqst.c
|
# Compiler configuration file # Compiler configuration file
BccW32.cfg : BccW32.cfg :
Copy &&| Copy &&|

View file

@ -79,7 +79,10 @@ Dep_circledexe = \
spec_procs.obj\ spec_procs.obj\
spec_assign.obj\ spec_assign.obj\
utils.obj\ utils.obj\
weather.obj weather.obj\
quest.obj\
qedit.obj\
genqst.obj
circle.exe : $(Dep_circledexe) circle.exe : $(Dep_circledexe)
$(TLINK32) @&&| $(TLINK32) @&&|
@ -120,7 +123,10 @@ spell_parser.obj+
spec_procs.obj+ spec_procs.obj+
spec_assign.obj+ spec_assign.obj+
utils.obj+ utils.obj+
weather.obj weather.obj+
quest.obj+
qedit.obj+
genqst.obj
$<,$* $<,$*
C:\BORLAND\BCC55\LIB\import32.lib+ C:\BORLAND\BCC55\LIB\import32.lib+
C:\BORLAND\BCC55\LIB\cw32i.lib C:\BORLAND\BCC55\LIB\cw32i.lib
@ -306,6 +312,21 @@ weather.obj : weather.c
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c $(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c
| |
quest.obj : quest.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ quest.c
|
qedit.obj : qedit.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ qedit.c
|
genqst.obj : genqst.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ genqst.c
|
# Compiler configuration file # Compiler configuration file
BccW32.cfg : BccW32.cfg :
Copy &&| Copy &&|

View file

@ -1,12 +1,9 @@
# CircleMUD Makefile.in - Makefile template used by 'configure' # tbaMUD Makefile.in - Makefile template used by 'configure'
# # Clean-up provided by seqwith.
# C compiler to use # C compiler to use
CC = @CC@ CC = @CC@
# Path to cxref utility
CXREF = cxref
# Any special flags you want to pass to the compiler # Any special flags you want to pass to the compiler
MYFLAGS = @MYFLAGS@ MYFLAGS = @MYFLAGS@
@ -23,31 +20,8 @@ CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE)
LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@ LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@
OBJFILES = act.comm.o act.informative.o act.item.o act.movement.o \ SRCFILES := $(wildcard *.c)
act.offensive.o act.other.o act.social.o act.wizard.o aedit.o \ OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
ban.o boards.o bsd-snprintf.o castle.o cedit.o class.o comm.o config.o \
constants.o db.o dg_comm.o dg_db_scripts.o dg_event.o \
dg_handler.o dg_misc.o dg_mobcmd.o dg_objcmd.o dg_olc.o dg_scripts.o \
dg_triggers.o dg_variables.o dg_wldcmd.o fight.o genmob.o \
genobj.o genolc.o genshp.o genwld.o genzon.o graph.o handler.o hedit.o \
house.o improved-edit.o interpreter.o limits.o magic.o mail.o medit.o \
mobact.o modify.o oasis.o oasis_copy.o oasis_delete.o oasis_list.o \
objsave.o oedit.o players.o random.o redit.o sedit.o shop.o \
spec_assign.o spec_procs.o spell_parser.o spells.o tedit.o utils.o \
weather.o zedit.o zmalloc.o
CXREF_FILES = act.comm.c act.informative.c act.item.c act.movement.c \
act.offensive.c act.other.c act.social.c act.wizard.c aedit.c \
ban.c boards.c bsd-snprintf.c castle.c cedit.c class.c comm.c config.c \
constants.c db.c dg_comm.c dg_db_scripts.c dg_event.c \
dg_handler.c dg_misc.c dg_mobcmd.c dg_objcmd.c dg_olc.c dg_scripts.c \
dg_triggers.c dg_variables.c dg_wldcmd.c fight.c genmob.c \
genobj.c genolc.c genshp.c genwld.c genzon.c graph.c handler.c hedit.c \
house.c improved-edit.c interpreter.c limits.c magic.c mail.c medit.c \
mobact.c modify.c oasis.c oasis_copy.c oasis_delete.c oasis_list.c \
objsave.c oedit.c players.c random.c redit.c sedit.c shop.c \
spec_assign.c spec_procs.c spell_parser.c spells.c tedit.c utils.c \
weather.c zedit.c zmalloc.c
default: all default: all
@ -60,48 +34,18 @@ all: .accepted
utils: .accepted utils: .accepted
(cd util; $(MAKE) all) (cd util; $(MAKE) all)
circle: circle:
$(MAKE) $(BINDIR)/circle $(MAKE) $(BINDIR)/circle
$(BINDIR)/circle : $(OBJFILES) $(BINDIR)/circle : $(OBJFILES)
$(CC) -o $(BINDIR)/circle $(PROFILE) $(OBJFILES) $(LIBS) $(CC) -o $(BINDIR)/circle $(PROFILE) $(OBJFILES) $(LIBS)
$%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@
clean: clean:
rm -f *.o rm -f *.o depend
ref:
#
# Create the cross reference files
# Note, this is not meant to be used unless you've installed cxref...
#
@for file in $(CXREF_FILES) ; do \
echo Cross referencing $$file ; \
$(CXREF) -D__CXREF__ -xref -Odoc -Ncircle $$file ; \
done
#
# Create the source files using cxref
#
@for file in $(CXREF_FILES) ; do \
echo Documenting $$file ; \
( cd . ; $(CXREF) -D__CXREF__ -warn-xref -xref -Odoc -Ncircle -html $$file ) ; \
rm -f $(DOCS) ; \
done
#
# Create the index using cxref
#
@echo Indexing
@( cd . ; $(CXREF) -D__CXREF__ -index-all -Odoc -Ncircle -html )
@rm -f $(DOCS)
#
# Make html files for the .h files
#
@echo Creating .h.html files...
@for file in *.h ; do \
echo $$file ; \
cat htmlh-head $$file htmlh-tail > doc/$$file.html ; \
done
# Copy over to the html directory
#cp doc/*.html $(HOME)/www/cxref
#chmod 644 $(HOME)/www/cxref/*.html
# Dependencies for the object files (automagically generated with # Dependencies for the object files (automagically generated with
# gcc -MM) # gcc -MM)

View file

@ -16,6 +16,9 @@ DISTDIR=c:\circle
CFLAGS=-c -I$(LCCDIR)\include -DLCC_WIN32 CFLAGS=-c -I$(LCCDIR)\include -DLCC_WIN32
CC=lcc CC=lcc
OBJS=\ OBJS=\
genqst.obj \
qedit.obj \
quest.obj \
weather.obj \ weather.obj \
utils.obj \ utils.obj \
spells.obj \ spells.obj \
@ -58,6 +61,52 @@ LIBS=$(LCCDIR)\lib\wsock32.lib
circle.exe: $(OBJS) circle.exe: $(OBJS)
lcclnk -subsystem console -o $(DISTDIR)\bin\circle.exe $(OBJS) $(LIBS) lcclnk -subsystem console -o $(DISTDIR)\bin\circle.exe $(OBJS) $(LIBS)
# Build GENQST.C
GENQST_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\genolc.h\
$(DISTDIR)\src\genzon.h\
$(DISTDIR)\src\quest.h\
$(DISTDIR)\src\db.h\
genqst.obj: $(GENQST_C) $(DISTDIR)\src\genqst.c
$(CC) $(CFLAGS) $(DISTDIR)\src\genqst.c
# Build QEDIT.C
QEDIT_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\oasis.h\
$(DISTDIR)\src\improved-edit.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\genolc.h\
$(DISTDIR)\src\genzon.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\quest.h\
qedit.obj: $(QEDIT_C) $(DISTDIR)\src\qedit.c
$(CC) $(CFLAGS) $(DISTDIR)\src\qedit.c
# Build QUEST.C
QUEST_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\quest.h\
quest.obj: $(QUEST_C) $(DISTDIR)\src\quest.c
$(CC) $(CFLAGS) $(DISTDIR)\src\quest.c
# Build WEATHER.C # Build WEATHER.C
WEATHER_C=\ WEATHER_C=\
$(DISTDIR)\src\sysdep.h\ $(DISTDIR)\src\sysdep.h\

View file

@ -40,7 +40,7 @@ OBJFILES = comm.obj act.comm.obj act.informative.obj act.movement.obj act.item.o
castle.obj class.obj config.obj constants.obj db.obj fight.obj graph.obj handler.obj \ castle.obj class.obj config.obj constants.obj db.obj fight.obj graph.obj handler.obj \
house.obj interpreter.obj limits.obj magic.obj mail.obj mobact.obj modify.obj \ house.obj interpreter.obj limits.obj magic.obj mail.obj mobact.obj modify.obj \
objsave.obj shop.obj spec_assign.obj spec_procs.obj spell_parser.obj \ objsave.obj shop.obj spec_assign.obj spec_procs.obj spell_parser.obj \
spells.obj utils.obj weather.obj random.obj players.obj spells.obj utils.obj weather.obj random.obj players.obj quest.obj qedit.obj genqst.obj
default: circle.exe default: circle.exe
$(MAKE) circle.exe $(MAKE) circle.exe
@ -153,3 +153,12 @@ utils.obj: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
weather.obj: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \ weather.obj: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c $(CC) -c $(CFLAGS) weather.c
quest.obj: quest.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h \
comm.h db.h screen.h quest.h
$(CC) -c $(CFLAGS) quest.c
qedit.obj: qedit.c conf.h sysdep.h structs.h utils.h comm.h db.h oasis.h \
improved-edit.h screen.h genolc.h genzon.h interpreter.h quest.h
$(CC) -c $(CFLAGS) qedit.c
genqst.obj: genqst.c conf.h sysdep.h structs.h utils.h db.h quest.h \
genolc.h genzon.h
$(CC) -c $(CFLAGS) genqst.c

View file

@ -26,7 +26,7 @@ OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \ castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \ house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \ objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \
spells.o utils.o weather.o random.o players.o spells.o utils.o weather.o random.o players.o quest.o qedit.o genqst.o
default: .accepted default: .accepted
$(MAKE) ../bin/circle $(MAKE) ../bin/circle
@ -194,3 +194,12 @@ utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \ weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c $(CC) -c $(CFLAGS) weather.c
quest.obj: quest.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h \
comm.h db.h screen.h quest.h
$(CC) -c $(CFLAGS) quest.c
qedit.obj: qedit.c conf.h sysdep.h structs.h utils.h comm.h db.h oasis.h \
improved-edit.h screen.h genolc.h genzon.h interpreter.h quest.h
$(CC) -c $(CFLAGS) qedit.c
genqst.obj: genqst.c conf.h sysdep.h structs.h utils.h db.h quest.h \
genolc.h genzon.h
$(CC) -c $(CFLAGS) genqst.c

View file

@ -19,22 +19,13 @@
#include "screen.h" #include "screen.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "act.h"
#include "modify.h"
/* local functions */ /* prototypes of local functions */
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg); /* do_tell utility functions */
int is_tell_ok(struct char_data *ch, struct char_data *vict); static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg);
ACMD(do_say); static int is_tell_ok(struct char_data *ch, struct char_data *vict);
ACMD(do_gsay);
ACMD(do_tell);
ACMD(do_reply);
ACMD(do_spec_comm);
ACMD(do_write);
ACMD(do_page);
ACMD(do_gen_comm);
ACMD(do_qcomm);
void handle_webster_file(void);
static long last_webster_teller = -1L;
ACMD(do_say) ACMD(do_say)
{ {
@ -102,7 +93,7 @@ ACMD(do_gsay)
} }
} }
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg) static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
{ {
char buf[MAX_STRING_LENGTH], *msg; char buf[MAX_STRING_LENGTH], *msg;
@ -122,7 +113,7 @@ void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
GET_LAST_TELL(vict) = GET_IDNUM(ch); GET_LAST_TELL(vict) = GET_IDNUM(ch);
} }
int is_tell_ok(struct char_data *ch, struct char_data *vict) static int is_tell_ok(struct char_data *ch, struct char_data *vict)
{ {
if (ch == vict) if (ch == vict)
send_to_char(ch, "You try to tell yourself something.\r\n"); send_to_char(ch, "You try to tell yourself something.\r\n");
@ -471,7 +462,6 @@ ACMD(do_gen_comm)
} }
if (subcmd == SCMD_GEMOTE) { if (subcmd == SCMD_GEMOTE) {
ACMD(do_gmote);
if (*argument == '*') if (*argument == '*')
do_gmote(ch, argument + 1, 0, 1); do_gmote(ch, argument + 1, 0, 1);
else else
@ -580,40 +570,3 @@ ACMD(do_qcomm)
} }
} }
void handle_webster_file(void) {
FILE *fl;
struct char_data *ch = find_char(last_webster_teller);
char info[MAX_STRING_LENGTH], line[READ_SIZE];
size_t len = 0, nlen = 0;
last_webster_teller = -1L;
if (!ch) /* they quit ? */
return;
fl = fopen("websterinfo", "r");
if (!fl) {
send_to_char(ch, "It seems Merriam-Webster is offline..\r\n");
return;
}
unlink("websterinfo");
get_line(fl, line);
while (!feof(fl)) {
nlen = snprintf(info + len, sizeof(info) - len, "%s\r\n", line);
if (len + nlen >= sizeof(info) || nlen < 0)
break;
len += nlen;
get_line(fl, line);
}
if (len >= sizeof(info)) {
const char *overflow = "\r\n**OVERFLOW**\r\n";
strcpy(info + sizeof(info) - strlen(overflow) - 1, overflow); /* strcpy: OK */
}
fclose(fl);
send_to_char(ch, "You get this feedback from Merriam-Webster:\r\n");
page_string(ch->desc, info, 1);
}

View file

@ -20,83 +20,41 @@
#include "screen.h" #include "screen.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "mail.h" /**< For the has_mail function */
#include "act.h"
#include "class.h"
#include "fight.h"
#include "modify.h"
#include "asciimap.h"
/* extern variables */ /* prototypes of local functions */
extern int top_of_helpt; /* do_diagnose utility functions */
extern struct help_index_element *help_table; static void diag_char_to_char(struct char_data *i, struct char_data *ch);
extern char *help; /* do_look and do_examine utility functions */
extern char *ihelp; static void do_auto_exits(struct char_data *ch);
extern struct time_info_data time_info; static void list_char_to_char(struct char_data *list, struct char_data *ch);
extern char *credits; static void list_one_char(struct char_data *i, struct char_data *ch);
extern char *news; static void look_at_char(struct char_data *i, struct char_data *ch);
extern char *info; static void look_at_target(struct char_data *ch, char *arg);
extern char *motd; static void look_in_direction(struct char_data *ch, int dir);
extern char *imotd; static void look_in_obj(struct char_data *ch, char *arg);
extern char *wizlist; /* do_look, do_inventory utility functions */
extern char *immlist; static void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show);
extern char *policies; /* do_look, do_equipment, do_examine, do_inventory */
extern char *handbook; static void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode);
extern char *class_abbrevs[]; static void show_obj_modifiers(struct obj_data *obj, struct char_data *ch);
/* do_where utility functions */
/* extern functions */ static void perform_immort_where(struct char_data *ch, char *arg);
ACMD(do_action); static void perform_mortal_where(struct char_data *ch, char *arg);
bitvector_t find_class_bitvector(const char *arg); static void print_object_location(int num, struct obj_data *obj, struct char_data *ch, int recur);
int level_exp(int chclass, int level);
char *title_male(int chclass, int level);
char *title_female(int chclass, int level);
struct time_info_data *real_time_passed(time_t t2, time_t t1);
int compute_armor_class(struct char_data *ch);
int has_mail(long id);
/* local functions */
int sort_commands_helper(const void *a, const void *b);
void print_object_location(int num, struct obj_data *obj, struct char_data *ch, int recur);
void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode);
void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show);
void show_obj_modifiers(struct obj_data *obj, struct char_data *ch);
ACMD(do_look);
ACMD(do_examine);
ACMD(do_gold);
ACMD(do_score);
ACMD(do_inventory);
ACMD(do_equipment);
ACMD(do_time);
ACMD(do_weather);
void space_to_minus(char *str);
ACMD(do_help);
ACMD(do_who);
ACMD(do_users);
ACMD(do_gen_ps);
void perform_mortal_where(struct char_data *ch, char *arg);
void perform_immort_where(struct char_data *ch, char *arg);
ACMD(do_where);
ACMD(do_levels);
ACMD(do_consider);
ACMD(do_diagnose);
ACMD(do_color);
ACMD(do_toggle);
void sort_commands(void);
ACMD(do_commands);
void diag_char_to_char(struct char_data *i, struct char_data *ch);
void look_at_char(struct char_data *i, struct char_data *ch);
void list_one_char(struct char_data *i, struct char_data *ch);
void list_char_to_char(struct char_data *list, struct char_data *ch);
void do_auto_exits(struct char_data *ch);
ACMD(do_exits);
void look_in_direction(struct char_data *ch, int dir);
void look_in_obj(struct char_data *ch, char *arg);
char *find_exdesc(char *word, struct extra_descr_data *list);
void look_at_target(struct char_data *ch, char *arg);
/* local globals */
int *cmd_sort_info;
/* Subcommands */
/* For show_obj_to_char 'mode'. /-- arbitrary */ /* For show_obj_to_char 'mode'. /-- arbitrary */
#define SHOW_OBJ_LONG 0 #define SHOW_OBJ_LONG 0
#define SHOW_OBJ_SHORT 1 #define SHOW_OBJ_SHORT 1
#define SHOW_OBJ_ACTION 2 #define SHOW_OBJ_ACTION 2
void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode) static void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode)
{ {
int found = 0; int found = 0;
struct char_data *temp; struct char_data *temp;
@ -194,7 +152,7 @@ void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode)
send_to_char(ch, "\r\n"); send_to_char(ch, "\r\n");
} }
void show_obj_modifiers(struct obj_data *obj, struct char_data *ch) static void show_obj_modifiers(struct obj_data *obj, struct char_data *ch)
{ {
if (OBJ_FLAGGED(obj, ITEM_INVISIBLE)) if (OBJ_FLAGGED(obj, ITEM_INVISIBLE))
send_to_char(ch, " (invisible)"); send_to_char(ch, " (invisible)");
@ -212,7 +170,7 @@ void show_obj_modifiers(struct obj_data *obj, struct char_data *ch)
send_to_char(ch, " ..It emits a faint humming sound!"); send_to_char(ch, " ..It emits a faint humming sound!");
} }
void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show) static void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int show)
{ {
struct obj_data *i, *j; struct obj_data *i, *j;
bool found; bool found;
@ -244,7 +202,7 @@ void list_obj_to_char(struct obj_data *list, struct char_data *ch, int mode, int
send_to_char(ch, " Nothing.\r\n"); send_to_char(ch, " Nothing.\r\n");
} }
void diag_char_to_char(struct char_data *i, struct char_data *ch) static void diag_char_to_char(struct char_data *i, struct char_data *ch)
{ {
struct { struct {
byte percent; byte percent;
@ -274,7 +232,7 @@ void diag_char_to_char(struct char_data *i, struct char_data *ch)
send_to_char(ch, "%c%s %s\r\n", UPPER(*pers), pers + 1, diagnosis[ar_index].text); send_to_char(ch, "%c%s %s\r\n", UPPER(*pers), pers + 1, diagnosis[ar_index].text);
} }
void look_at_char(struct char_data *i, struct char_data *ch) static void look_at_char(struct char_data *i, struct char_data *ch)
{ {
int j, found; int j, found;
struct obj_data *tmp_obj; struct obj_data *tmp_obj;
@ -318,7 +276,7 @@ void look_at_char(struct char_data *i, struct char_data *ch)
} }
} }
void list_one_char(struct char_data *i, struct char_data *ch) static void list_one_char(struct char_data *i, struct char_data *ch)
{ {
struct obj_data *furniture; struct obj_data *furniture;
const char *positions[] = { const char *positions[] = {
@ -417,7 +375,7 @@ void list_one_char(struct char_data *i, struct char_data *ch)
act("...$e glows with a bright light!", FALSE, i, 0, ch, TO_VICT); act("...$e glows with a bright light!", FALSE, i, 0, ch, TO_VICT);
} }
void list_char_to_char(struct char_data *list, struct char_data *ch) static void list_char_to_char(struct char_data *list, struct char_data *ch)
{ {
struct char_data *i; struct char_data *i;
@ -437,7 +395,7 @@ void list_char_to_char(struct char_data *list, struct char_data *ch)
} }
} }
void do_auto_exits(struct char_data *ch) static void do_auto_exits(struct char_data *ch)
{ {
int door, slen = 0; int door, slen = 0;
@ -529,7 +487,16 @@ void look_at_room(struct char_data *ch, int ignore_brief)
if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief || if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief ||
ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH))
{
if(!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch))
{
str_and_map(world[IN_ROOM(ch)].description, ch);
}
else
{
send_to_char(ch, "%s", world[IN_ROOM(ch)].description); send_to_char(ch, "%s", world[IN_ROOM(ch)].description);
}
}
/* autoexits */ /* autoexits */
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT))
@ -540,7 +507,7 @@ void look_at_room(struct char_data *ch, int ignore_brief)
list_char_to_char(world[IN_ROOM(ch)].people, ch); list_char_to_char(world[IN_ROOM(ch)].people, ch);
} }
void look_in_direction(struct char_data *ch, int dir) static void look_in_direction(struct char_data *ch, int dir)
{ {
if (EXIT(ch, dir)) { if (EXIT(ch, dir)) {
if (EXIT(ch, dir)->general_description) if (EXIT(ch, dir)->general_description)
@ -556,7 +523,7 @@ void look_in_direction(struct char_data *ch, int dir)
send_to_char(ch, "Nothing special there...\r\n"); send_to_char(ch, "Nothing special there...\r\n");
} }
void look_in_obj(struct char_data *ch, char *arg) static void look_in_obj(struct char_data *ch, char *arg)
{ {
struct obj_data *obj = NULL; struct obj_data *obj = NULL;
struct char_data *dummy = NULL; struct char_data *dummy = NULL;
@ -629,7 +596,7 @@ char *find_exdesc(char *word, struct extra_descr_data *list)
* matches the target. First, see if there is another char in the room with * matches the target. First, see if there is another char in the room with
* the name. Then check local objs for exdescs. Thanks to Angus Mezick for * the name. Then check local objs for exdescs. Thanks to Angus Mezick for
* the suggested fix to this problem. */ * the suggested fix to this problem. */
void look_at_target(struct char_data *ch, char *arg) static void look_at_target(struct char_data *ch, char *arg)
{ {
int bits, found = FALSE, j, fnum, i = 0; int bits, found = FALSE, j, fnum, i = 0;
struct char_data *found_char = NULL; struct char_data *found_char = NULL;
@ -827,6 +794,16 @@ ACMD(do_score)
send_to_char(ch, "You need %d exp to reach your next level.\r\n", send_to_char(ch, "You need %d exp to reach your next level.\r\n",
level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1) - GET_EXP(ch)); level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1) - GET_EXP(ch));
send_to_char(ch, "You have earned %d quest points.\r\n", GET_QUESTPOINTS(ch));
send_to_char(ch, "You have completed %d quest%s, ",
GET_NUM_QUESTS(ch),
GET_NUM_QUESTS(ch) == 1 ? "" : "s");
if (GET_QUEST(ch) == NOTHING)
send_to_char(ch, "and you are not on a quest at the moment.\r\n");
else
send_to_char(ch, "and your current quest is %d.\r\n",
GET_QUEST(ch) == NOTHING ? -1 : GET_QUEST(ch));
playing_time = *real_time_passed((time(0) - ch->player.time.logon) + playing_time = *real_time_passed((time(0) - ch->player.time.logon) +
ch->player.time.played, 0); ch->player.time.played, 0);
send_to_char(ch, "You have been playing for %d day%s and %d hour%s.\r\n", send_to_char(ch, "You have been playing for %d day%s and %d hour%s.\r\n",
@ -1040,7 +1017,7 @@ int search_help(char *argument, int level)
while (level < help_table[mid].min_level && mid < (bot + top) / 2) while (level < help_table[mid].min_level && mid < (bot + top) / 2)
mid++; mid++;
//to allow morts access to helpfiles on TBA, delete next line. if (strn_cmp(argument, help_table[mid].keywords, minlen) || level < help_table[mid].min_level) // if (strn_cmp(argument, help_table[mid].keywords, minlen) || level < help_table[mid].min_level)
if (strn_cmp(argument, help_table[mid].keywords, minlen)) if (strn_cmp(argument, help_table[mid].keywords, minlen))
break; break;
@ -1057,7 +1034,8 @@ int search_help(char *argument, int level)
ACMD(do_help) ACMD(do_help)
{ {
int mid = 0; int mid = 0;
int i, found = 0;
if (!ch->desc) if (!ch->desc)
return; return;
@ -1079,7 +1057,6 @@ ACMD(do_help)
space_to_minus(argument); space_to_minus(argument);
if ((mid = search_help(argument, GET_LEVEL(ch))) == NOWHERE) { if ((mid = search_help(argument, GET_LEVEL(ch))) == NOWHERE) {
int i, found = 0;
send_to_char(ch, "There is no help on that word.\r\n"); send_to_char(ch, "There is no help on that word.\r\n");
mudlog(NRM, MAX(LVL_IMPL, GET_INVIS_LEV(ch)), TRUE, mudlog(NRM, MAX(LVL_IMPL, GET_INVIS_LEV(ch)), TRUE,
"%s tried to get help on %s", GET_NAME(ch), argument); "%s tried to get help on %s", GET_NAME(ch), argument);
@ -1543,7 +1520,7 @@ ACMD(do_gen_ps)
} }
} }
void perform_mortal_where(struct char_data *ch, char *arg) static void perform_mortal_where(struct char_data *ch, char *arg)
{ {
struct char_data *i; struct char_data *i;
struct descriptor_data *d; struct descriptor_data *d;
@ -1576,7 +1553,7 @@ void perform_mortal_where(struct char_data *ch, char *arg)
} }
} }
void print_object_location(int num, struct obj_data *obj, struct char_data *ch, static void print_object_location(int num, struct obj_data *obj, struct char_data *ch,
int recur) int recur)
{ {
if (num > 0) if (num > 0)
@ -1605,7 +1582,7 @@ void print_object_location(int num, struct obj_data *obj, struct char_data *ch,
send_to_char(ch, "in an unknown location\r\n"); send_to_char(ch, "in an unknown location\r\n");
} }
void perform_immort_where(struct char_data *ch, char *arg) static void perform_immort_where(struct char_data *ch, char *arg)
{ {
struct char_data *i; struct char_data *i;
struct obj_data *k; struct obj_data *k;
@ -1664,17 +1641,50 @@ ACMD(do_where)
ACMD(do_levels) ACMD(do_levels)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH], arg[MAX_STRING_LENGTH];
size_t i, len = 0, nlen; size_t i, len = 0, nlen;
int ret, min_lev=1, max_lev=LVL_IMMORT, val;
if (IS_NPC(ch)) { if (IS_NPC(ch)) {
send_to_char(ch, "You ain't nothin' but a hound-dog.\r\n"); send_to_char(ch, "You ain't nothin' but a hound-dog.\r\n");
return; return;
} }
one_argument(argument, arg);
for (i = 1; i < LVL_IMMORT; i++) { if (arg && *arg) {
nlen = snprintf(buf + len, sizeof(buf) - len, "[%2d] %8d-%-8d : ", i, if (isdigit(*arg)) {
level_exp(GET_CLASS(ch), i), level_exp(GET_CLASS(ch), i + 1) - 1); ret = sscanf(arg, "%d-%d", &min_lev, &max_lev);
if (ret == 0) {
/* No valid args found */
min_lev = 1;
max_lev = LVL_IMMORT;
}
else if (ret == 1) {
/* One arg = range is (num) either side of current level */
val = min_lev;
max_lev = MIN(GET_LEVEL(ch) + val, LVL_IMMORT);
min_lev = MAX(GET_LEVEL(ch) - val, 1);
}
else if (ret == 2) {
/* Two args = min-max range limit - just do sanity checks */
min_lev = MAX(min_lev, 1);
max_lev = MIN(max_lev + 1, LVL_IMMORT);
}
}
else
{
send_to_char(ch, "Usage: %slevels [<min>-<max> | <range>]%s\r\n\r\n", QYEL, QNRM);
send_to_char(ch, "Displays exp required for levels.\r\n");
send_to_char(ch, "%slevels %s- shows all levels (1-%d)\r\n", QCYN, QNRM, (LVL_IMMORT-1));
send_to_char(ch, "%slevels 5 %s- shows 5 levels either side of your current level\r\n", QCYN, QNRM);
send_to_char(ch, "%slevels 10-40 %s- shows level 10 to level 40\r\n",QCYN, QNRM);
return;
}
}
for (i = min_lev; i < max_lev; i++) {
nlen = snprintf(buf + len, sizeof(buf) - len, "[%2d] %8d-%-8d : ", (int)i,
level_exp(GET_CLASS(ch), i), level_exp(GET_CLASS(ch), i + 1) - 1);
if (len + nlen >= sizeof(buf) || nlen < 0) if (len + nlen >= sizeof(buf) || nlen < 0)
break; break;
len += nlen; len += nlen;
@ -1860,6 +1870,10 @@ ACMD(do_toggle)
{"autoassist", PRF_AUTOASSIST, 0, {"autoassist", PRF_AUTOASSIST, 0,
"Autoassist disabled.\r\n", "Autoassist disabled.\r\n",
"Autoassist enabled.\r\n"}, "Autoassist enabled.\r\n"},
{"screenwidth", 0, 0, "\n", "\n"},
{"automap", PRF_AUTOMAP, 0,
"You will no longer see the mini-map.\r\n",
"You will now see a mini-map at the side of room descriptions.\r\n"},
{"\n", 0, -1, "\n", "\n"} /* must be last */ {"\n", 0, -1, "\n", "\n"} /* must be last */
}; };
@ -1931,9 +1945,12 @@ ACMD(do_toggle)
" AutoSac: %-3s " " AutoSac: %-3s "
" AutoAssist: %-3s " " AutoAssist: %-3s "
" AFK: %-3s\r\n" " AutoMap: %-3s\r\n"
" Pagelength: %-3d " " Pagelength: %-3d "
" Screenwidth: %-3d "
" AFK: %-3s\r\n"
" Color: %s \r\n ", " Color: %s \r\n ",
ONOFF(PRF_FLAGGED(ch, PRF_DISPHP)), ONOFF(PRF_FLAGGED(ch, PRF_DISPHP)),
@ -1962,9 +1979,12 @@ ACMD(do_toggle)
ONOFF(PRF_FLAGGED(ch, PRF_AUTOSAC)), ONOFF(PRF_FLAGGED(ch, PRF_AUTOSAC)),
ONOFF(PRF_FLAGGED(ch, PRF_AUTOASSIST)), ONOFF(PRF_FLAGGED(ch, PRF_AUTOASSIST)),
ONOFF(PRF_FLAGGED(ch, PRF_AFK)), ONOFF(PRF_FLAGGED(ch, PRF_AUTOMAP)),
GET_PAGE_LENGTH(ch), GET_PAGE_LENGTH(ch),
GET_SCREEN_WIDTH(ch),
ONOFF(PRF_FLAGGED(ch, PRF_AFK)),
types[COLOR_LEV(ch)]); types[COLOR_LEV(ch)]);
return; return;
} }
@ -2080,6 +2100,33 @@ ACMD(do_toggle)
} else } else
send_to_char(ch, "Please specify a number of lines (5 - 255)."); send_to_char(ch, "Please specify a number of lines (5 - 255).");
break; break;
case SCMD_SCREENWIDTH:
if (!*arg2)
send_to_char(ch, "You current screen width is set to %d characters.", GET_SCREEN_WIDTH(ch));
else if (is_number(arg2)) {
GET_SCREEN_WIDTH(ch) = MIN(MAX(atoi(arg2), 40), 200);
send_to_char(ch, "Okay, your screen width is now set to %d characters.", GET_SCREEN_WIDTH(ch));
} else
send_to_char(ch, "Please specify a number of characters (40 - 200).");
break;
case SCMD_AUTOMAP:
if (can_see_map(ch)) {
if (!*arg2) {
TOGGLE_BIT_AR(PRF_FLAGS(ch), tog_messages[toggle].toggle);
result = (PRF_FLAGGED(ch, tog_messages[toggle].toggle));
} else if (!strcmp(arg2, "on")) {
SET_BIT_AR(PRF_FLAGS(ch), tog_messages[toggle].toggle);
result = 1;
} else if (!strcmp(arg2, "off")) {
REMOVE_BIT_AR(PRF_FLAGS(ch), tog_messages[toggle].toggle);
} else {
send_to_char(ch, "Value for %s must either be 'on' or 'off'.\r\n", tog_messages[toggle].command);
return;
}
} else {
send_to_char(ch, "Sorry, automap is currently disabled.\r\n");
return;
}
default: default:
if (!*arg2) { if (!*arg2) {
TOGGLE_BIT_AR(PRF_FLAGS(ch), tog_messages[toggle].toggle); TOGGLE_BIT_AR(PRF_FLAGS(ch), tog_messages[toggle].toggle);
@ -2100,35 +2147,18 @@ ACMD(do_toggle)
send_to_char(ch, "%s", tog_messages[toggle].disable_msg); send_to_char(ch, "%s", tog_messages[toggle].disable_msg);
} }
int sort_commands_helper(const void *a, const void *b)
{
return strcmp(complete_cmd_info[*(const int *)a].sort_as,
complete_cmd_info[*(const int *)b].sort_as);
}
void sort_commands(void)
{
int a, num_of_cmds = 0;
while (complete_cmd_info[num_of_cmds].command[0] != '\n')
num_of_cmds++;
num_of_cmds++; /* \n */
CREATE(cmd_sort_info, int, num_of_cmds);
for (a = 0; a < num_of_cmds; a++)
cmd_sort_info[a] = a;
/* Don't sort the RESERVED or \n entries. */
qsort(cmd_sort_info + 1, num_of_cmds - 2, sizeof(int), sort_commands_helper);
}
ACMD(do_commands) ACMD(do_commands)
{ {
int no, i, cmd_num; int no, i, cmd_num;
int wizhelp = 0, socials = 0; int wizhelp = 0, socials = 0;
struct char_data *vict; struct char_data *vict;
char arg[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
const char *commands[1000];
int overflow = sizeof(commands) / sizeof(commands[0]);
if (!ch->desc)
return;
one_argument(argument, arg); one_argument(argument, arg);
@ -2145,13 +2175,15 @@ ACMD(do_commands)
else if (subcmd == SCMD_WIZHELP) else if (subcmd == SCMD_WIZHELP)
wizhelp = 1; wizhelp = 1;
send_to_char(ch, "The following %s%s are available to %s:\r\n", sprintf(buf, "The following %s%s are available to %s:\r\n",
wizhelp ? "privileged " : "", wizhelp ? "privileged " : "",
socials ? "socials" : "commands", socials ? "socials" : "commands",
vict == ch ? "you" : GET_NAME(vict)); vict == ch ? "you" : GET_NAME(vict));
/* cmd_num starts at 1, not 0, to remove 'RESERVED' */ /* cmd_num starts at 1, not 0, to remove 'RESERVED' */
for (no = 1, cmd_num = 1; complete_cmd_info[cmd_sort_info[cmd_num]].command[0] != '\n'; cmd_num++) { for (no = 0, cmd_num = 1;
complete_cmd_info[cmd_sort_info[cmd_num]].command[0] != '\n';
++cmd_num) {
i = cmd_sort_info[cmd_num]; i = cmd_sort_info[cmd_num];
@ -2167,11 +2199,27 @@ ACMD(do_commands)
if (wizhelp && complete_cmd_info[i].command_pointer == do_action) if (wizhelp && complete_cmd_info[i].command_pointer == do_action)
continue; continue;
send_to_char(ch, "%-11s%s", complete_cmd_info[i].command, no++ % 7 == 0 ? "\r\n" : ""); if (--overflow < 0)
continue;
/* matching command: copy to commands list */
commands[no++] = complete_cmd_info[i].command;
} }
if (no % 7 != 1) /* display commands list in a nice columnized format */
send_to_char(ch, "\r\n"); column_list(buf + strlen(buf), sizeof(buf) - strlen(buf),
/* subtract 1 or 2 lines (the pager adds 1 or 2) */
/* also "skip" a line since we printed a header above */
GET_PAGE_LENGTH(ch) - (PRF_FLAGGED(ch, PRF_COMPACT) ? 1 : 2), 1,
/* 7 columns; no == how many elements, 0 offset */
7, commands, no, 0, "$11l");
if (overflow < 0) {
log("SYSERR: Too many commands for do_commands; increase size of *commands array.");
strncat(buf, "\r\n** OVERFLOW **\r\n", sizeof(buf) - strlen(buf));
}
page_string(ch->desc, buf, TRUE);
} }
void free_history(struct char_data *ch, int type) void free_history(struct char_data *ch, int type)

View file

@ -20,40 +20,37 @@
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "oasis.h" #include "oasis.h"
#include "act.h"
#include "quest.h"
/* local functions */
int can_take_obj(struct char_data *ch, struct obj_data *obj);
void get_check_money(struct char_data *ch, struct obj_data *obj);
int perform_get_from_room(struct char_data *ch, struct obj_data *obj);
void get_from_room(struct char_data *ch, char *arg, int amount);
void perform_give_gold(struct char_data *ch, struct char_data *vict, int amount);
void perform_give(struct char_data *ch, struct char_data *vict, struct obj_data *obj);
int perform_drop(struct char_data *ch, struct obj_data *obj, byte mode, const char *sname, room_rnum RDR);
void perform_drop_gold(struct char_data *ch, int amount, byte mode, room_rnum RDR);
struct char_data *give_find_vict(struct char_data *ch, char *arg);
void weight_change_object(struct obj_data *obj, int weight);
void perform_put(struct char_data *ch, struct obj_data *obj, struct obj_data *cont);
void name_from_drinkcon(struct obj_data *obj);
void get_from_container(struct char_data *ch, struct obj_data *cont, char *arg, int mode, int amount);
void name_to_drinkcon(struct obj_data *obj, int type);
void wear_message(struct char_data *ch, struct obj_data *obj, int where);
void perform_wear(struct char_data *ch, struct obj_data *obj, int where);
int find_eq_pos(struct char_data *ch, struct obj_data *obj, char *arg);
void perform_get_from_container(struct char_data *ch, struct obj_data *obj, struct obj_data *cont, int mode);
void perform_remove(struct char_data *ch, int pos);
ACMD(do_remove);
ACMD(do_put);
ACMD(do_get);
ACMD(do_drop);
ACMD(do_give);
ACMD(do_drink);
ACMD(do_eat);
ACMD(do_pour);
ACMD(do_wear);
ACMD(do_wield);
ACMD(do_grab);
void perform_put(struct char_data *ch, struct obj_data *obj, struct obj_data *cont) /* local function prototypes */
/* do_get utility functions */
static int can_take_obj(struct char_data *ch, struct obj_data *obj);
static void get_check_money(struct char_data *ch, struct obj_data *obj);
static void get_from_container(struct char_data *ch, struct obj_data *cont, char *arg, int mode, int amount);
static void get_from_room(struct char_data *ch, char *arg, int amount);
static void perform_get_from_container(struct char_data *ch, struct obj_data *obj, struct obj_data *cont, int mode);
static int perform_get_from_room(struct char_data *ch, struct obj_data *obj);
/* do_give utility functions */
static struct char_data *give_find_vict(struct char_data *ch, char *arg);
static void perform_give(struct char_data *ch, struct char_data *vict, struct obj_data *obj);
static void perform_give_gold(struct char_data *ch, struct char_data *vict, int amount);
/* do_drop utility functions */
static int perform_drop(struct char_data *ch, struct obj_data *obj, byte mode, const char *sname, room_rnum RDR);
static void perform_drop_gold(struct char_data *ch, int amount, byte mode, room_rnum RDR);
/* do_put utility functions */
static void perform_put(struct char_data *ch, struct obj_data *obj, struct obj_data *cont);
/* do_remove utility functions */
static void perform_remove(struct char_data *ch, int pos);
/* do_wear utility functions */
static void perform_wear(struct char_data *ch, struct obj_data *obj, int where);
static void wear_message(struct char_data *ch, struct obj_data *obj, int where);
static void perform_put(struct char_data *ch, struct obj_data *obj, struct obj_data *cont)
{ {
if (!drop_otrigger(obj, ch)) if (!drop_otrigger(obj, ch))
@ -162,7 +159,7 @@ ACMD(do_put)
} }
} }
int can_take_obj(struct char_data *ch, struct obj_data *obj) static int can_take_obj(struct char_data *ch, struct obj_data *obj)
{ {
if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) { if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) {
act("$p: you can't carry that many items.", FALSE, ch, obj, 0, TO_CHAR); act("$p: you can't carry that many items.", FALSE, ch, obj, 0, TO_CHAR);
@ -177,7 +174,7 @@ int can_take_obj(struct char_data *ch, struct obj_data *obj)
return (1); return (1);
} }
void get_check_money(struct char_data *ch, struct obj_data *obj) static void get_check_money(struct char_data *ch, struct obj_data *obj)
{ {
int value = GET_OBJ_VAL(obj, 0); int value = GET_OBJ_VAL(obj, 0);
@ -194,7 +191,7 @@ void get_check_money(struct char_data *ch, struct obj_data *obj)
send_to_char(ch, "There were %d coins.\r\n", value); send_to_char(ch, "There were %d coins.\r\n", value);
} }
void perform_get_from_container(struct char_data *ch, struct obj_data *obj, static void perform_get_from_container(struct char_data *ch, struct obj_data *obj,
struct obj_data *cont, int mode) struct obj_data *cont, int mode)
{ {
if (mode == FIND_OBJ_INV || can_take_obj(ch, obj)) { if (mode == FIND_OBJ_INV || can_take_obj(ch, obj)) {
@ -260,7 +257,7 @@ void get_from_container(struct char_data *ch, struct obj_data *cont,
} }
} }
int perform_get_from_room(struct char_data *ch, struct obj_data *obj) static int perform_get_from_room(struct char_data *ch, struct obj_data *obj)
{ {
if (can_take_obj(ch, obj) && get_otrigger(obj, ch)) { if (can_take_obj(ch, obj) && get_otrigger(obj, ch)) {
obj_from_room(obj); obj_from_room(obj);
@ -273,7 +270,7 @@ int perform_get_from_room(struct char_data *ch, struct obj_data *obj)
return (0); return (0);
} }
void get_from_room(struct char_data *ch, char *arg, int howmany) static void get_from_room(struct char_data *ch, char *arg, int howmany)
{ {
struct obj_data *obj, *next_obj; struct obj_data *obj, *next_obj;
int dotmode, found = 0; int dotmode, found = 0;
@ -384,7 +381,7 @@ ACMD(do_get)
} }
} }
void perform_drop_gold(struct char_data *ch, int amount, byte mode, room_rnum RDR) static void perform_drop_gold(struct char_data *ch, int amount, byte mode, room_rnum RDR)
{ {
struct obj_data *obj; struct obj_data *obj;
@ -430,7 +427,7 @@ void perform_drop_gold(struct char_data *ch, int amount, byte mode, room_rnum RD
#define VANISH(mode) ((mode == SCMD_DONATE || mode == SCMD_JUNK) ? \ #define VANISH(mode) ((mode == SCMD_DONATE || mode == SCMD_JUNK) ? \
" It vanishes in a puff of smoke!" : "") " It vanishes in a puff of smoke!" : "")
int perform_drop(struct char_data *ch, struct obj_data *obj, static int perform_drop(struct char_data *ch, struct obj_data *obj,
byte mode, const char *sname, room_rnum RDR) byte mode, const char *sname, room_rnum RDR)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
@ -594,7 +591,7 @@ ACMD(do_drop)
} }
} }
void perform_give(struct char_data *ch, struct char_data *vict, static void perform_give(struct char_data *ch, struct char_data *vict,
struct obj_data *obj) struct obj_data *obj)
{ {
if (!give_otrigger(obj, ch, vict)) if (!give_otrigger(obj, ch, vict))
@ -619,10 +616,12 @@ void perform_give(struct char_data *ch, struct char_data *vict,
act("You give $p to $N.", FALSE, ch, obj, vict, TO_CHAR); act("You give $p to $N.", FALSE, ch, obj, vict, TO_CHAR);
act("$n gives you $p.", FALSE, ch, obj, vict, TO_VICT); act("$n gives you $p.", FALSE, ch, obj, vict, TO_VICT);
act("$n gives $p to $N.", TRUE, ch, obj, vict, TO_NOTVICT); act("$n gives $p to $N.", TRUE, ch, obj, vict, TO_NOTVICT);
autoquest_trigger_check( ch, vict, obj, AQ_OBJ_RETURN);
} }
/* utility function for give */ /* utility function for give */
struct char_data *give_find_vict(struct char_data *ch, char *arg) static struct char_data *give_find_vict(struct char_data *ch, char *arg)
{ {
struct char_data *vict; struct char_data *vict;
@ -639,7 +638,7 @@ struct char_data *give_find_vict(struct char_data *ch, char *arg)
return (NULL); return (NULL);
} }
void perform_give_gold(struct char_data *ch, struct char_data *vict, static void perform_give_gold(struct char_data *ch, struct char_data *vict,
int amount) int amount)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
@ -871,7 +870,7 @@ ACMD(do_drink)
send_to_char(ch, "Your stomach can't contain anymore!\r\n"); send_to_char(ch, "Your stomach can't contain anymore!\r\n");
return; return;
} }
if ((GET_OBJ_VAL(temp, 1) == 0) && (!GET_OBJ_VAL(temp, 0) == 1)) { if ((GET_OBJ_VAL(temp, 1) == 0) || (!GET_OBJ_VAL(temp, 0) == 1)) {
send_to_char(ch, "It is empty.\r\n"); send_to_char(ch, "It is empty.\r\n");
return; return;
} }
@ -1156,7 +1155,7 @@ ACMD(do_pour)
weight_change_object(to_obj, amount); /* Add weight */ weight_change_object(to_obj, amount); /* Add weight */
} }
void wear_message(struct char_data *ch, struct obj_data *obj, int where) static void wear_message(struct char_data *ch, struct obj_data *obj, int where)
{ {
const char *wear_messages[][2] = { const char *wear_messages[][2] = {
{"$n lights $p and holds it.", {"$n lights $p and holds it.",
@ -1218,7 +1217,7 @@ void wear_message(struct char_data *ch, struct obj_data *obj, int where)
act(wear_messages[where][1], FALSE, ch, obj, 0, TO_CHAR); act(wear_messages[where][1], FALSE, ch, obj, 0, TO_CHAR);
} }
void perform_wear(struct char_data *ch, struct obj_data *obj, int where) static void perform_wear(struct char_data *ch, struct obj_data *obj, int where)
{ {
/* /*
* ITEM_WEAR_TAKE is used for objects that do not require special bits * ITEM_WEAR_TAKE is used for objects that do not require special bits
@ -1439,7 +1438,7 @@ ACMD(do_grab)
} }
} }
void perform_remove(struct char_data *ch, int pos) static void perform_remove(struct char_data *ch, int pos)
{ {
struct obj_data *obj; struct obj_data *obj;

View file

@ -20,31 +20,23 @@
#include "house.h" #include "house.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "act.h"
#include "fight.h"
#include "oasis.h" /* for buildwalk */
/* external functions */
int special(struct char_data *ch, int cmd, char *arg);
void death_cry(struct char_data *ch);
int find_eq_pos(struct char_data *ch, struct obj_data *obj, char *arg);
int buildwalk(struct char_data *ch, int dir);
/* local functions */ /* local only functions */
int has_boat(struct char_data *ch); /* do_simple_move utility functions */
int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname); static int has_boat(struct char_data *ch);
int has_key(struct char_data *ch, obj_vnum key); /* do_gen_door utility functions */
void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd); static int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname);
int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd); static int has_key(struct char_data *ch, obj_vnum key);
ACMD(do_gen_door); static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd);
ACMD(do_enter); static int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd);
ACMD(do_leave);
ACMD(do_stand);
ACMD(do_sit);
ACMD(do_rest);
ACMD(do_sleep);
ACMD(do_wake);
ACMD(do_follow);
/* simple function to determine if char can walk on water */ /* simple function to determine if char can walk on water */
int has_boat(struct char_data *ch) static int has_boat(struct char_data *ch)
{ {
struct obj_data *obj; struct obj_data *obj;
int i; int i;
@ -118,63 +110,136 @@ int has_scuba(struct char_data *ch)
return (0); return (0);
} }
/* do_simple_move assumes that there is no master, no followers and that the /** Move a PC/NPC character from their current location to a new location. This
* direction exists. It returns 1 for success, 0 if failure. */ * is the standard movement locomotion function that all normal walking
* movement by characters should be sent through. This function also defines
* the move cost of normal locomotion as:
* ( (move cost for source room) + (move cost for destination) ) / 2
*
* @pre Function assumes that ch has no master controlling character, that
* ch has no followers (in other words followers won't be moved by this
* function) and that the direction traveled in is one of the valid, enumerated
* direction.
* @param ch The character structure to attempt to move.
* @param dir The defined direction (NORTH, SOUTH, etc...) to attempt to
* move into.
* @param need_specials_check If TRUE will cause
* @retval int 1 for a successful move (ch is now in a new location)
* or 0 for a failed move (ch is still in the original location). */
int do_simple_move(struct char_data *ch, int dir, int need_specials_check) int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{ {
char throwaway[MAX_INPUT_LENGTH] = ""; /* Functions assume writable. */ /* Begin Local variable definitions */
/*---------------------------------------------------------------------*/
/* Used in our special proc check. By default, we pass a NULL argument
* when checking for specials */
char spec_proc_args[MAX_INPUT_LENGTH] = "";
/* The room the character is currently in and will move from... */
room_rnum was_in = IN_ROOM(ch); room_rnum was_in = IN_ROOM(ch);
int need_movement; /* ... and the room the character will move into. */
room_rnum going_to = EXIT(ch, dir)->to_room;
/* How many movement points are required to travel from was_in to going_to.
* We redefine this later when we need it. */
int need_movement = 0;
/* Contains the "leave" message to display to the was_in room. */
char leave_message[SMALL_BUFSIZE];
/*---------------------------------------------------------------------*/
/* End Local variable definitions */
/* Begin checks that can prevent a character from leaving the was_in room. */
/* Future checks should be implemented within this section and return 0. */
/*---------------------------------------------------------------------*/
/* Check for special routines that might activate because of the move and
* also might prevent the movement. Special requires commands, so we pass
* in the "command" equivalent of the direction (ie. North is '1' in the
* command list, but NORTH is defined as '0').
* Note -- only check if following; this avoids 'double spec-proc' bug */
if (need_specials_check && special(ch, dir + 1, spec_proc_args))
return 0;
/* Check for special routines (North is 1 in command list, but 0 here) Note /* Leave Trigger Checks: Does a leave trigger block exit from the room? */
* -- only check if following; this avoids 'double spec-proc' bug */
if (need_specials_check && special(ch, dir + 1, throwaway))
return (0);
/* blocked by a leave trigger ? */
if (!leave_mtrigger(ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */ if (!leave_mtrigger(ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
return 0; return 0;
if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */ if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
return 0; return 0;
if (!leave_otrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */ if (!leave_otrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
return 0; return 0;
/* charmed? */
if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && IN_ROOM(ch) == IN_ROOM(ch->master)) { /* Charm effect: Does it override the movement? */
if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && was_in == IN_ROOM(ch->master))
{
send_to_char(ch, "The thought of leaving your master makes you weep.\r\n"); send_to_char(ch, "The thought of leaving your master makes you weep.\r\n");
act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM); act("$n bursts into tears.", FALSE, ch, 0, 0, TO_ROOM);
return (0); return (0);
} }
/* if this room or the one we're going to needs a boat, check for one */ /* Water, No Swimming Rooms: Does the deep water prevent movement? */
if ((SECT(IN_ROOM(ch)) == SECT_WATER_NOSWIM) || if ((SECT(was_in) == SECT_WATER_NOSWIM) ||
(SECT(EXIT(ch, dir)->to_room) == SECT_WATER_NOSWIM)) { (SECT(going_to) == SECT_WATER_NOSWIM))
if (!has_boat(ch)) { {
if (!has_boat(ch))
{
send_to_char(ch, "You need a boat to go there.\r\n"); send_to_char(ch, "You need a boat to go there.\r\n");
return (0); return (0);
} }
} }
/* If this room or the one we're going to needs flight, check for it. */ /* Flying Required: Does lack of flying prevent movement? */
if ((SECT(IN_ROOM(ch)) == SECT_FLYING) || (SECT(EXIT(ch, dir)->to_room) == SECT_FLYING)) { if ((SECT(was_in) == SECT_FLYING) || (SECT(going_to) == SECT_FLYING))
if (!has_flight(ch)) { {
if (!has_flight(ch))
{
send_to_char(ch, "You need to be flying to go there!\r\n"); send_to_char(ch, "You need to be flying to go there!\r\n");
return (0); return (0);
} }
} }
/* If this room or the one we're going to needs scuba, check for it. */ /* Underwater Room: Does lack of underwater breathing prevent movement? */
if ((SECT(IN_ROOM(ch)) == SECT_UNDERWATER) || (SECT(EXIT(ch, dir)->to_room) == SECT_UNDERWATER)) { if ((SECT(was_in) == SECT_UNDERWATER) || (SECT(going_to) == SECT_UNDERWATER))
{
if (!has_scuba(ch)) { if (!has_scuba(ch)) {
send_to_char(ch, "You need to be able to breathe water to go there!\r\n"); send_to_char(ch, "You need to be able to breathe water to go there!\r\n");
return (0); return (0);
} }
} }
/* move points needed is avg. move loss for src and destination sect type */ /* Houses: Can the player walk into the house? */
need_movement = (movement_loss[SECT(IN_ROOM(ch))] + if (ROOM_FLAGGED(was_in, ROOM_ATRIUM))
movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2; {
if (!House_can_enter(ch, GET_ROOM_VNUM(going_to)))
{
send_to_char(ch, "That's private property -- no trespassing!\r\n");
return (0);
}
}
if (GET_MOVE(ch) < need_movement && !IS_NPC(ch)) { /* Room Size Capacity: Is the room full of people already? */
if (ROOM_FLAGGED(going_to, ROOM_TUNNEL) &&
num_pc_in_room(&(world[going_to])) >= CONFIG_TUNNEL_SIZE)
{
if (CONFIG_TUNNEL_SIZE > 1)
send_to_char(ch, "There isn't enough room for you to go there!\r\n");
else
send_to_char(ch, "There isn't enough room there for more than one person!\r\n");
return (0);
}
/* Room Level Requirements: Is ch privileged enough to enter the room? */
if (ROOM_FLAGGED(going_to, ROOM_GODROOM) && GET_LEVEL(ch) < LVL_GOD)
{
send_to_char(ch, "You aren't godly enough to use that room!\r\n");
return (0);
}
/* All checks passed, nothing will prevent movement now other than lack of
* move points. */
/* move points needed is avg. move loss for src and destination sect type */
need_movement = (movement_loss[SECT(was_in)] +
movement_loss[SECT(going_to)]) / 2;
/* Move Point Requirement Check */
if (GET_MOVE(ch) < need_movement && !IS_NPC(ch))
{
if (need_specials_check && ch->master) if (need_specials_check && ch->master)
send_to_char(ch, "You are too exhausted to follow.\r\n"); send_to_char(ch, "You are too exhausted to follow.\r\n");
else else
@ -182,69 +247,78 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
return (0); return (0);
} }
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_ATRIUM)) {
if (!House_can_enter(ch, GET_ROOM_VNUM(EXIT(ch, dir)->to_room))) {
send_to_char(ch, "That's private property -- no trespassing!\r\n");
return (0);
}
}
if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_TUNNEL) &&
num_pc_in_room(&(world[EXIT(ch, dir)->to_room])) >= CONFIG_TUNNEL_SIZE) {
if (CONFIG_TUNNEL_SIZE > 1)
send_to_char(ch, "There isn't enough room for you to go there!\r\n");
else
send_to_char(ch, "There isn't enough room there for more than one person!\r\n");
return (0);
}
/* Mortals and low level gods cannot enter greater god rooms. */
if (ROOM_FLAGGED(EXIT(ch, dir)->to_room, ROOM_GODROOM) &&
GET_LEVEL(ch) < LVL_GOD) {
send_to_char(ch, "You aren't godly enough to use that room!\r\n");
return (0);
}
/* Now we know we're allowed to go into the room. */ /*---------------------------------------------------------------------*/
/* End checks that can prevent a character from leaving the was_in room. */
/* Begin: the leave operation. */
/*---------------------------------------------------------------------*/
/* If applicable, subtract movement cost. */
if (GET_LEVEL(ch) < LVL_IMMORT && !IS_NPC(ch)) if (GET_LEVEL(ch) < LVL_IMMORT && !IS_NPC(ch))
GET_MOVE(ch) -= need_movement; GET_MOVE(ch) -= need_movement;
if (!AFF_FLAGGED(ch, AFF_SNEAK)) { /* Generate the leave message and display to others in the was_in room. */
char buf2[MAX_STRING_LENGTH]; if (!AFF_FLAGGED(ch, AFF_SNEAK))
{
snprintf(buf2, sizeof(buf2), "$n leaves %s.", dirs[dir]); snprintf(leave_message, sizeof(leave_message), "$n leaves %s.", dirs[dir]);
act(buf2, TRUE, ch, 0, 0, TO_ROOM); act(leave_message, TRUE, ch, 0, 0, TO_ROOM);
} }
was_in = IN_ROOM(ch);
char_from_room(ch); char_from_room(ch);
char_to_room(ch, world[was_in].dir_option[dir]->to_room); char_to_room(ch, going_to);
/*---------------------------------------------------------------------*/
/* End: the leave operation. The character is now in the new room. */
/* move them first, then move them back if they aren't allowed to go. Also,
* see if an entry trigger disallows the move */ /* Begin: Post-move operations. */
if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir)) { /*---------------------------------------------------------------------*/
/* Post Move Trigger Checks: Check the new room for triggers.
* Assumptions: The character has already truly left the was_in room. If
* the entry trigger "prevents" movement into the room, it is thr triggers
* job to provide a message to the original was_in room. */
if (!entry_mtrigger(ch) || !enter_wtrigger(&world[going_to], ch, dir)) {
char_from_room(ch); char_from_room(ch);
char_to_room(ch, was_in); char_to_room(ch, was_in);
return 0; return 0;
} }
/* Display arrival information to anyone in the destination room... */
if (!AFF_FLAGGED(ch, AFF_SNEAK)) if (!AFF_FLAGGED(ch, AFF_SNEAK))
act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM); act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM);
/* ... and the room description to the character. */
if (ch->desc != NULL) if (ch->desc != NULL)
look_at_room(ch, 0); look_at_room(ch, 0);
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) { /* ... and Kill the player if the room is a death trap. */
mudlog(BRF, LVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(IN_ROOM(ch)), world[IN_ROOM(ch)].name); if (ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT)
{
mudlog(BRF, LVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(going_to), world[going_to].name);
death_cry(ch); death_cry(ch);
extract_char(ch); extract_char(ch);
return (0); return (0);
} }
/* At this point, the character is safe and in the room. */
/* Fire memory and greet triggers, check and see if the greet trigger
* prevents movement, and if so, move the player back to the previous room. */
entry_memory_mtrigger(ch); entry_memory_mtrigger(ch);
if (!greet_mtrigger(ch, dir)) { if (!greet_mtrigger(ch, dir))
{
char_from_room(ch); char_from_room(ch);
char_to_room(ch, was_in); char_to_room(ch, was_in);
look_at_room(ch, 0); look_at_room(ch, 0);
} else greet_memory_mtrigger(ch); /* Failed move, return a failure */
return (0);
}
else
greet_memory_mtrigger(ch);
/*---------------------------------------------------------------------*/
/* End: Post-move operations. */
/* Only here is the move successful *and* complete. Return success for
* calling functions to handle post move operations. */
return (1); return (1);
} }
@ -285,13 +359,11 @@ int perform_move(struct char_data *ch, int dir, int need_specials_check)
ACMD(do_move) ACMD(do_move)
{ {
/* This is basically a mapping of cmd numbers to perform_move indices. It /* These subcmd defines are mapped precisely to the direction defines. */
* cannot be done in perform_move because perform_move is called by other perform_move(ch, subcmd, 0);
* functions which do not require the remapping. */
perform_move(ch, subcmd - 1, 0);
} }
int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname) static int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname)
{ {
int door; int door;
@ -350,6 +422,7 @@ int has_key(struct char_data *ch, obj_vnum key)
#define NEED_UNLOCKED (1 << 2) #define NEED_UNLOCKED (1 << 2)
#define NEED_LOCKED (1 << 3) #define NEED_LOCKED (1 << 3)
/* cmd_door is required external from act.movement.c */
const char *cmd_door[] = const char *cmd_door[] =
{ {
"open", "open",
@ -359,7 +432,7 @@ const char *cmd_door[] =
"pick" "pick"
}; };
const int flags_door[] = static const int flags_door[] =
{ {
NEED_CLOSED | NEED_UNLOCKED, NEED_CLOSED | NEED_UNLOCKED,
NEED_OPEN, NEED_OPEN,
@ -385,7 +458,7 @@ const int flags_door[] =
(TOGGLE_BIT(GET_OBJ_VAL(obj, 1), CONT_LOCKED)) :\ (TOGGLE_BIT(GET_OBJ_VAL(obj, 1), CONT_LOCKED)) :\
(TOGGLE_BIT(EXITN(room, door)->exit_info, EX_LOCKED))) (TOGGLE_BIT(EXITN(room, door)->exit_info, EX_LOCKED)))
void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd) static void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
size_t len; size_t len;
@ -456,7 +529,7 @@ void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd)
scmd == SCMD_CLOSE ? "d" : "ed"); scmd == SCMD_CLOSE ? "d" : "ed");
} }
int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd) static int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd)
{ {
int percent, skill_lvl; int percent, skill_lvl;

View file

@ -17,22 +17,8 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "spells.h" #include "spells.h"
#include "act.h"
/* extern functions */ #include "fight.h"
void raw_kill(struct char_data *ch, struct char_data * killer);
void check_killer(struct char_data *ch, struct char_data *vict);
int compute_armor_class(struct char_data *ch);
/* local functions */
ACMD(do_assist);
ACMD(do_hit);
ACMD(do_kill);
ACMD(do_backstab);
ACMD(do_order);
ACMD(do_flee);
ACMD(do_bash);
ACMD(do_rescue);
ACMD(do_kick);
ACMD(do_assist) ACMD(do_assist)
{ {

View file

@ -8,6 +8,7 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/ **************************************************************************/
/* needed by sysdep.h to allow for definition of <sys/stat.h> */
#define __ACT_OTHER_C__ #define __ACT_OTHER_C__
#include "conf.h" #include "conf.h"
@ -23,41 +24,19 @@
#include "house.h" #include "house.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "act.h"
#include "spec_procs.h"
#include "class.h"
#include "fight.h"
#include "mail.h" /* for has_mail() */
#include "shop.h"
#include "quest.h"
/* extern variables */ /* Local defined utility functions */
extern struct spell_info_type spell_info[]; /* do_group utility functions */
extern const char *class_abbrevs[]; static int perform_group(struct char_data *ch, struct char_data *vict);
static void print_group(struct char_data *ch);
/* extern functions */
void list_skills(struct char_data *ch);
void appear(struct char_data *ch);
void perform_immort_vis(struct char_data *ch);
SPECIAL(shop_keeper);
ACMD(do_gen_comm);
void die(struct char_data *ch, struct char_data * killer);
void Crash_rentsave(struct char_data *ch, int cost);
int has_mail(long id);
/* local functions */
ACMD(do_quit);
ACMD(do_save);
ACMD(do_not_here);
ACMD(do_sneak);
ACMD(do_hide);
ACMD(do_steal);
ACMD(do_practice);
ACMD(do_visible);
ACMD(do_title);
int perform_group(struct char_data *ch, struct char_data *vict);
void print_group(struct char_data *ch);
ACMD(do_group);
ACMD(do_ungroup);
ACMD(do_report);
ACMD(do_split);
ACMD(do_use);
ACMD(do_display);
ACMD(do_gen_tog);
ACMD(do_gen_write);
ACMD(do_quit) ACMD(do_quit)
{ {
@ -74,6 +53,10 @@ ACMD(do_quit)
} else { } else {
act("$n has left the game.", TRUE, ch, 0, 0, TO_ROOM); act("$n has left the game.", TRUE, ch, 0, 0, TO_ROOM);
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has quit the game.", GET_NAME(ch)); mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has quit the game.", GET_NAME(ch));
if (GET_QUEST_TIME(ch) != -1)
quest_timeout(ch);
send_to_char(ch, "Goodbye, friend.. Come back soon!\r\n"); send_to_char(ch, "Goodbye, friend.. Come back soon!\r\n");
/* We used to check here for duping attempts, but we may as well do it right /* We used to check here for duping attempts, but we may as well do it right
@ -335,7 +318,7 @@ ACMD(do_title)
} }
} }
int perform_group(struct char_data *ch, struct char_data *vict) static int perform_group(struct char_data *ch, struct char_data *vict)
{ {
if (AFF_FLAGGED(vict, AFF_GROUP) || !CAN_SEE(ch, vict)) if (AFF_FLAGGED(vict, AFF_GROUP) || !CAN_SEE(ch, vict))
return (0); return (0);
@ -348,7 +331,7 @@ int perform_group(struct char_data *ch, struct char_data *vict)
return (1); return (1);
} }
void print_group(struct char_data *ch) static void print_group(struct char_data *ch)
{ {
struct char_data *k; struct char_data *k;
struct follow_type *f; struct follow_type *f;

View file

@ -17,15 +17,12 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "spells.h" #include "spells.h"
#include "act.h"
/* local defined functions for local use */
/* do_action and do_gmote utility function */
static int find_action(int cmd);
/* local functions */
int find_action(int cmd);
ACMD(do_action);
void free_social_messages(void);
void free_action(struct social_messg *mess);
void free_command_list(void);
void create_command_list(void);
ACMD(do_gmote);
ACMD(do_action) ACMD(do_action)
{ {
@ -110,7 +107,6 @@ void create_command_list(void)
{ {
int i, j, k; int i, j, k;
struct social_messg temp; struct social_messg temp;
extern struct command_info cmd_info[];
/* free up old command list */ /* free up old command list */
if (complete_cmd_info) if (complete_cmd_info)
@ -206,7 +202,7 @@ void free_action(struct social_messg *mess) {
memset(mess, 0, sizeof(struct social_messg)); memset(mess, 0, sizeof(struct social_messg));
} }
int find_action(int cmd) static int find_action(int cmd)
{ {
int bot, top, mid; int bot, top, mid;

View file

@ -23,101 +23,30 @@
#include "oasis.h" #include "oasis.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "shop.h" #include "shop.h"
#include "act.h"
#include "genzon.h" /* for real_zone_by_thing */
#include "class.h"
#include "genolc.h"
#include "fight.h"
#include "house.h"
#include "modify.h"
#include "quest.h"
/* external vars */ /* local utility functions with file scope */
extern FILE *player_fl; static int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg);
extern struct attack_hit_type attack_hit_text[]; static void perform_immort_invis(struct char_data *ch, int level);
extern char *class_abbrevs[]; static void list_zone_commands_room(struct char_data *ch, room_vnum rvnum);
extern time_t boot_time; static void do_stat_room(struct char_data *ch, struct room_data *rm);
extern int circle_shutdown, circle_reboot; static void do_stat_object(struct char_data *ch, struct obj_data *j);
extern int circle_restrict; static void do_stat_character(struct char_data *ch, struct char_data *k);
extern int buf_switches, buf_largecount, buf_overflows; static void stop_snooping(struct char_data *ch);
extern int top_of_p_table; static size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int listall);
extern socket_t mother_desc; static struct char_data *is_in_game(long idnum);
extern ush_int port; static void mob_checkload(struct char_data *ch, mob_vnum mvnum);
extern const char *pc_class_types[]; static void obj_checkload(struct char_data *ch, obj_vnum ovnum);
extern int top_of_p_table; static void trg_checkload(struct char_data *ch, trig_vnum tvnum);
extern struct player_index_element *player_table; static void mod_llog_entry(struct last_entry *llast,int type);
/* external functions */
int level_exp(int chclass, int level);
void show_shops(struct char_data *ch, char *value);
void hcontrol_list_houses(struct char_data *ch, char *arg);
void do_start(struct char_data *ch);
void appear(struct char_data *ch);
void reset_zone(zone_rnum zone);
void roll_real_abils(struct char_data *ch);
int parse_class(char arg);
void run_autowiz(void);
int save_all(void);
zone_rnum real_zone_by_thing(room_vnum vznum);
SPECIAL(shop_keeper);
void Crash_rentsave(struct char_data * ch, int cost);
void new_hist_messg(struct descriptor_data *d, const char *msg);
void clearMemory(struct char_data *ch);
int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_arg);
struct time_info_data *real_time_passed(time_t t2, time_t t1);
/* local functions */
int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg);
void perform_immort_invis(struct char_data *ch, int level);
ACMD(do_echo);
ACMD(do_send);
room_rnum find_target_room(struct char_data *ch, char *rawroomstr);
ACMD(do_at);
ACMD(do_goto);
ACMD(do_trans);
ACMD(do_teleport);
ACMD(do_vnum);
void list_zone_commands_room(struct char_data *ch, room_vnum rvnum);
void do_stat_room(struct char_data *ch, struct room_data *rm);
void do_stat_object(struct char_data *ch, struct obj_data *j);
void do_stat_character(struct char_data *ch, struct char_data *k);
ACMD(do_stat);
ACMD(do_shutdown);
void stop_snooping(struct char_data *ch);
ACMD(do_snoop);
ACMD(do_switch);
ACMD(do_return);
ACMD(do_load);
ACMD(do_vstat);
ACMD(do_purge);
ACMD(do_syslog);
ACMD(do_advance);
ACMD(do_restore);
void perform_immort_vis(struct char_data *ch);
ACMD(do_invis);
ACMD(do_gecho);
ACMD(do_poofset);
ACMD(do_dc);
ACMD(do_wizlock);
ACMD(do_date);
ACMD(do_last);
ACMD(do_force);
ACMD(do_wiznet);
ACMD(do_zreset);
ACMD(do_wizutil);
size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int listall);
ACMD(do_show);
ACMD(do_set);
void snoop_check(struct char_data *ch);
ACMD(do_saveall);
ACMD(do_zpurge);
void clean_llog_entries(void);
ACMD(do_list_llog_entries);
struct char_data *is_in_game(long idnum);
ACMD(do_links);
void mob_checkload(struct char_data *ch, mob_vnum mvnum);
void obj_checkload(struct char_data *ch, obj_vnum ovnum);
void trg_checkload(struct char_data *ch, trig_vnum tvnum);
ACMD(do_zcheck);
ACMD(do_checkloadstatus);
ACMD(do_poofs);
ACMD(do_copyover);
ACMD(do_peace);
void mod_llog_entry(struct last_entry *llast,int type);
ACMD(do_plist);
ACMD(do_wizupdate);
int purge_room(room_rnum room) int purge_room(room_rnum room)
{ {
@ -431,7 +360,7 @@ ACMD(do_vnum)
#define ZOCMD zone_table[zrnum].cmd[subcmd] #define ZOCMD zone_table[zrnum].cmd[subcmd]
void list_zone_commands_room(struct char_data *ch, room_vnum rvnum) static void list_zone_commands_room(struct char_data *ch, room_vnum rvnum)
{ {
zone_rnum zrnum = real_zone_by_thing(rvnum); zone_rnum zrnum = real_zone_by_thing(rvnum);
room_rnum rrnum = real_room(rvnum), cmd_room = NOWHERE; room_rnum rrnum = real_room(rvnum), cmd_room = NOWHERE;
@ -551,7 +480,7 @@ void list_zone_commands_room(struct char_data *ch, room_vnum rvnum)
} }
#undef ZOCMD #undef ZOCMD
void do_stat_room(struct char_data *ch, struct room_data *rm) static void do_stat_room(struct char_data *ch, struct room_data *rm)
{ {
char buf2[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH];
struct extra_descr_data *desc; struct extra_descr_data *desc;
@ -638,7 +567,7 @@ void do_stat_room(struct char_data *ch, struct room_data *rm)
list_zone_commands_room(ch, rm->number); list_zone_commands_room(ch, rm->number);
} }
void do_stat_object(struct char_data *ch, struct obj_data *j) static void do_stat_object(struct char_data *ch, struct obj_data *j)
{ {
int i, found; int i, found;
obj_vnum vnum; obj_vnum vnum;
@ -789,7 +718,7 @@ void do_stat_object(struct char_data *ch, struct obj_data *j)
do_sstat_object(ch, j); do_sstat_object(ch, j);
} }
void do_stat_character(struct char_data *ch, struct char_data *k) static void do_stat_character(struct char_data *ch, struct char_data *k)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
int i, i2, column, found = FALSE; int i, i2, column, found = FALSE;
@ -862,7 +791,9 @@ void do_stat_character(struct char_data *ch, struct char_data *k)
GET_GOLD(k), GET_BANK_GOLD(k), GET_GOLD(k) + GET_BANK_GOLD(k)); GET_GOLD(k), GET_BANK_GOLD(k), GET_GOLD(k) + GET_BANK_GOLD(k));
if (!IS_NPC(k)) if (!IS_NPC(k))
send_to_char(ch, "Questpoints: [%d]\r\n", GET_QUESTPOINTS(k)); send_to_char(ch, "Questpoints: [%d] Screen %s[%s%d%sx%s%d%s]%s\r\n", GET_QUESTPOINTS(k),
CCCYN(ch, C_NRM), CCYEL(ch, C_NRM), GET_SCREEN_WIDTH(k), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), GET_PAGE_LENGTH(k), CCCYN(ch, C_NRM), CCNRM(ch, C_NRM));
send_to_char(ch, "AC: [%d%+d/10], Hitroll: [%2d], Damroll: [%2d], Saving throws: [%d/%d/%d/%d/%d]\r\n", send_to_char(ch, "AC: [%d%+d/10], Hitroll: [%2d], Damroll: [%2d], Saving throws: [%d/%d/%d/%d/%d]\r\n",
GET_AC(k), dex_app[GET_DEX(k)].defensive, k->points.hitroll, GET_AC(k), dex_app[GET_DEX(k)].defensive, k->points.hitroll,
@ -893,6 +824,12 @@ void do_stat_character(struct char_data *ch, struct char_data *k)
sprintbitarray(PRF_FLAGS(k), preference_bits, PR_ARRAY_MAX, buf); sprintbitarray(PRF_FLAGS(k), preference_bits, PR_ARRAY_MAX, buf);
send_to_char(ch, "PRF: %s%s%s\r\n", CCGRN(ch, C_NRM), buf, CCNRM(ch, C_NRM)); send_to_char(ch, "PRF: %s%s%s\r\n", CCGRN(ch, C_NRM), buf, CCNRM(ch, C_NRM));
send_to_char(ch, "Quest Points: [%9d] Quests Completed: [%5d]\r\n",
GET_QUESTPOINTS(ch), GET_NUM_QUESTS(ch));
if (GET_QUEST(ch) != NOTHING)
send_to_char(ch, "Current Quest: [%5d] Time Left: [%5d]\r\n",
GET_QUEST(ch), GET_QUEST_TIME(ch));
} }
if (IS_MOB(k)) if (IS_MOB(k))
@ -1120,7 +1057,8 @@ ACMD(do_shutdown)
log("(GC) Reboot by %s.", GET_NAME(ch)); log("(GC) Reboot by %s.", GET_NAME(ch));
send_to_all("Rebooting.. come back in a few minutes.\r\n"); send_to_all("Rebooting.. come back in a few minutes.\r\n");
touch(FASTBOOT_FILE); touch(FASTBOOT_FILE);
circle_shutdown = circle_reboot = 1; circle_shutdown = 1;
circle_reboot = 2; /* do not autosave olc */
} else if (!str_cmp(arg, "die")) { } else if (!str_cmp(arg, "die")) {
log("(GC) Shutdown by %s.", GET_NAME(ch)); log("(GC) Shutdown by %s.", GET_NAME(ch));
send_to_all("Shutting down for maintenance.\r\n"); send_to_all("Shutting down for maintenance.\r\n");
@ -1160,7 +1098,7 @@ void snoop_check(struct char_data *ch)
} }
} }
void stop_snooping(struct char_data *ch) static void stop_snooping(struct char_data *ch)
{ {
if (!ch->desc->snooping) if (!ch->desc->snooping)
send_to_char(ch, "You aren't snooping anyone.\r\n"); send_to_char(ch, "You aren't snooping anyone.\r\n");
@ -1624,7 +1562,7 @@ void perform_immort_vis(struct char_data *ch)
send_to_char(ch, "You are now fully visible.\r\n"); send_to_char(ch, "You are now fully visible.\r\n");
} }
void perform_immort_invis(struct char_data *ch, int level) static void perform_immort_invis(struct char_data *ch, int level)
{ {
struct char_data *tch; struct char_data *tch;
@ -1857,7 +1795,7 @@ struct last_entry *find_llog_entry(int punique, long idnum) {
} }
/* mod_llog_entry assumes that llast is accurate */ /* mod_llog_entry assumes that llast is accurate */
void mod_llog_entry(struct last_entry *llast,int type) { static void mod_llog_entry(struct last_entry *llast,int type) {
FILE *fp; FILE *fp;
struct last_entry mlast; struct last_entry mlast;
int size,recs,tmp; int size,recs,tmp;
@ -1998,7 +1936,7 @@ ACMD(do_list_llog_entries) {
} }
} }
struct char_data *is_in_game(long idnum) { static struct char_data *is_in_game(long idnum) {
struct descriptor_data *i; struct descriptor_data *i;
for (i = descriptor_list; i; i = i->next) { for (i = descriptor_list; i; i = i->next) {
@ -2382,7 +2320,7 @@ ACMD(do_wizutil)
/* single zone printing fn used by "show zone" so it's not repeated in the /* single zone printing fn used by "show zone" so it's not repeated in the
code 3 times ... -je, 4/6/93 FIXME: overflow possible */ code 3 times ... -je, 4/6/93 FIXME: overflow possible */
size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int listall) static size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int listall)
{ {
size_t tmp; size_t tmp;
@ -2592,8 +2530,8 @@ ACMD(do_show)
" %5d mobiles %5d prototypes\r\n" " %5d mobiles %5d prototypes\r\n"
" %5d objects %5d prototypes\r\n" " %5d objects %5d prototypes\r\n"
" %5d rooms %5d zones\r\n" " %5d rooms %5d zones\r\n"
" %5d triggers %5d shops\r\n" " %5d triggers %5d shops\r\n"
" %5d large bufs\r\n" " %5d large bufs %5d autoquests\r\n"
" %5d buf switches %5d overflows\r\n", " %5d buf switches %5d overflows\r\n",
i, con, i, con,
top_of_p_table + 1, top_of_p_table + 1,
@ -2601,7 +2539,7 @@ ACMD(do_show)
k, top_of_objt + 1, k, top_of_objt + 1,
top_of_world + 1, top_of_zone_table + 1, top_of_world + 1, top_of_zone_table + 1,
top_of_trigt + 1, top_shop + 1, top_of_trigt + 1, top_shop + 1,
buf_largecount, buf_largecount, total_quests,
buf_switches, buf_overflows buf_switches, buf_overflows
); );
break; break;
@ -2756,24 +2694,26 @@ ACMD(do_show)
{ "practices", LVL_GOD, PC, NUMBER }, /* 40 */ { "practices", LVL_GOD, PC, NUMBER }, /* 40 */
{ "quest", LVL_GOD, PC, BINARY }, { "quest", LVL_GOD, PC, BINARY },
{ "room", LVL_BUILDER, BOTH, NUMBER }, { "room", LVL_BUILDER, BOTH, NUMBER },
{ "screenwidth", LVL_GOD, PC, NUMBER },
{ "sex", LVL_GOD, BOTH, MISC }, { "sex", LVL_GOD, BOTH, MISC },
{ "showvnums", LVL_BUILDER, PC, BINARY }, { "showvnums", LVL_BUILDER, PC, BINARY }, /* 45 */
{ "siteok", LVL_GOD, PC, BINARY }, /* 45 */ { "siteok", LVL_GOD, PC, BINARY },
{ "str", LVL_BUILDER, BOTH, NUMBER }, { "str", LVL_BUILDER, BOTH, NUMBER },
{ "stradd", LVL_BUILDER, BOTH, NUMBER }, { "stradd", LVL_BUILDER, BOTH, NUMBER },
{ "thief", LVL_GOD, PC, BINARY }, { "thief", LVL_GOD, PC, BINARY },
{ "thirst", LVL_BUILDER, BOTH, MISC }, { "thirst", LVL_BUILDER, BOTH, MISC }, /* 50 */
{ "title", LVL_GOD, PC, MISC }, /* 50 */ { "title", LVL_GOD, PC, MISC },
{ "variable", LVL_GRGOD, PC, MISC }, { "variable", LVL_GRGOD, PC, MISC },
{ "weight", LVL_BUILDER, BOTH, NUMBER }, { "weight", LVL_BUILDER, BOTH, NUMBER },
{ "wis", LVL_BUILDER, BOTH, NUMBER }, { "wis", LVL_BUILDER, BOTH, NUMBER },
{ "questpoints", LVL_GOD, PC, NUMBER }, { "questpoints", LVL_GOD, PC, NUMBER }, /* 55 */
{ "questhistory", LVL_GOD, PC, NUMBER },
{ "\n", 0, BOTH, MISC } { "\n", 0, BOTH, MISC }
}; };
int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg) static int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg)
{ {
int i, on = 0, off = 0, value = 0; int i, on = 0, off = 0, value = 0, qvnum;
room_rnum rnum; room_rnum rnum;
room_vnum rvnum; room_vnum rvnum;
@ -2859,7 +2799,8 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
GET_CLASS(vict) = i; GET_CLASS(vict) = i;
break; break;
case 8: /* color */ case 8: /* color */
SET_OR_REMOVE(PRF_FLAGS(vict), (PRF_COLOR_1 | PRF_COLOR_2)); SET_OR_REMOVE(PRF_FLAGS(vict), (PRF_COLOR_1));
SET_OR_REMOVE(PRF_FLAGS(vict), (PRF_COLOR_2));
break; break;
case 9: /* con */ case 9: /* con */
if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD) if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD)
@ -3086,20 +3027,23 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
char_from_room(vict); char_from_room(vict);
char_to_room(vict, rnum); char_to_room(vict, rnum);
break; break;
case 43: /* sex */ case 43: /* screenwidth */
GET_SCREEN_WIDTH(vict) = RANGE(40, 200);
break;
case 44: /* sex */
if ((i = search_block(val_arg, genders, FALSE)) < 0) { if ((i = search_block(val_arg, genders, FALSE)) < 0) {
send_to_char(ch, "Must be 'male', 'female', or 'neutral'.\r\n"); send_to_char(ch, "Must be 'male', 'female', or 'neutral'.\r\n");
return (0); return (0);
} }
GET_SEX(vict) = i; GET_SEX(vict) = i;
break; break;
case 44: /* showvnums */ case 45: /* showvnums */
SET_OR_REMOVE(PRF_FLAGS(vict), PRF_SHOWVNUMS); SET_OR_REMOVE(PRF_FLAGS(vict), PRF_SHOWVNUMS);
break; break;
case 45: /* siteok */ case 46: /* siteok */
SET_OR_REMOVE(PLR_FLAGS(vict), PLR_SITEOK); SET_OR_REMOVE(PLR_FLAGS(vict), PLR_SITEOK);
break; break;
case 46: /* str */ case 47: /* str */
if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD) if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD)
RANGE(3, 25); RANGE(3, 25);
else else
@ -3108,16 +3052,16 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
vict->real_abils.str_add = 0; vict->real_abils.str_add = 0;
affect_total(vict); affect_total(vict);
break; break;
case 47: /* stradd */ case 48: /* stradd */
vict->real_abils.str_add = RANGE(0, 100); vict->real_abils.str_add = RANGE(0, 100);
if (value > 0) if (value > 0)
vict->real_abils.str = 18; vict->real_abils.str = 18;
affect_total(vict); affect_total(vict);
break; break;
case 48: /* thief */ case 49: /* thief */
SET_OR_REMOVE(PLR_FLAGS(vict), PLR_THIEF); SET_OR_REMOVE(PLR_FLAGS(vict), PLR_THIEF);
break; break;
case 49: /* thirst */ case 50: /* thirst */
if (!str_cmp(val_arg, "off")) { if (!str_cmp(val_arg, "off")) {
GET_COND(vict, THIRST) = -1; GET_COND(vict, THIRST) = -1;
send_to_char(ch, "%s's thirst is now off.\r\n", GET_NAME(vict)); send_to_char(ch, "%s's thirst is now off.\r\n", GET_NAME(vict));
@ -3131,18 +3075,18 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
return (0); return (0);
} }
break; break;
case 50: /* title */ case 51: /* title */
set_title(vict, val_arg); set_title(vict, val_arg);
send_to_char(ch, "%s's title is now: %s\r\n", GET_NAME(vict), GET_TITLE(vict)); send_to_char(ch, "%s's title is now: %s\r\n", GET_NAME(vict), GET_TITLE(vict));
break; break;
case 51: /* variable */ case 52: /* variable */
return perform_set_dg_var(ch, vict, val_arg); return perform_set_dg_var(ch, vict, val_arg);
break; break;
case 52: /* weight */ case 53: /* weight */
GET_WEIGHT(vict) = value; GET_WEIGHT(vict) = value;
affect_total(vict); affect_total(vict);
break; break;
case 53: /* wis */ case 54: /* wis */
if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD) if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD)
RANGE(3, 25); RANGE(3, 25);
else else
@ -3150,9 +3094,26 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
vict->real_abils.wis = value; vict->real_abils.wis = value;
affect_total(vict); affect_total(vict);
break; break;
case 54: /* questpoints */ case 55: /* questpoints */
GET_QUESTPOINTS(vict) = RANGE(0, 100000000); GET_QUESTPOINTS(vict) = RANGE(0, 100000000);
break; break;
case 56: /* questhistory */
qvnum = atoi(val_arg);
if (real_quest(qvnum) == NOTHING) {
send_to_char(ch, "That quest doesn't exist.\r\n");
return FALSE;
} else {
if (is_complete(vict, qvnum)) {
remove_completed_quest(vict, qvnum);
send_to_char(ch, "Quest %d removed from history for player %s.\r\n",
qvnum, GET_NAME(vict));
} else {
add_completed_quest(vict, qvnum);
send_to_char(ch, "Quest %d added to history for player %s.\r\n",
qvnum, GET_NAME(vict));
}
break;
}
default: default:
send_to_char(ch, "Can't set that!\r\n"); send_to_char(ch, "Can't set that!\r\n");
return (0); return (0);
@ -3676,7 +3637,7 @@ ACMD (do_zcheck)
} /* for (k.. */ } /* for (k.. */
} /* cycle directions */ } /* cycle directions */
if (ROOM_FLAGGED(i, ROOM_ATRIUM | ROOM_HOUSE | ROOM_HOUSE_CRASH | ROOM_OLC | ROOM_BFS_MARK)) if (ROOM_FLAGGED(i, ROOM_ATRIUM) || ROOM_FLAGGED(i, ROOM_HOUSE) || ROOM_FLAGGED(i, ROOM_HOUSE_CRASH) || ROOM_FLAGGED(i, ROOM_OLC) || ROOM_FLAGGED(i, ROOM_BFS_MARK))
len += snprintf(buf + len, sizeof(buf) - len, len += snprintf(buf + len, sizeof(buf) - len,
"- Has illegal affection bits set (%s %s %s %s %s)\r\n", "- Has illegal affection bits set (%s %s %s %s %s)\r\n",
ROOM_FLAGGED(i, ROOM_ATRIUM) ? "ATRIUM" : "", ROOM_FLAGGED(i, ROOM_ATRIUM) ? "ATRIUM" : "",
@ -3687,8 +3648,8 @@ ACMD (do_zcheck)
if ((MIN_ROOM_DESC_LENGTH) && strlen(world[i].description)<MIN_ROOM_DESC_LENGTH && (found=1)) if ((MIN_ROOM_DESC_LENGTH) && strlen(world[i].description)<MIN_ROOM_DESC_LENGTH && (found=1))
len += snprintf(buf + len, sizeof(buf) - len, len += snprintf(buf + len, sizeof(buf) - len,
"- Room description is too short. (%4.4d of min. %d characters).\r\n", "- Room description is too short. (%4.4d of min. %d characters).\r\n",
strlen(world[i].description), MIN_ROOM_DESC_LENGTH); (int)strlen(world[i].description), MIN_ROOM_DESC_LENGTH);
if (strncmp(world[i].description, " ", 3) && (found=1)) if (strncmp(world[i].description, " ", 3) && (found=1))
len += snprintf(buf + len, sizeof(buf) - len, len += snprintf(buf + len, sizeof(buf) - len,
@ -3735,7 +3696,7 @@ ACMD (do_zcheck)
} }
void mob_checkload(struct char_data *ch, mob_vnum mvnum) static void mob_checkload(struct char_data *ch, mob_vnum mvnum)
{ {
int cmd_no; int cmd_no;
zone_rnum zone; zone_rnum zone;
@ -3765,7 +3726,7 @@ void mob_checkload(struct char_data *ch, mob_vnum mvnum)
} }
} }
void obj_checkload(struct char_data *ch, obj_vnum ovnum) static void obj_checkload(struct char_data *ch, obj_vnum ovnum)
{ {
int cmd_no; int cmd_no;
zone_rnum zone; zone_rnum zone;
@ -3837,7 +3798,7 @@ void obj_checkload(struct char_data *ch, obj_vnum ovnum)
} /*for zone...*/ } /*for zone...*/
} }
void trg_checkload(struct char_data *ch, trig_vnum tvnum) static void trg_checkload(struct char_data *ch, trig_vnum tvnum)
{ {
int cmd_no, found = 0; int cmd_no, found = 0;
zone_rnum zone; zone_rnum zone;
@ -3998,7 +3959,7 @@ ACMD(do_copyover)
sprintf (buf, "\n\r *** COPYOVER by %s - please remain seated!\n\r", GET_NAME(ch)); sprintf (buf, "\n\r *** COPYOVER by %s - please remain seated!\n\r", GET_NAME(ch));
/* write boot_time as first line in file */ /* write boot_time as first line in file */
fprintf(fp, "%ld\n", boot_time); fprintf(fp, "%ld\n", (long)boot_time);
/* For each playing descriptor, save its state */ /* For each playing descriptor, save its state */
for (d = descriptor_list; d ; d = d_next) { for (d = descriptor_list; d ; d = d_next) {
@ -4100,105 +4061,177 @@ ACMD(do_zpurge)
} }
} }
/** Used to read and gather a bit of information about external log files while
* in game.
* Makes use of the '@' color codes in the file status information.
* Some of the methods used are a bit wasteful (reading through the file
* multiple times to gather diagnostic information), but it is
* assumed that the files read with this function will never be very large.
* Files to be read are assumed to exist and be readable and if they aren't,
* log the name of the missing file.
*/
ACMD(do_file) ACMD(do_file)
{ {
FILE *req_file; /* Local variables */
int cur_line = 0, num_lines = 0, req_lines = 0, i, j, l; int def_lines_to_read = 15; /* Set the default num lines to be read. */
char field[MAX_INPUT_LENGTH], value[MAX_INPUT_LENGTH], line[READ_SIZE]; int max_lines_to_read = 300; /* Maximum number of lines to read. */
char buf[MAX_STRING_LENGTH]; FILE *req_file; /* Pointer to file to be read. */
size_t len = 0, nlen; size_t req_file_size = 0; /* Size of file to be read. */
int req_file_lines = 0; /* Number of total lines in file to be read. */
int lines_read = 0; /* Counts total number of lines read from the file. */
int req_lines = 0; /* Number of lines requested to be displayed. */
int i, j; /* Generic loop counters. */
int l; /* Marks choice of file in fields array. */
char field[MAX_INPUT_LENGTH]; /* Holds users choice of file to be read. */
char value[MAX_INPUT_LENGTH]; /* Holds # lines to be read, if requested. */
char buf[MAX_STRING_LENGTH]; /* Display buffer for req_file. */
/* Defines which files are available to read. */
struct file_struct { struct file_struct {
char *cmd; char *cmd; /* The 'name' of the file to view */
char level; char level; /* Minimum level needed to view. */
char *file; char *file; /* The file location, relative to the working dir. */
int read_backwards; /* Should the file be read backwards by default? */
} fields[] = { } fields[] = {
{ "bugs", LVL_GOD, "../lib/misc/bugs"}, { "bugs", LVL_GOD, BUG_FILE, TRUE},
{ "typos", LVL_GOD, "../lib/misc/typos"}, { "typos", LVL_GOD, TYPO_FILE, TRUE},
{ "ideas", LVL_GOD, "../lib/misc/ideas"}, { "ideas", LVL_GOD, IDEA_FILE, TRUE},
{ "xnames", LVL_GOD, "../lib/misc/xnames"}, { "xnames", LVL_GOD, XNAME_FILE, TRUE},
{ "levels", LVL_GOD, "../log/levels" }, { "levels", LVL_GOD, LEVELS_LOGFILE, TRUE},
{ "rip", LVL_GOD, "../log/rip" }, { "rip", LVL_GOD, RIP_LOGFILE, TRUE},
{ "players", LVL_GOD, "../log/newplayers" }, { "players", LVL_GOD, NEWPLAYERS_LOGFILE, TRUE},
{ "rentgone", LVL_GOD, "../log/rentgone" }, { "rentgone", LVL_GOD, RENTGONE_LOGFILE, TRUE},
{ "errors", LVL_GOD, "../log/errors" }, { "errors", LVL_GOD, ERRORS_LOGFILE, TRUE},
{ "godcmds", LVL_GOD, "../log/godcmds" }, { "godcmds", LVL_GOD, GODCMDS_LOGFILE, TRUE},
{ "syslog", LVL_GOD, "../syslog" }, { "syslog", LVL_GOD, SYSLOG_LOGFILE, TRUE},
{ "crash", LVL_GOD, "../syslog.CRASH" }, { "crash", LVL_GOD, CRASH_LOGFILE, TRUE},
{ "help", LVL_GOD, "../log/help" }, { "help", LVL_GOD, HELP_LOGFILE, TRUE},
{ "changelog", LVL_GOD, "../changelog" }, { "changelog", LVL_GOD, CHANGE_LOG_FILE, FALSE},
{ "\n", 0, "\n" } { "deletes", LVL_GOD, DELETES_LOGFILE, TRUE},
{ "restarts", LVL_GOD, RESTARTS_LOGFILE, TRUE},
{ "usage", LVL_GOD, USAGE_LOGFILE, TRUE},
{ "badpws", LVL_GOD, BADPWS_LOGFILE, TRUE},
{ "olc", LVL_GOD, OLC_LOGFILE, TRUE},
{ "trigger", LVL_GOD, TRIGGER_LOGFILE, TRUE},
{ "\n", 0, "\n", FALSE } /* This must be the last entry */
}; };
/* Initialize buffer */
buf[0] = '\0';
/**/
/* End function variable set-up and initialization. */
skip_spaces(&argument); skip_spaces(&argument);
/* Display usage if no argument. */
if (!*argument) { if (!*argument) {
send_to_char(ch, "USAGE: file <option> <num lines>\r\n\r\nFile options:\r\n"); send_to_char(ch, "USAGE: file <filename> <num lines>\r\n\r\nFile options:\r\n");
for (j = 0, i = 0; fields[i].level; i++) for (j = 0, i = 0; fields[i].level; i++)
if (fields[i].level <= GET_LEVEL(ch)) if (fields[i].level <= GET_LEVEL(ch))
send_to_char(ch, "%-15s%s\r\n", fields[i].cmd, fields[i].file); send_to_char(ch, "%-15s%s\r\n", fields[i].cmd, fields[i].file);
return; return;
} }
/* Begin validity checks. Is the file choice valid and accessible? */
/**/
/* There are some arguments, deal with them. */
two_arguments(argument, field, value); two_arguments(argument, field, value);
for (l = 0; *(fields[l].cmd) != '\n'; l++) for (l = 0; *(fields[l].cmd) != '\n'; l++)
{
if (!strncmp(field, fields[l].cmd, strlen(field))) if (!strncmp(field, fields[l].cmd, strlen(field)))
break; break;
if(*(fields[l].cmd) == '\n') {
send_to_char(ch, "That is not a valid option!\r\n");
return;
} }
if (GET_LEVEL(ch) < fields[l].level) { if(*(fields[l].cmd) == '\n') {
send_to_char(ch, "You are not godly enough to view that file!\r\n"); send_to_char(ch, "'%s' is not a valid file.\r\n", field);
return; return;
} }
if (GET_LEVEL(ch) < fields[l].level) {
send_to_char(ch, "You have not achieved a high enough level to view '%s'.\r\n",
fields[l].cmd);
return;
}
/* Number of lines to view. Default is 15. */
if(!*value) if(!*value)
req_lines = 15; /* Default is the last 15 lines. */ req_lines = def_lines_to_read;
else if (!isdigit(*value))
{
/* This check forces the requisite positive digit and prevents negative
* numbers of lines from being read. */
send_to_char(ch, "'%s' is not a valid number of lines to view.\r\n", value);
return;
}
else else
{
req_lines = atoi(value); req_lines = atoi(value);
/* Limit the maximum number of lines */
req_lines = MIN( req_lines, max_lines_to_read );
}
/* Must be able to access the file on disk. */
if (!(req_file=fopen(fields[l].file,"r"))) { if (!(req_file=fopen(fields[l].file,"r"))) {
send_to_char(ch, "The file %s can not be opened.\r\n", fields[l].file);
mudlog(BRF, LVL_IMPL, TRUE, mudlog(BRF, LVL_IMPL, TRUE,
"SYSERR: Error opening file %s using 'file' command.", "SYSERR: Error opening file %s using 'file' command.",
fields[l].file); fields[l].file);
return; return;
} }
/**/
/* End validity checks. From here on, the file should be viewable. */
/* Diagnostic information about the file */
req_file_size = file_sizeof(req_file);
req_file_lines = file_numlines(req_file);
snprintf( buf, sizeof(buf),
"@gFile:@n %s@g; Min. Level to read:@n %d@g; File Location:@n %s@g\r\n"
"File size (bytes):@n %ld@g; Total num lines:@n %d\r\n",
fields[l].cmd, fields[l].level, fields[l].file, (long) req_file_size,
req_file_lines);
get_line(req_file, line); /* Should the file be 'headed' or 'tailed'? */
while (!feof(req_file)) { if ( (fields[l].read_backwards == TRUE) && (req_lines < req_file_lines) )
num_lines++; {
get_line(req_file,line); snprintf( buf + strlen(buf), sizeof(buf) - strlen(buf),
"@gReading from the tail of the file.@n\r\n\r\n" );
lines_read = file_tail( req_file, buf, sizeof(buf), req_lines );
} }
rewind(req_file); else
{
/* Limit the maximum number of lines to 300. */ snprintf( buf + strlen(buf), sizeof(buf) - strlen(buf),
req_lines = MIN(MIN(req_lines, num_lines), 300); "@gReading from the head of the file.@n\r\n\r\n" );
lines_read = file_head( req_file, buf, sizeof(buf), req_lines );
len = snprintf(buf, sizeof(buf), "Last %d lines of %s:\r\n", req_lines, fields[l].file);
if (req_lines == num_lines)
len += snprintf(buf + len, sizeof(buf) - len, "Top of file.\r\n");
get_line(req_file,line);
while (!feof(req_file)) {
cur_line++;
if(cur_line > (num_lines - req_lines)) {
nlen = snprintf(buf + len, sizeof(buf) - len, "%s\r\n", line);
if (len + nlen >= sizeof(buf) || nlen < 0)
break;
len += nlen;
}
get_line(req_file,line);
} }
/** Since file_head and file_tail will add the overflow message, we
* don't check for status here. */
if ( lines_read == req_file_lines )
{
/* We're reading the entire file */
snprintf( buf + strlen(buf), sizeof(buf) - strlen(buf),
"\r\n@gEntire file returned (@n%d @glines).@n\r\n",
lines_read );
}
else if ( lines_read == max_lines_to_read )
{
snprintf( buf + strlen(buf), sizeof(buf) - strlen(buf),
"\r\n@gMaximum number of @n%d @glines returned.@n\r\n",
lines_read );
}
else
{
snprintf( buf + strlen(buf), sizeof(buf) - strlen(buf),
"\r\n%d @glines returned.@n\r\n",
lines_read );
}
/* Clean up before return */
fclose(req_file); fclose(req_file);
if (len >= sizeof(buf)) {
const char *overflow = "\r\n**OVERFLOW**\r\n";
strcpy(buf + sizeof(buf) - strlen(overflow) - 1, overflow); /* strcpy: OK */
}
page_string(ch->desc, buf, 1); page_string(ch->desc, buf, 1);
} }

View file

@ -7,6 +7,7 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "interpreter.h" #include "interpreter.h"
#include "handler.h" #include "handler.h"
#include "comm.h" #include "comm.h"
@ -16,20 +17,19 @@
#include "screen.h" #include "screen.h"
#include "constants.h" #include "constants.h"
#include "genolc.h" #include "genolc.h"
#include "act.h"
/* local utility functions */
static int aedit_find_command(const char *txt);
static void aedit_disp_menu(struct descriptor_data * d);
static void aedit_save_to_disk(struct descriptor_data *d);
/* used in aedit parse */
static void aedit_setup_new(struct descriptor_data *d);
static void aedit_setup_existing(struct descriptor_data *d, int real_num);
static void aedit_save_internally(struct descriptor_data *d);
/* external functions */
int sort_command_helper(const void *a, const void *b);
void sort_commands(void); /* aedit patch -- M. Scott */
void create_command_list(void);
/* local functions */
ACMD(do_astat);
int aedit_find_command(const char *txt);
void aedit_disp_menu(struct descriptor_data * d);
void aedit_setup_new(struct descriptor_data *d);
void aedit_setup_existing(struct descriptor_data *d, int real_num);
void aedit_save_internally(struct descriptor_data *d);
void aedit_save_to_disk(struct descriptor_data *d);
/* Utils and exported functions. */ /* Utils and exported functions. */
ACMD(do_oasis_aedit) ACMD(do_oasis_aedit)
@ -107,7 +107,7 @@ ACMD(do_oasis_aedit)
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing actions.", GET_NAME(ch)); mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing actions.", GET_NAME(ch));
} }
void aedit_setup_new(struct descriptor_data *d) { static void aedit_setup_new(struct descriptor_data *d) {
CREATE(OLC_ACTION(d), struct social_messg, 1); CREATE(OLC_ACTION(d), struct social_messg, 1);
OLC_ACTION(d)->command = strdup(OLC_STORAGE(d)); OLC_ACTION(d)->command = strdup(OLC_STORAGE(d));
OLC_ACTION(d)->sort_as = strdup(OLC_STORAGE(d)); OLC_ACTION(d)->sort_as = strdup(OLC_STORAGE(d));
@ -132,7 +132,7 @@ void aedit_setup_new(struct descriptor_data *d) {
OLC_VAL(d) = 0; OLC_VAL(d) = 0;
} }
void aedit_setup_existing(struct descriptor_data *d, int real_num) { static void aedit_setup_existing(struct descriptor_data *d, int real_num) {
CREATE(OLC_ACTION(d), struct social_messg, 1); CREATE(OLC_ACTION(d), struct social_messg, 1);
OLC_ACTION(d)->command = strdup(soc_mess_list[real_num].command); OLC_ACTION(d)->command = strdup(soc_mess_list[real_num].command);
OLC_ACTION(d)->sort_as = strdup(soc_mess_list[real_num].sort_as); OLC_ACTION(d)->sort_as = strdup(soc_mess_list[real_num].sort_as);
@ -170,7 +170,7 @@ void aedit_setup_existing(struct descriptor_data *d, int real_num) {
aedit_disp_menu(d); aedit_disp_menu(d);
} }
void aedit_save_internally(struct descriptor_data *d) { static void aedit_save_internally(struct descriptor_data *d) {
struct social_messg *new_soc_mess_list = NULL; struct social_messg *new_soc_mess_list = NULL;
int i; int i;
@ -193,13 +193,14 @@ void aedit_save_internally(struct descriptor_data *d) {
} }
create_command_list(); create_command_list();
/* aedit patch -- M. Scott */
sort_commands(); sort_commands();
add_to_save_list(AEDIT_PERMISSION, SL_ACT); add_to_save_list(AEDIT_PERMISSION, SL_ACT);
aedit_save_to_disk(d); /* autosave by Rumble */ aedit_save_to_disk(d); /* autosave by Rumble */
} }
void aedit_save_to_disk(struct descriptor_data *d) { static void aedit_save_to_disk(struct descriptor_data *d) {
FILE *fp; FILE *fp;
int i; int i;
if (!(fp = fopen(SOCMESS_FILE_NEW, "w+"))) { if (!(fp = fopen(SOCMESS_FILE_NEW, "w+"))) {
@ -242,7 +243,7 @@ void aedit_save_to_disk(struct descriptor_data *d) {
} }
/* The Main Menu. */ /* The Main Menu. */
void aedit_disp_menu(struct descriptor_data * d) { static void aedit_disp_menu(struct descriptor_data * d) {
struct social_messg *action = OLC_ACTION(d); struct social_messg *action = OLC_ACTION(d);
struct char_data *ch = d->character; struct char_data *ch = d->character;
@ -798,7 +799,7 @@ ACMD(do_astat)
} }
int aedit_find_command(const char *txt) static int aedit_find_command(const char *txt)
{ {
int cmd; int cmd;

View file

@ -8,6 +8,8 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/ **************************************************************************/
#define __BAN_C__
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
@ -16,22 +18,21 @@
#include "interpreter.h" #include "interpreter.h"
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "ban.h"
/* local globals */ /* global variables locally defined, used externally */
struct ban_list_element *ban_list = NULL; struct ban_list_element *ban_list = NULL;
int num_invalid = 0;
/* local functions */ /* Local (file) scope variables */
void load_banned(void); #define MAX_INVALID_NAMES 200
int isbanned(char *hostname); static char *invalid_list[MAX_INVALID_NAMES];
void _write_one_node(FILE *fp, struct ban_list_element *node);
void write_ban_list(void);
ACMD(do_ban);
ACMD(do_unban);
int valid_name(char *newname);
void read_invalid_list(void);
void free_invalid_list(void);
const char *ban_types[] = { /* local utility functions */
static void write_ban_list(void);
static void _write_one_node(FILE *fp, struct ban_list_element *node);
static const char *ban_types[] = {
"no", "no",
"new", "new",
"select", "select",
@ -95,7 +96,7 @@ int isbanned(char *hostname)
return (i); return (i);
} }
void _write_one_node(FILE *fp, struct ban_list_element *node) static void _write_one_node(FILE *fp, struct ban_list_element *node)
{ {
if (node) { if (node) {
_write_one_node(fp, node->next); _write_one_node(fp, node->next);
@ -104,7 +105,7 @@ void _write_one_node(FILE *fp, struct ban_list_element *node)
} }
} }
void write_ban_list(void) static void write_ban_list(void)
{ {
FILE *fl; FILE *fl;
@ -224,11 +225,9 @@ ACMD(do_unban)
write_ban_list(); write_ban_list();
} }
/* Check for invalid names (i.e., profanity, etc.) Written by Sharon P Garza. */
#define MAX_INVALID_NAMES 200
char *invalid_list[MAX_INVALID_NAMES];
int num_invalid = 0;
/* Check for invalid names (i.e., profanity, etc.) Written by Sharon P Garza. */
int valid_name(char *newname) int valid_name(char *newname)
{ {
int i, vowels = 0; int i, vowels = 0;

View file

@ -8,6 +8,8 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/ **************************************************************************/
#define __BOARDS_C__
/* FEATURES & INSTALLATION INSTRUCTIONS /* FEATURES & INSTALLATION INSTRUCTIONS
* - Arbitrary number of boards handled by one set of generalized routines. * - Arbitrary number of boards handled by one set of generalized routines.
* Adding a new board is as easy as adding another entry to an array. * Adding a new board is as easy as adding another entry to an array.
@ -38,6 +40,7 @@
#include "interpreter.h" #include "interpreter.h"
#include "handler.h" #include "handler.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "modify.h"
/* Board appearance order. */ /* Board appearance order. */
#define NEWEST_AT_TOP FALSE #define NEWEST_AT_TOP FALSE
@ -54,20 +57,20 @@ struct board_info_type board_info[NUM_OF_BOARDS] = {
{1228, 0, 0, LVL_IMPL, LIB_ETC "board.advertising", 0}, {1228, 0, 0, LVL_IMPL, LIB_ETC "board.advertising", 0},
}; };
/* local functions */ /* local (file scope) global variables */
SPECIAL(gen_board); static char *msg_storage[INDEX_SIZE];
int find_slot(void); static int msg_storage_taken[INDEX_SIZE];
int find_board(struct char_data *ch); static int num_of_msgs[NUM_OF_BOARDS];
void init_boards(void); static struct board_msginfo msg_index[NUM_OF_BOARDS][MAX_BOARD_MESSAGES];
char *msg_storage[INDEX_SIZE];
int msg_storage_taken[INDEX_SIZE];
int num_of_msgs[NUM_OF_BOARDS];
int ACMD_READ, ACMD_LOOK, ACMD_EXAMINE, ACMD_WRITE, ACMD_REMOVE;
struct board_msginfo msg_index[NUM_OF_BOARDS][MAX_BOARD_MESSAGES];
void board_reset_board(int board_type);
void board_clear_board(int board_type);
int find_slot(void) /* local static utility functions */
static int find_slot(void);
static int find_board(struct char_data *ch);
static void init_boards(void);
static void board_reset_board(int board_type);
static void board_clear_board(int board_type);
static int find_slot(void)
{ {
int i; int i;
@ -80,7 +83,7 @@ int find_slot(void)
} }
/* search the room ch is standing in to find which board he's looking at */ /* search the room ch is standing in to find which board he's looking at */
int find_board(struct char_data *ch) static int find_board(struct char_data *ch)
{ {
struct obj_data *obj; struct obj_data *obj;
int i; int i;
@ -99,7 +102,7 @@ int find_board(struct char_data *ch)
return (-1); return (-1);
} }
void init_boards(void) static void init_boards(void)
{ {
int i, j, fatal_error = 0; int i, j, fatal_error = 0;
@ -132,6 +135,9 @@ SPECIAL(gen_board)
static int loaded = 0; static int loaded = 0;
struct obj_data *board = (struct obj_data *)me; struct obj_data *board = (struct obj_data *)me;
/* These were originally globals for some unknown reason. */
int ACMD_READ, ACMD_LOOK, ACMD_EXAMINE, ACMD_WRITE, ACMD_REMOVE;
if (!loaded) { if (!loaded) {
init_boards(); init_boards();
loaded = 1; loaded = 1;
@ -514,7 +520,7 @@ void board_clear_board(int board_type)
} }
/* Destroy the on-disk and in-memory board. */ /* Destroy the on-disk and in-memory board. */
void board_reset_board(int board_type) static void board_reset_board(int board_type)
{ {
board_clear_board(board_type); board_clear_board(board_type);
remove(FILENAME(board_type)); remove(FILENAME(board_type));

View file

@ -1,12 +1,17 @@
/************************************************************************** /**
* File: boards.h Part of tbaMUD * * @file boards.h
* Usage: header file for bulletin boards * * Header file for the bulletin board system (boards.c).
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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 _BOARDS_H_
#define _BOARDS_H_
#define NUM_OF_BOARDS 7 /* change if needed! */ #define NUM_OF_BOARDS 7 /* change if needed! */
#define MAX_BOARD_MESSAGES 60 /* arbitrary -- change if needed */ #define MAX_BOARD_MESSAGES 60 /* arbitrary -- change if needed */
@ -45,6 +50,7 @@ struct board_info_type {
#define MSG_SLOTNUM(i, j) (msg_index[i][j].slot_num) #define MSG_SLOTNUM(i, j) (msg_index[i][j].slot_num)
#define MSG_LEVEL(i, j) (msg_index[i][j].level) #define MSG_LEVEL(i, j) (msg_index[i][j].level)
SPECIAL(gen_board);
int board_display_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board); int board_display_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board);
int board_show_board(int board_type, struct char_data *ch, char *arg, struct obj_data *board); int board_show_board(int board_type, struct char_data *ch, char *arg, struct obj_data *board);
int board_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board); int board_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board);
@ -52,3 +58,12 @@ int board_write_message(int board_type, struct char_data *ch, char *arg, struct
void board_save_board(int board_type); void board_save_board(int board_type);
void board_load_board(int board_type); void board_load_board(int board_type);
void board_clear_all(void); void board_clear_all(void);
/* Global variables */
#ifndef __BOARDS_C__
extern struct board_info_type board_info[NUM_OF_BOARDS];
#endif /* __BOARDS_C__ */
#endif /* _BOARDS_H_ */

View file

@ -1,7 +1,10 @@
/************************************************************************** /**
* File: bsd-snprintf.h Part of tbaMUD * * @file bsd-snprintf.h
* Usage: Used if your OS does not provide snprintf() or vsnprintf(). * * Used if your OS does not provide snprintf() or vsnprintf().
**************************************************************************/ *
* Part of the core tbaMUD source code distribution, which is a derivative
* of, and continuation of, CircleMUD.
*/
/* This file taken from openbsd-compat of OpenSSH 3.1: /* This file taken from openbsd-compat of OpenSSH 3.1:
* *
@ -39,10 +42,9 @@
* --- 8< --- OpenSSH LICENSE --- 8< --- * --- 8< --- OpenSSH LICENSE --- 8< ---
*/ */
/* $Id: bsd-snprintf.h,v 1.1 2002/04/16 02:22:12 greerga Exp $ */
#ifndef _BSD_SNPRINTF_H #ifndef _BSD_SNPRINTF_H_
#define _BSD_SNPRINTF_H #define _BSD_SNPRINTF_H_
#ifndef HAVE_SNPRINTF #ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t count, const char *fmt, ...); int snprintf(char *str, size_t count, const char *fmt, ...);
@ -53,4 +55,4 @@ int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif /* !HAVE_SNPRINTF */ #endif /* !HAVE_SNPRINTF */
#endif /* _BSD_SNPRINTF_H */ #endif /* _BSD_SNPRINTF_H_ */

View file

@ -17,34 +17,32 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "spells.h" #include "spells.h"
#include "act.h"
#include "spec_procs.h" /**< castle.c is part of the spec_procs module */
#include "fight.h"
/* IMPORTANT! The below defined number is the zone number of the Kings Castle. /* IMPORTANT! The below defined number is the zone number of the Kings Castle.
* Change it to apply to your chosen zone number. The default zone number * Change it to apply to your chosen zone number. The default zone number
* is 80. */ * is 80. */
#define Z_KINGS_C 150 #define Z_KINGS_C 150
/* external variables */
extern struct time_info_data time_info;
extern int mini_mud;
/* local functions */
mob_vnum castle_virtual(mob_vnum offset);
room_rnum castle_real_room(room_vnum roomoffset);
struct char_data *find_npc_by_name(struct char_data *chAtChar, const char *pszName, int iLen);
int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room, int iProhibited_direction);
void assign_kings_castle(void);
int member_of_staff(struct char_data *chChar);
int member_of_royal_guard(struct char_data *chChar);
struct char_data *find_guard(struct char_data *chAtChar);
struct char_data *get_victim(struct char_data *chAtChar);
int banzaii(struct char_data *ch);
int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim);
int is_trash(struct obj_data *i);
void fry_victim(struct char_data *ch);
int castle_cleaner(struct char_data *ch, int cmd, int gripe);
int castle_twin_proc(struct char_data *ch, int cmd, char *arg, int ctlnum, const char *twinname);
void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc));
/* local, file scope restricted functions */
static mob_vnum castle_virtual(mob_vnum offset);
static room_rnum castle_real_room(room_vnum roomoffset);
static struct char_data *find_npc_by_name(struct char_data *chAtChar, const char *pszName, int iLen);
static int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room, int iProhibited_direction);
static int member_of_staff(struct char_data *chChar);
static int member_of_royal_guard(struct char_data *chChar);
static struct char_data *find_guard(struct char_data *chAtChar);
static struct char_data *get_victim(struct char_data *chAtChar);
static int banzaii(struct char_data *ch);
static int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim);
static int is_trash(struct obj_data *i);
static void fry_victim(struct char_data *ch);
static int castle_cleaner(struct char_data *ch, int cmd, int gripe);
static int castle_twin_proc(struct char_data *ch, int cmd, char *arg, int ctlnum, const char *twinname);
static void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc));
/* Special procedures for Kings Castle by Pjotr. Coded by Sapowox. */ /* Special procedures for Kings Castle by Pjotr. Coded by Sapowox. */
SPECIAL(CastleGuard); SPECIAL(CastleGuard);
SPECIAL(James); SPECIAL(James);
@ -56,13 +54,13 @@ SPECIAL(king_welmar);
SPECIAL(training_master); SPECIAL(training_master);
SPECIAL(peter); SPECIAL(peter);
SPECIAL(jerry); SPECIAL(jerry);
SPECIAL(guild);
ACMD(do_gen_door);
ACMD(do_follow);
/* Assign castle special procedures. NOTE: The mobile number isn't fully /* Assign castle special procedures. NOTE: The mobile number isn't fully
* specified. It's only an offset from the zone's base. */ * specified. It's only an offset from the zone's base. */
void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc)) static void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc))
{ {
mob_vnum vmv = castle_virtual(mobnum); mob_vnum vmv = castle_virtual(mobnum);
mob_rnum rmr = NOBODY; mob_rnum rmr = NOBODY;
@ -80,7 +78,7 @@ void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc))
mob_index[rmr].func = specproc; mob_index[rmr].func = specproc;
} }
mob_vnum castle_virtual(mob_vnum offset) static mob_vnum castle_virtual(mob_vnum offset)
{ {
zone_rnum zon; zone_rnum zon;
@ -90,7 +88,7 @@ mob_vnum castle_virtual(mob_vnum offset)
return zone_table[zon].bot + offset; return zone_table[zon].bot + offset;
} }
room_rnum castle_real_room(room_vnum roomoffset) static room_rnum castle_real_room(room_vnum roomoffset)
{ {
zone_rnum zon; zone_rnum zon;
@ -131,7 +129,7 @@ void assign_kings_castle(void)
/* Routine: member_of_staff. Used to see if a character is a member of the /* Routine: member_of_staff. Used to see if a character is a member of the
* castle staff. Used mainly by BANZAI:ng NPC:s. */ * castle staff. Used mainly by BANZAI:ng NPC:s. */
int member_of_staff(struct char_data *chChar) static int member_of_staff(struct char_data *chChar)
{ {
int ch_num; int ch_num;
@ -157,7 +155,7 @@ int member_of_staff(struct char_data *chChar)
/* Function: member_of_royal_guard. Returns TRUE if the character is a guard on /* Function: member_of_royal_guard. Returns TRUE if the character is a guard on
* duty, otherwise FALSE. Used by Peter the captain of the royal guard. */ * duty, otherwise FALSE. Used by Peter the captain of the royal guard. */
int member_of_royal_guard(struct char_data *chChar) static int member_of_royal_guard(struct char_data *chChar)
{ {
int ch_num; int ch_num;
@ -180,7 +178,7 @@ int member_of_royal_guard(struct char_data *chChar)
/* Function: find_npc_by_name. Returns a pointer to an npc by the given name. /* Function: find_npc_by_name. Returns a pointer to an npc by the given name.
* Used by Tim and Tom. */ * Used by Tim and Tom. */
struct char_data *find_npc_by_name(struct char_data *chAtChar, static struct char_data *find_npc_by_name(struct char_data *chAtChar,
const char *pszName, int iLen) const char *pszName, int iLen)
{ {
struct char_data *ch; struct char_data *ch;
@ -194,7 +192,7 @@ struct char_data *find_npc_by_name(struct char_data *chAtChar,
/* Function: find_guard. Returns the pointer to a guard on duty. Used by Peter /* Function: find_guard. Returns the pointer to a guard on duty. Used by Peter
* the Captain of the Royal Guard */ * the Captain of the Royal Guard */
struct char_data *find_guard(struct char_data *chAtChar) static struct char_data *find_guard(struct char_data *chAtChar)
{ {
struct char_data *ch; struct char_data *ch;
@ -208,7 +206,7 @@ struct char_data *find_guard(struct char_data *chAtChar)
/* Function: get_victim. Returns a pointer to a randomly chosen character in /* Function: get_victim. Returns a pointer to a randomly chosen character in
* the same room, fighting someone in the castle staff. Used by BANZAII-ing * the same room, fighting someone in the castle staff. Used by BANZAII-ing
* characters and King Welmar... */ * characters and King Welmar... */
struct char_data *get_victim(struct char_data *chAtChar) static struct char_data *get_victim(struct char_data *chAtChar)
{ {
struct char_data *ch; struct char_data *ch;
int iNum_bad_guys = 0, iVictim; int iNum_bad_guys = 0, iVictim;
@ -244,7 +242,7 @@ struct char_data *get_victim(struct char_data *chAtChar)
/* Banzaii. Makes a character banzaii on attackers of the castle staff. Used /* Banzaii. Makes a character banzaii on attackers of the castle staff. Used
* by Guards, Tim, Tom, Dick, David, Peter, Master, and the King. */ * by Guards, Tim, Tom, Dick, David, Peter, Master, and the King. */
int banzaii(struct char_data *ch) static int banzaii(struct char_data *ch)
{ {
struct char_data *chOpponent; struct char_data *chOpponent;
@ -258,7 +256,7 @@ int banzaii(struct char_data *ch)
} }
/* Do_npc_rescue. Makes ch_hero rescue ch_victim. Used by Tim and Tom. */ /* Do_npc_rescue. Makes ch_hero rescue ch_victim. Used by Tim and Tom. */
int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim) static int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim)
{ {
struct char_data *ch_bad_guy; struct char_data *ch_bad_guy;
@ -287,7 +285,7 @@ int do_npc_rescue(struct char_data *ch_hero, struct char_data *ch_victim)
/* Procedure to block a person trying to enter a room. Used by Tim/Tom at Kings /* Procedure to block a person trying to enter a room. Used by Tim/Tom at Kings
* bedroom and Dick/David at treasury. */ * bedroom and Dick/David at treasury. */
int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room, static int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room,
int iProhibited_direction) int iProhibited_direction)
{ {
if (cmd != ++iProhibited_direction) if (cmd != ++iProhibited_direction)
@ -308,7 +306,7 @@ int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room,
/* Routine to check if an object is trash. Used by James the Butler and the /* Routine to check if an object is trash. Used by James the Butler and the
* Cleaning Lady. */ * Cleaning Lady. */
int is_trash(struct obj_data *i) static int is_trash(struct obj_data *i)
{ {
if (!OBJWEAR_FLAGGED(i, ITEM_WEAR_TAKE)) if (!OBJWEAR_FLAGGED(i, ITEM_WEAR_TAKE))
return (FALSE); return (FALSE);
@ -321,7 +319,7 @@ int is_trash(struct obj_data *i)
/* Fry_victim. Finds a suitabe victim, and cast some _NASTY_ spell on him. Used /* Fry_victim. Finds a suitabe victim, and cast some _NASTY_ spell on him. Used
* by King Welmar. */ * by King Welmar. */
void fry_victim(struct char_data *ch) static void fry_victim(struct char_data *ch)
{ {
struct char_data *tch; struct char_data *tch;
@ -578,7 +576,7 @@ SPECIAL(tim)
} }
/* Common routine for the Castle Twins. */ /* Common routine for the Castle Twins. */
int castle_twin_proc(struct char_data *ch, int cmd, char *arg, int ctlnum, const char *twinname) static int castle_twin_proc(struct char_data *ch, int cmd, char *arg, int ctlnum, const char *twinname)
{ {
struct char_data *king, *twin; struct char_data *king, *twin;
@ -616,7 +614,7 @@ SPECIAL(James)
} }
/* Common code for James and the Cleaning Woman. */ /* Common code for James and the Cleaning Woman. */
int castle_cleaner(struct char_data *ch, int cmd, int gripe) static int castle_cleaner(struct char_data *ch, int cmd, int gripe)
{ {
struct obj_data *i; struct obj_data *i;

View file

@ -8,34 +8,31 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "utils.h"
#include "db.h" #include "db.h"
#include "constants.h" #include "constants.h"
#include "genolc.h" #include "genolc.h"
#include "oasis.h" #include "oasis.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "modify.h"
/* Local Macros */
#define NO 0
#define YES 1
#define CHECK_VAR(var) ((var == YES) ? "Yes" : "No") #define CHECK_VAR(var) ((var == YES) ? "Yes" : "No")
#define TOGGLE_VAR(var) if (var == YES) { var = NO; } else { var = YES; } #define TOGGLE_VAR(var) if (var == YES) { var = NO; } else { var = YES; }
/* local functions */ /* local scope functions, not used externally */
void cedit_disp_menu(struct descriptor_data *d); static void cedit_disp_menu(struct descriptor_data *d);
void cedit_save_internally(struct descriptor_data *d); static void cedit_save_internally(struct descriptor_data *d);
void cedit_disp_game_play_options(struct descriptor_data *d); static void cedit_disp_game_play_options(struct descriptor_data *d);
void cedit_disp_crash_save_options(struct descriptor_data *d); static void cedit_disp_crash_save_options(struct descriptor_data *d);
void cedit_disp_room_numbers(struct descriptor_data *d); static void cedit_disp_room_numbers(struct descriptor_data *d);
void cedit_disp_operation_options(struct descriptor_data *d); static void cedit_disp_operation_options(struct descriptor_data *d);
void cedit_disp_autowiz_options(struct descriptor_data *d); static void cedit_disp_autowiz_options(struct descriptor_data *d);
int save_config( IDXTYPE nowhere ); static void reassign_rooms(void);
void reassign_rooms(void); static void cedit_setup(struct descriptor_data *d);
void cedit_setup(struct descriptor_data *d);
void cedit_save_to_disk( void );
ACMD(do_oasis_cedit) ACMD(do_oasis_cedit)
{ {
@ -79,7 +76,7 @@ ACMD(do_oasis_cedit)
cedit_save_to_disk(); cedit_save_to_disk();
} }
void cedit_setup(struct descriptor_data *d) static void cedit_setup(struct descriptor_data *d)
{ {
/* Create the config_data struct. */ /* Create the config_data struct. */
CREATE(OLC_CONFIG(d), struct config_data, 1); CREATE(OLC_CONFIG(d), struct config_data, 1);
@ -103,7 +100,10 @@ void cedit_setup(struct descriptor_data *d)
OLC_CONFIG(d)->play.track_through_doors = CONFIG_TRACK_T_DOORS; OLC_CONFIG(d)->play.track_through_doors = CONFIG_TRACK_T_DOORS;
OLC_CONFIG(d)->play.no_mort_to_immort = CONFIG_NO_MORT_TO_IMMORT; OLC_CONFIG(d)->play.no_mort_to_immort = CONFIG_NO_MORT_TO_IMMORT;
OLC_CONFIG(d)->play.disp_closed_doors = CONFIG_DISP_CLOSED_DOORS; OLC_CONFIG(d)->play.disp_closed_doors = CONFIG_DISP_CLOSED_DOORS;
OLC_CONFIG(d)->play.map_option = CONFIG_MAP;
OLC_CONFIG(d)->play.map_size = CONFIG_MAP_SIZE;
OLC_CONFIG(d)->play.minimap_size = CONFIG_MINIMAP_SIZE;
/* Crash Saves */ /* Crash Saves */
OLC_CONFIG(d)->csd.free_rent = CONFIG_FREE_RENT; OLC_CONFIG(d)->csd.free_rent = CONFIG_FREE_RENT;
OLC_CONFIG(d)->csd.max_obj_save = CONFIG_MAX_OBJ_SAVE; OLC_CONFIG(d)->csd.max_obj_save = CONFIG_MAX_OBJ_SAVE;
@ -174,7 +174,7 @@ void cedit_setup(struct descriptor_data *d)
cedit_disp_menu(d); cedit_disp_menu(d);
} }
void cedit_save_internally(struct descriptor_data *d) static void cedit_save_internally(struct descriptor_data *d)
{ {
/* see if we need to reassign spec procs on rooms */ /* see if we need to reassign spec procs on rooms */
int reassign = (CONFIG_DTS_ARE_DUMPS != OLC_CONFIG(d)->play.dts_are_dumps); int reassign = (CONFIG_DTS_ARE_DUMPS != OLC_CONFIG(d)->play.dts_are_dumps);
@ -196,6 +196,9 @@ void cedit_save_internally(struct descriptor_data *d)
CONFIG_TRACK_T_DOORS = OLC_CONFIG(d)->play.track_through_doors; CONFIG_TRACK_T_DOORS = OLC_CONFIG(d)->play.track_through_doors;
CONFIG_NO_MORT_TO_IMMORT = OLC_CONFIG(d)->play.no_mort_to_immort; CONFIG_NO_MORT_TO_IMMORT = OLC_CONFIG(d)->play.no_mort_to_immort;
CONFIG_DISP_CLOSED_DOORS = OLC_CONFIG(d)->play.disp_closed_doors; CONFIG_DISP_CLOSED_DOORS = OLC_CONFIG(d)->play.disp_closed_doors;
CONFIG_MAP = OLC_CONFIG(d)->play.map_option;
CONFIG_MAP_SIZE = OLC_CONFIG(d)->play.map_size;
CONFIG_MINIMAP_SIZE = OLC_CONFIG(d)->play.minimap_size;
/* Crash Saves */ /* Crash Saves */
CONFIG_FREE_RENT = OLC_CONFIG(d)->csd.free_rent; CONFIG_FREE_RENT = OLC_CONFIG(d)->csd.free_rent;
@ -354,7 +357,14 @@ int save_config( IDXTYPE nowhere )
"no_mort_to_immort = %d\n\n", CONFIG_NO_MORT_TO_IMMORT); "no_mort_to_immort = %d\n\n", CONFIG_NO_MORT_TO_IMMORT);
fprintf(fl, "* Should closed doors be shown on autoexit / exit?\n" fprintf(fl, "* Should closed doors be shown on autoexit / exit?\n"
"disp_closed_doors = %d\n\n", CONFIG_DISP_CLOSED_DOORS); "disp_closed_doors = %d\n\n", CONFIG_DISP_CLOSED_DOORS);
fprintf(fl, "* Who can use the map functions? 0=off, 1=on, 2=imm_only\n"
"map_option = %d\n\n", CONFIG_MAP);
fprintf(fl, "* Default size of map shown by 'map' command\n"
"default_map_size = %d\n\n", CONFIG_MAP_SIZE);
fprintf(fl, "* Default minimap size shown to the right of room descriptions\n"
"default_minimap_size = %d\n\n", CONFIG_MINIMAP_SIZE);
strcpy(buf, CONFIG_OK); strcpy(buf, CONFIG_OK);
strip_cr(buf); strip_cr(buf);
@ -524,8 +534,9 @@ int save_config( IDXTYPE nowhere )
} }
/* Menu functions - The main menu. */ /* Menu functions - The main menu. */
void cedit_disp_menu(struct descriptor_data *d) static void cedit_disp_menu(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
@ -551,11 +562,15 @@ void cedit_disp_menu(struct descriptor_data *d)
OLC_MODE(d) = CEDIT_MAIN_MENU; OLC_MODE(d) = CEDIT_MAIN_MENU;
} }
void cedit_disp_game_play_options(struct descriptor_data *d) static void cedit_disp_game_play_options(struct descriptor_data *d)
{ {
int m_opt;
m_opt = OLC_CONFIG(d)->play.map_option;
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
write_to_output(d, "\r\n\r\n" write_to_output(d, "\r\n\r\n"
"%sA%s) Player Killing Allowed : %s%s\r\n" "%sA%s) Player Killing Allowed : %s%s\r\n"
"%sB%s) Player Thieving Allowed : %s%s\r\n" "%sB%s) Player Thieving Allowed : %s%s\r\n"
@ -574,9 +589,12 @@ void cedit_disp_game_play_options(struct descriptor_data *d)
"%sO%s) Track Through Doors : %s%s\r\n" "%sO%s) Track Through Doors : %s%s\r\n"
"%sP%s) Display Closed Doors : %s%s\r\n" "%sP%s) Display Closed Doors : %s%s\r\n"
"%sR%s) Mortals Level To Immortal : %s%s\r\n" "%sR%s) Mortals Level To Immortal : %s%s\r\n"
"%s1%s) OK Message Text : %s%s" "%s1%s) OK Message Text : %s%s"
"%s2%s) NOPERSON Message Text : %s%s" "%s2%s) NOPERSON Message Text : %s%s"
"%s3%s) NOEFFECT Message Text : %s%s" "%s3%s) NOEFFECT Message Text : %s%s"
"%s4%s) Map/Automap Option : %s%s\r\n"
"%s5%s) Default map size : %s%d\r\n"
"%s6%s) Default minimap size : %s%d\r\n"
"%sQ%s) Exit To The Main Menu\r\n" "%sQ%s) Exit To The Main Menu\r\n"
"Enter your choice : ", "Enter your choice : ",
grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.pk_allowed), grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.pk_allowed),
@ -596,11 +614,14 @@ void cedit_disp_game_play_options(struct descriptor_data *d)
grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.load_into_inventory), grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.load_into_inventory),
grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.track_through_doors), grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.track_through_doors),
grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.disp_closed_doors), grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.disp_closed_doors),
grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.no_mort_to_immort), grn, nrm, cyn, CHECK_VAR(OLC_CONFIG(d)->play.no_mort_to_immort),
grn, nrm, cyn, OLC_CONFIG(d)->play.OK, grn, nrm, cyn, OLC_CONFIG(d)->play.OK,
grn, nrm, cyn, OLC_CONFIG(d)->play.NOPERSON, grn, nrm, cyn, OLC_CONFIG(d)->play.NOPERSON,
grn, nrm, cyn, OLC_CONFIG(d)->play.NOEFFECT, grn, nrm, cyn, OLC_CONFIG(d)->play.NOEFFECT,
grn, nrm, cyn, m_opt == 0 ? "Off" : (m_opt == 1 ? "On" : (m_opt == 2 ? "Imm-Only" : "Invalid!")),
grn, nrm, cyn, OLC_CONFIG(d)->play.map_size,
grn, nrm, cyn, OLC_CONFIG(d)->play.minimap_size,
grn, nrm grn, nrm
); );
@ -608,7 +629,7 @@ void cedit_disp_game_play_options(struct descriptor_data *d)
OLC_MODE(d) = CEDIT_GAME_OPTIONS_MENU; OLC_MODE(d) = CEDIT_GAME_OPTIONS_MENU;
} }
void cedit_disp_crash_save_options(struct descriptor_data *d) static void cedit_disp_crash_save_options(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
@ -636,7 +657,7 @@ void cedit_disp_crash_save_options(struct descriptor_data *d)
OLC_MODE(d) = CEDIT_CRASHSAVE_OPTIONS_MENU; OLC_MODE(d) = CEDIT_CRASHSAVE_OPTIONS_MENU;
} }
void cedit_disp_room_numbers(struct descriptor_data *d) static void cedit_disp_room_numbers(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
@ -662,7 +683,7 @@ void cedit_disp_room_numbers(struct descriptor_data *d)
OLC_MODE(d) = CEDIT_ROOM_NUMBERS_MENU; OLC_MODE(d) = CEDIT_ROOM_NUMBERS_MENU;
} }
void cedit_disp_operation_options(struct descriptor_data *d) static void cedit_disp_operation_options(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
@ -704,7 +725,7 @@ void cedit_disp_operation_options(struct descriptor_data *d)
OLC_MODE(d) = CEDIT_OPERATION_OPTIONS_MENU; OLC_MODE(d) = CEDIT_OPERATION_OPTIONS_MENU;
} }
void cedit_disp_autowiz_options(struct descriptor_data *d) static void cedit_disp_autowiz_options(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
@ -910,6 +931,24 @@ void cedit_parse(struct descriptor_data *d, char *arg)
OLC_MODE(d) = CEDIT_NOEFFECT; OLC_MODE(d) = CEDIT_NOEFFECT;
return; return;
case '4':
write_to_output(d, "1) Disable maps\r\n");
write_to_output(d, "2) Enable Maps\r\n");
write_to_output(d, "3) Maps for Immortals only\r\n");
write_to_output(d, "Enter choice: ");
OLC_MODE(d) = CEDIT_MAP_OPTION;
return;
case '5':
write_to_output(d, "Enter default map size (1-12) : ");
OLC_MODE(d) = CEDIT_MAP_SIZE;
return;
case '6':
write_to_output(d, "Enter default mini-map size (1-12) : ");
OLC_MODE(d) = CEDIT_MINIMAP_SIZE;
return;
case 'q': case 'q':
case 'Q': case 'Q':
cedit_disp_menu(d); cedit_disp_menu(d);
@ -1281,8 +1320,7 @@ void cedit_parse(struct descriptor_data *d, char *arg)
if (OLC_CONFIG(d)->play.OK) if (OLC_CONFIG(d)->play.OK)
free(OLC_CONFIG(d)->play.OK); free(OLC_CONFIG(d)->play.OK);
OLC_CONFIG(d)->play.OK = str_udup(arg); OLC_CONFIG(d)->play.OK = str_udupnl(arg);
strcat(OLC_CONFIG(d)->play.OK, "\r\n");
cedit_disp_game_play_options(d); cedit_disp_game_play_options(d);
break; break;
@ -1294,8 +1332,7 @@ void cedit_parse(struct descriptor_data *d, char *arg)
if (OLC_CONFIG(d)->play.NOPERSON) if (OLC_CONFIG(d)->play.NOPERSON)
free(OLC_CONFIG(d)->play.NOPERSON); free(OLC_CONFIG(d)->play.NOPERSON);
OLC_CONFIG(d)->play.NOPERSON = str_udup(arg); OLC_CONFIG(d)->play.NOPERSON = str_udupnl(arg);
strcat(OLC_CONFIG(d)->play.NOPERSON, "\r\n");
cedit_disp_game_play_options(d); cedit_disp_game_play_options(d);
break; break;
@ -1307,8 +1344,7 @@ void cedit_parse(struct descriptor_data *d, char *arg)
if (OLC_CONFIG(d)->play.NOEFFECT) if (OLC_CONFIG(d)->play.NOEFFECT)
free(OLC_CONFIG(d)->play.NOEFFECT); free(OLC_CONFIG(d)->play.NOEFFECT);
OLC_CONFIG(d)->play.NOEFFECT = str_udup(arg); OLC_CONFIG(d)->play.NOEFFECT = str_udupnl(arg);
strcat(OLC_CONFIG(d)->play.NOEFFECT, "\r\n");
cedit_disp_game_play_options(d); cedit_disp_game_play_options(d);
break; break;
@ -1522,6 +1558,40 @@ void cedit_parse(struct descriptor_data *d, char *arg)
} }
break; break;
case CEDIT_MAP_OPTION:
if (!*arg) {
write_to_output(d,
"That is an invalid choice!\r\n"
"Select 1, 2 or 3 (0 to cancel) :");
} else {
if ((atoi(arg) >= 1) && (atoi(arg) <= 3))
OLC_CONFIG(d)->play.map_option = (atoi(arg) - 1);
cedit_disp_game_play_options(d);
}
break;
case CEDIT_MAP_SIZE:
if (!*arg) {
/* User just pressed return - restore to default */
OLC_CONFIG(d)->play.map_size = 6;
cedit_disp_game_play_options(d);
} else {
OLC_CONFIG(d)->play.map_size = MIN(MAX((atoi(arg)), 1), 12);
cedit_disp_game_play_options(d);
}
break;
case CEDIT_MINIMAP_SIZE:
if (!*arg) {
/* User just pressed return - restore to default */
OLC_CONFIG(d)->play.minimap_size = 2;
cedit_disp_game_play_options(d);
} else {
OLC_CONFIG(d)->play.minimap_size = MIN(MAX((atoi(arg)), 1), 12);
cedit_disp_game_play_options(d);
}
break;
default: /* We should never get here, but just in case... */ default: /* We should never get here, but just in case... */
cleanup_olc(d, CLEANUP_CONFIG); cleanup_olc(d, CLEANUP_CONFIG);
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: cedit_parse(): Reached default case!"); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: cedit_parse(): Reached default case!");
@ -1530,7 +1600,7 @@ void cedit_parse(struct descriptor_data *d, char *arg)
} }
} /* End of parse_cedit() */ } /* End of parse_cedit() */
void reassign_rooms(void) static void reassign_rooms(void)
{ {
void assign_rooms(void); void assign_rooms(void);
int i; int i;

View file

@ -8,6 +8,9 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/ **************************************************************************/
/** Help buffer the global variable definitions */
#define __CLASS_C__
/* This file attempts to concentrate most of the code which must be changed /* This file attempts to concentrate most of the code which must be changed
* in order for new classes to be added. If you're adding a new class, you * in order for new classes to be added. If you're adding a new class, you
* should go through this entire file from beginning to end and add the * should go through this entire file from beginning to end and add the
@ -16,25 +19,13 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "db.h"
#include "utils.h" #include "utils.h"
#include "db.h"
#include "spells.h" #include "spells.h"
#include "interpreter.h" #include "interpreter.h"
#include "constants.h" #include "constants.h"
#include "act.h"
/* local functions */
void snoop_check(struct char_data *ch);
int parse_class(char arg);
bitvector_t find_class_bitvector(const char *arg);
byte saving_throws(int class_num, int type, int level);
int thaco(int class_num, int level);
void roll_real_abils(struct char_data *ch);
void do_start(struct char_data *ch);
int backstab_mult(int level);
int invalid_class(struct char_data *ch, struct obj_data *obj);
int level_exp(int chclass, int level);
const char *title_male(int chclass, int level);
const char *title_female(int chclass, int level);
/* Names first */ /* Names first */
const char *class_abbrevs[] = { const char *class_abbrevs[] = {
@ -135,13 +126,13 @@ int prac_params[4][NUM_CLASSES] = {
struct guild_info_type guild_info[] = { struct guild_info_type guild_info[] = {
/* Midgaard */ /* Midgaard */
{ CLASS_MAGIC_USER, 3017, SCMD_SOUTH }, { CLASS_MAGIC_USER, 3017, SOUTH },
{ CLASS_CLERIC, 3004, SCMD_NORTH }, { CLASS_CLERIC, 3004, NORTH },
{ CLASS_THIEF, 3027, SCMD_EAST }, { CLASS_THIEF, 3027, EAST },
{ CLASS_WARRIOR, 3021, SCMD_EAST }, { CLASS_WARRIOR, 3021, EAST },
/* Brass Dragon */ /* Brass Dragon */
{ -999 /* all */ , 5065, SCMD_WEST }, { -999 /* all */ , 5065, WEST },
/* this must go last -- add new guards above! */ /* this must go last -- add new guards above! */
{ -1, NOWHERE, -1} { -1, NOWHERE, -1}

View file

@ -13,6 +13,8 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
/* Begin conf.h dependent includes */
#if CIRCLE_GNU_LIBC_MEMORY_TRACK #if CIRCLE_GNU_LIBC_MEMORY_TRACK
# include <mcheck.h> # include <mcheck.h>
#endif #endif
@ -47,6 +49,14 @@
# include <sys/ioctl.h> # include <sys/ioctl.h>
#endif #endif
#ifdef HAVE_ARPA_TELNET_H
#include <arpa/telnet.h>
#else
#include "telnet.h"
#endif
/* end conf.h dependent includes */
/* Note, most includes for all platforms are in sysdep.h. The list of /* Note, most includes for all platforms are in sysdep.h. The list of
* files that is included is controlled by conf.h for that platform. */ * files that is included is controlled by conf.h for that platform. */
@ -61,121 +71,95 @@
#include "genolc.h" #include "genolc.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "dg_event.h" #include "dg_event.h"
#include "screen.h" /* to support the gemote act type command */
#ifdef HAVE_ARPA_TELNET_H #include "constants.h" /* For mud versions */
#include <arpa/telnet.h> #include "boards.h"
#else #include "act.h"
#include "telnet.h" #include "ban.h"
#endif #include "fight.h"
#include "spells.h" /* for affect_update */
#include "modify.h"
#include "quest.h"
#ifndef INVALID_SOCKET #ifndef INVALID_SOCKET
#define INVALID_SOCKET (-1) #define INVALID_SOCKET (-1)
#endif #endif
/* externs */ /* locally defined globals, used externally */
extern struct ban_list_element *ban_list; struct descriptor_data *descriptor_list = NULL; /* master desc list */
extern int num_invalid; int buf_largecount = 0; /* # of large buffers which exist */
extern char *GREETINGS; int buf_overflows = 0; /* # of overflows of output */
extern const char *tbamud_version; int buf_switches = 0; /* # of switches from small to large buf */
extern const char *oasisolc_version; int circle_shutdown = 0; /* clean shutdown */
extern const char *ascii_pfiles_version; int circle_reboot = 0; /* reboot the game after a shutdown */
extern int circle_restrict; int no_specials = 0; /* Suppress ass. of special routines */
extern int mini_mud; int scheck = 0; /* for syntax checking mode */
extern int no_rent_check; FILE *logfile = NULL; /* Where to send the log messages. */
extern int *cmd_sort_info; unsigned long pulse = 0; /* number of pulses since game start */
extern struct time_info_data time_info; /* In db.c */
extern char *help;
/* local globals */
struct descriptor_data *descriptor_list = NULL; /* master desc list */
struct txt_block *bufpool = 0; /* pool of large output buffers */
int buf_largecount = 0; /* # of large buffers which exist */
int buf_overflows = 0; /* # of overflows of output */
int buf_switches = 0; /* # of switches from small to large buf */
int circle_shutdown = 0; /* clean shutdown */
int circle_reboot = 0; /* reboot the game after a shutdown */
int no_specials = 0; /* Suppress ass. of special routines */
int max_players = 0; /* max descriptors available */
int tics_passed = 0; /* for extern checkpointing */
int scheck = 0; /* for syntax checking mode */
struct timeval null_time; /* zero-valued time structure */
byte reread_wizlist; /* signal: SIGUSR1 */
byte emergency_unban; /* signal: SIGUSR2 */
FILE *logfile = NULL; /* Where to send the log messages. */
int dg_act_check; /* toggle for act_trigger */
unsigned long pulse = 0; /* number of pulses since game start */
static bool fCopyOver; /* Are we booting in copyover mode? */
ush_int port; ush_int port;
socket_t mother_desc; socket_t mother_desc;
int log_this_messg; /* used with do_tell and handle_webster_file utility */
char *last_act_message = NULL; long last_webster_teller = -1L;
/* local functions */ /* static local global variable declarations (current file scope only) */
RETSIGTYPE reread_wizlists(int sig); static struct txt_block *bufpool = 0; /* pool of large output buffers */
RETSIGTYPE unrestrict_game(int sig); static int max_players = 0; /* max descriptors available */
RETSIGTYPE reap(int sig); static int tics_passed = 0; /* for extern checkpointing */
RETSIGTYPE checkpointing(int sig); static struct timeval null_time; /* zero-valued time structure */
RETSIGTYPE hupsig(int sig); static byte reread_wizlist; /* signal: SIGUSR1 */
ssize_t perform_socket_read(socket_t desc, char *read_point,size_t space_left); /* normally signal SIGUSR2, currently orphaned in favor of Webster dictionary
ssize_t perform_socket_write(socket_t desc, const char *txt,size_t length); * lookup
void echo_off(struct descriptor_data *d); static byte emergency_unban;
void echo_on(struct descriptor_data *d); */
void circle_sleep(struct timeval *timeout); static int dg_act_check; /* toggle for act_trigger */
int get_from_q(struct txt_q *queue, char *dest, int *aliased); static bool fCopyOver; /* Are we booting in copyover mode? */
void init_game(ush_int port); static char *last_act_message = NULL;
void signal_setup(void); static byte webster_file_ready = FALSE;/* signal: SIGUSR2 */
void game_loop(socket_t mother_desc);
socket_t init_socket(ush_int port);
int new_descriptor(socket_t s);
int get_max_players(void);
int process_output(struct descriptor_data *t);
int process_input(struct descriptor_data *t);
void timediff(struct timeval *diff, struct timeval *a, struct timeval *b);
void timeadd(struct timeval *sum, struct timeval *a, struct timeval *b);
void flush_queues(struct descriptor_data *d);
void nonblock(socket_t s);
int perform_subst(struct descriptor_data *t, char *orig, char *subst);
void record_usage(void);
char *make_prompt(struct descriptor_data *point);
void check_idle_passwords(void);
void heartbeat(int heart_pulse);
void init_descriptor (struct descriptor_data *newd, int desc);
struct in_addr *get_bind_addr(void); /* static local function prototypes (current file scope only) */
int parse_ip(const char *addr, struct in_addr *inaddr); static RETSIGTYPE reread_wizlists(int sig);
int set_sendbuf(socket_t s); /* Appears to be orphaned right now...
void free_bufpool(void); static RETSIGTYPE unrestrict_game(int sig);
void setup_log(const char *filename, int fd); */
int open_logfile(const char *filename, FILE *stderr_fp); static RETSIGTYPE reap(int sig);
static RETSIGTYPE checkpointing(int sig);
static RETSIGTYPE hupsig(int sig);
static ssize_t perform_socket_read(socket_t desc, char *read_point,size_t space_left);
static ssize_t perform_socket_write(socket_t desc, const char *txt,size_t length);
static void circle_sleep(struct timeval *timeout);
static int get_from_q(struct txt_q *queue, char *dest, int *aliased);
static void init_game(ush_int port);
static void signal_setup(void);
static socket_t init_socket(ush_int port);
static int new_descriptor(socket_t s);
static int get_max_players(void);
static int process_output(struct descriptor_data *t);
static int process_input(struct descriptor_data *t);
static void timediff(struct timeval *diff, struct timeval *a, struct timeval *b);
static void timeadd(struct timeval *sum, struct timeval *a, struct timeval *b);
static void flush_queues(struct descriptor_data *d);
static void nonblock(socket_t s);
static int perform_subst(struct descriptor_data *t, char *orig, char *subst);
static void record_usage(void);
static char *make_prompt(struct descriptor_data *point);
static void check_idle_passwords(void);
static void init_descriptor (struct descriptor_data *newd, int desc);
static struct in_addr *get_bind_addr(void);
static int parse_ip(const char *addr, struct in_addr *inaddr);
static int set_sendbuf(socket_t s);
static void free_bufpool(void);
static void setup_log(const char *filename, int fd);
static int open_logfile(const char *filename, FILE *stderr_fp);
#if defined(POSIX) #if defined(POSIX)
sigfunc *my_signal(int signo, sigfunc *func); static sigfunc *my_signal(int signo, sigfunc *func);
#endif #endif
/* Webster Dictionary Lookup functions */
static RETSIGTYPE websterlink(int sig);
static size_t proc_colors(char *txt, size_t maxlen, int parse);
static void handle_webster_file();
byte webster_file_ready = FALSE;/* signal: SIGUSR2 */ /* externally defined functions, used locally */
RETSIGTYPE websterlink(int sig);
extern void handle_webster_file();
void copyover_recover(void);
size_t proc_colors(char *txt, size_t maxlen, int parse);
/* extern functions */
void reboot_wizlists(void);
void boot_world(void);
void affect_update(void); /* In magic.c */
void mobile_activity(void);
void perform_violence(void);
void show_string(struct descriptor_data *d, char *input);
int isbanned(char *hostname);
void weather_and_time(int mode);
int perform_alias(struct descriptor_data *d, char *orig, size_t maxlen);
void free_messages(void);
void board_clear_all(void);
void free_social_messages(void);
void free_invalid_list(void);
void free_command_list(void);
void free_save_list(void);
void load_config(void);
void new_hist_messg(struct descriptor_data *d, const char *msg);
#ifdef __CXREF__ #ifdef __CXREF__
#undef FD_ZERO #undef FD_ZERO
#undef FD_SET #undef FD_SET
@ -369,17 +353,17 @@ int main(int argc, char **argv)
if (!scheck) { if (!scheck) {
log("Clearing other memory."); log("Clearing other memory.");
free_bufpool(); /* comm.c */ free_bufpool(); /* comm.c */
free_player_index(); /* players.c */ free_player_index(); /* players.c */
free_messages(); /* fight.c */ free_messages(); /* fight.c */
free_text_files(); /* db.c */ free_text_files(); /* db.c */
board_clear_all(); /* boards.c */ board_clear_all(); /* boards.c */
free(cmd_sort_info); /* act.informative.c */ free(cmd_sort_info); /* act.informative.c */
free_command_list(); /* act.informative.c */ free_command_list(); /* act.informative.c */
free_social_messages(); /* act.social.c */ free_social_messages(); /* act.social.c */
free_help_table(); /* db.c */ free_help_table(); /* db.c */
free_invalid_list(); /* ban.c */ free_invalid_list(); /* ban.c */
free_save_list(); /* genolc.c */ free_save_list(); /* genolc.c */
free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */ free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */
} }
@ -398,9 +382,6 @@ int main(int argc, char **argv)
return (0); return (0);
} }
int enter_player_game(struct descriptor_data *d);
extern time_t boot_time;
/* Reload players after a copyover */ /* Reload players after a copyover */
void copyover_recover() void copyover_recover()
{ {
@ -426,7 +407,7 @@ void copyover_recover()
unlink (COPYOVER_FILE); unlink (COPYOVER_FILE);
/* read boot_time - first line in file */ /* read boot_time - first line in file */
fscanf(fp, "%ld\n", &boot_time); fscanf(fp, "%ld\n", (long *)&boot_time);
for (;;) { for (;;) {
fOld = TRUE; fOld = TRUE;
@ -484,7 +465,7 @@ void copyover_recover()
} }
/* Init sockets, run game, and cleanup sockets */ /* Init sockets, run game, and cleanup sockets */
void init_game(ush_int port) static void init_game(ush_int port)
{ {
/* We don't want to restart if we crash before we get up. */ /* We don't want to restart if we crash before we get up. */
touch(KILLSCRIPT_FILE); touch(KILLSCRIPT_FILE);
@ -545,7 +526,7 @@ void init_game(ush_int port)
/* init_socket sets up the mother descriptor - creates the socket, sets /* init_socket sets up the mother descriptor - creates the socket, sets
* its options up, binds it, and listens. */ * its options up, binds it, and listens. */
socket_t init_socket(ush_int port) static socket_t init_socket(ush_int port)
{ {
socket_t s; socket_t s;
struct sockaddr_in sa; struct sockaddr_in sa;
@ -633,7 +614,7 @@ socket_t init_socket(ush_int port)
return (s); return (s);
} }
int get_max_players(void) static int get_max_players(void)
{ {
#ifndef CIRCLE_UNIX #ifndef CIRCLE_UNIX
return (CONFIG_MAX_PLAYING); return (CONFIG_MAX_PLAYING);
@ -929,6 +910,7 @@ void game_loop(socket_t mother_desc)
mudlog(CMP, LVL_IMMORT, TRUE, "Signal received - rereading wizlists."); mudlog(CMP, LVL_IMMORT, TRUE, "Signal received - rereading wizlists.");
reboot_wizlists(); reboot_wizlists();
} }
/* Orphaned right now as signal trapping is used for Webster lookup
if (emergency_unban) { if (emergency_unban) {
emergency_unban = FALSE; emergency_unban = FALSE;
mudlog(BRF, LVL_IMMORT, TRUE, "Received SIGUSR2 - completely unrestricting game (emergent)"); mudlog(BRF, LVL_IMMORT, TRUE, "Received SIGUSR2 - completely unrestricting game (emergent)");
@ -936,6 +918,7 @@ void game_loop(socket_t mother_desc)
circle_restrict = 0; circle_restrict = 0;
num_invalid = 0; num_invalid = 0;
} }
*/
if (webster_file_ready) { if (webster_file_ready) {
webster_file_ready = FALSE; webster_file_ready = FALSE;
handle_webster_file(); handle_webster_file();
@ -969,11 +952,12 @@ void heartbeat(int heart_pulse)
if (!(heart_pulse % PULSE_VIOLENCE)) if (!(heart_pulse % PULSE_VIOLENCE))
perform_violence(); perform_violence();
if (!(heart_pulse % (SECS_PER_MUD_HOUR * PASSES_PER_SEC))) { if (!(heart_pulse % (SECS_PER_MUD_HOUR * PASSES_PER_SEC))) { /* Tick ! */
weather_and_time(1); weather_and_time(1);
check_time_triggers(); check_time_triggers();
affect_update(); affect_update();
point_update(); point_update();
check_timed_quests();
} }
if (CONFIG_AUTO_SAVE && !(heart_pulse % PULSE_AUTOSAVE)) { /* 1 minute */ if (CONFIG_AUTO_SAVE && !(heart_pulse % PULSE_AUTOSAVE)) { /* 1 minute */
@ -999,7 +983,7 @@ void heartbeat(int heart_pulse)
* Based on code submitted by ss@sirocco.cup.hp.com. Code to return the time * Based on code submitted by ss@sirocco.cup.hp.com. Code to return the time
* difference between a and b (a-b). Always returns a nonnegative value * difference between a and b (a-b). Always returns a nonnegative value
* (floors at 0). */ * (floors at 0). */
void timediff(struct timeval *rslt, struct timeval *a, struct timeval *b) static void timediff(struct timeval *rslt, struct timeval *a, struct timeval *b)
{ {
if (a->tv_sec < b->tv_sec) if (a->tv_sec < b->tv_sec)
*rslt = null_time; *rslt = null_time;
@ -1021,7 +1005,7 @@ void timediff(struct timeval *rslt, struct timeval *a, struct timeval *b)
} }
/* Add 2 time values. Patch sent by "d. hall" to fix 'static' usage. */ /* Add 2 time values. Patch sent by "d. hall" to fix 'static' usage. */
void timeadd(struct timeval *rslt, struct timeval *a, struct timeval *b) static void timeadd(struct timeval *rslt, struct timeval *a, struct timeval *b)
{ {
rslt->tv_sec = a->tv_sec + b->tv_sec; rslt->tv_sec = a->tv_sec + b->tv_sec;
rslt->tv_usec = a->tv_usec + b->tv_usec; rslt->tv_usec = a->tv_usec + b->tv_usec;
@ -1032,7 +1016,7 @@ void timeadd(struct timeval *rslt, struct timeval *a, struct timeval *b)
} }
} }
void record_usage(void) static void record_usage(void)
{ {
int sockets_connected = 0, sockets_playing = 0; int sockets_connected = 0, sockets_playing = 0;
struct descriptor_data *d; struct descriptor_data *d;
@ -1097,7 +1081,7 @@ const char *ANSI[] = { "@", A"0m",A"0m",A"0;30m",A"0;34m",A"0;32m",A"0;36m",A"0;
#undef A #undef A
const char CCODE[] = "@nNdbgcrmywDBGCRMYW01234567luoe!"; const char CCODE[] = "@nNdbgcrmywDBGCRMYW01234567luoe!";
size_t proc_colors(char *txt, size_t maxlen, int parse) static size_t proc_colors(char *txt, size_t maxlen, int parse)
{ {
char *d, *s, *c, *p; char *d, *s, *c, *p;
int i; int i;
@ -1158,7 +1142,7 @@ size_t proc_colors(char *txt, size_t maxlen, int parse)
return strlen(txt); return strlen(txt);
} }
char *make_prompt(struct descriptor_data *d) static char *make_prompt(struct descriptor_data *d)
{ {
static char prompt[MAX_PROMPT_LENGTH]; static char prompt[MAX_PROMPT_LENGTH];
@ -1262,7 +1246,7 @@ void write_to_q(const char *txt, struct txt_q *queue, int aliased)
} }
/* NOTE: 'dest' must be at least MAX_INPUT_LENGTH big. */ /* NOTE: 'dest' must be at least MAX_INPUT_LENGTH big. */
int get_from_q(struct txt_q *queue, char *dest, int *aliased) static int get_from_q(struct txt_q *queue, char *dest, int *aliased)
{ {
struct txt_block *tmp; struct txt_block *tmp;
@ -1282,7 +1266,7 @@ int get_from_q(struct txt_q *queue, char *dest, int *aliased)
} }
/* Empty the queues before closing connection */ /* Empty the queues before closing connection */
void flush_queues(struct descriptor_data *d) static void flush_queues(struct descriptor_data *d)
{ {
if (d->large_outbuf) { if (d->large_outbuf) {
d->large_outbuf->next = bufpool; d->large_outbuf->next = bufpool;
@ -1373,7 +1357,7 @@ size_t vwrite_to_output(struct descriptor_data *t, const char *format, va_list a
return (t->bufspace); return (t->bufspace);
} }
void free_bufpool(void) static void free_bufpool(void)
{ {
struct txt_block *tmp; struct txt_block *tmp;
@ -1392,7 +1376,7 @@ void free_bufpool(void)
* address, we try to bind to it; otherwise, we bind to INADDR_ANY. * address, we try to bind to it; otherwise, we bind to INADDR_ANY.
* Note that inet_aton() is preferred over inet_addr() so we use it if * Note that inet_aton() is preferred over inet_addr() so we use it if
* we can. If neither is available, we always bind to INADDR_ANY. */ * we can. If neither is available, we always bind to INADDR_ANY. */
struct in_addr *get_bind_addr() static struct in_addr *get_bind_addr()
{ {
static struct in_addr bind_addr; static struct in_addr bind_addr;
@ -1423,7 +1407,7 @@ struct in_addr *get_bind_addr()
#ifdef HAVE_INET_ATON #ifdef HAVE_INET_ATON
/* inet_aton's interface is the same as parse_ip's: 0 on failure, non-0 if /* inet_aton's interface is the same as parse_ip's: 0 on failure, non-0 if
* successful. */ * successful. */
int parse_ip(const char *addr, struct in_addr *inaddr) static int parse_ip(const char *addr, struct in_addr *inaddr)
{ {
return (inet_aton(addr, inaddr)); return (inet_aton(addr, inaddr));
} }
@ -1454,7 +1438,7 @@ int parse_ip(const char *addr, struct in_addr *inaddr)
#endif /* INET_ATON and INET_ADDR */ #endif /* INET_ATON and INET_ADDR */
/* Sets the kernel's send buffer size for the descriptor */ /* Sets the kernel's send buffer size for the descriptor */
int set_sendbuf(socket_t s) static int set_sendbuf(socket_t s)
{ {
#if defined(SO_SNDBUF) && !defined(CIRCLE_MACINTOSH) #if defined(SO_SNDBUF) && !defined(CIRCLE_MACINTOSH)
int opt = MAX_SOCK_BUF; int opt = MAX_SOCK_BUF;
@ -1469,7 +1453,7 @@ int set_sendbuf(socket_t s)
} }
/* Initialize a descriptor */ /* Initialize a descriptor */
void init_descriptor (struct descriptor_data *newd, int desc) static void init_descriptor (struct descriptor_data *newd, int desc)
{ {
static int last_desc = 0; /* last descriptor number */ static int last_desc = 0; /* last descriptor number */
@ -1488,7 +1472,7 @@ void init_descriptor (struct descriptor_data *newd, int desc)
newd->desc_num = last_desc; newd->desc_num = last_desc;
} }
int new_descriptor(socket_t s) static int new_descriptor(socket_t s)
{ {
socket_t desc; socket_t desc;
int sockets_connected = 0; int sockets_connected = 0;
@ -1496,6 +1480,7 @@ int new_descriptor(socket_t s)
struct descriptor_data *newd; struct descriptor_data *newd;
struct sockaddr_in peer; struct sockaddr_in peer;
struct hostent *from; struct hostent *from;
char greet_copy[MAX_STRING_LENGTH];
/* accept the new connection */ /* accept the new connection */
i = sizeof(peer); i = sizeof(peer);
@ -1556,7 +1541,12 @@ int new_descriptor(socket_t s)
newd->next = descriptor_list; newd->next = descriptor_list;
descriptor_list = newd; descriptor_list = newd;
write_to_output(newd, "%s", GREETINGS); /* This is where the greetings are actually sent to the new player */
/* Adjusted by Jamdog to show color codes on the greetings page */
*greet_copy = '\0';
sprintf(greet_copy, "%s", GREETINGS);
proc_colors(greet_copy, MAX_STRING_LENGTH, TRUE);
write_to_output(newd, "%s", greet_copy);
return (0); return (0);
} }
@ -1567,7 +1557,7 @@ int new_descriptor(socket_t s)
* 14 bytes: overflow message * 14 bytes: overflow message
* 2 bytes: extra \r\n for non-comapct * 2 bytes: extra \r\n for non-comapct
* 14 bytes: unused */ * 14 bytes: unused */
int process_output(struct descriptor_data *t) static int process_output(struct descriptor_data *t)
{ {
char i[MAX_SOCK_BUF], *osb = i + 2; char i[MAX_SOCK_BUF], *osb = i + 2;
int result; int result;
@ -1691,7 +1681,7 @@ ssize_t perform_socket_write(socket_t desc, const char *txt, size_t length)
#endif #endif
/* perform_socket_write for all Non-Windows platforms */ /* perform_socket_write for all Non-Windows platforms */
ssize_t perform_socket_write(socket_t desc, const char *txt, size_t length) static ssize_t perform_socket_write(socket_t desc, const char *txt, size_t length)
{ {
ssize_t result; ssize_t result;
@ -1763,7 +1753,7 @@ int write_to_descriptor(socket_t desc, const char *txt)
/* Same information about perform_socket_write applies here. I like /* Same information about perform_socket_write applies here. I like
* standards, there are so many of them. -gg 6/30/98 */ * standards, there are so many of them. -gg 6/30/98 */
ssize_t perform_socket_read(socket_t desc, char *read_point, size_t space_left) static ssize_t perform_socket_read(socket_t desc, char *read_point, size_t space_left)
{ {
ssize_t ret; ssize_t ret;
@ -1834,7 +1824,7 @@ ssize_t perform_socket_read(socket_t desc, char *read_point, size_t space_left)
* above, 'tmp' lost the '+8' since it doesn't need it and the code has been * above, 'tmp' lost the '+8' since it doesn't need it and the code has been
* changed to reserve space by accepting one less character. (Do you really * changed to reserve space by accepting one less character. (Do you really
* need 256 characters on a line?) -gg 1/21/2000 */ * need 256 characters on a line?) -gg 1/21/2000 */
int process_input(struct descriptor_data *t) static int process_input(struct descriptor_data *t)
{ {
int buf_length, failed_subst; int buf_length, failed_subst;
ssize_t bytes_read; ssize_t bytes_read;
@ -1985,7 +1975,7 @@ int process_input(struct descriptor_data *t)
/* Perform substitution for the '^..^' csh-esque syntax orig is the orig string, /* Perform substitution for the '^..^' csh-esque syntax orig is the orig string,
* i.e. the one being modified. subst contains the substition string, i.e. * i.e. the one being modified. subst contains the substition string, i.e.
* "^telm^tell" */ * "^telm^tell" */
int perform_subst(struct descriptor_data *t, char *orig, char *subst) static int perform_subst(struct descriptor_data *t, char *orig, char *subst)
{ {
char newsub[MAX_INPUT_LENGTH + 5]; char newsub[MAX_INPUT_LENGTH + 5];
@ -2115,7 +2105,7 @@ void close_socket(struct descriptor_data *d)
free(d); free(d);
} }
void check_idle_passwords(void) static void check_idle_passwords(void)
{ {
struct descriptor_data *d, *next_d; struct descriptor_data *d, *next_d;
@ -2182,7 +2172,7 @@ void nonblock(socket_t s)
#define O_NONBLOCK O_NDELAY #define O_NONBLOCK O_NDELAY
#endif #endif
void nonblock(socket_t s) static void nonblock(socket_t s)
{ {
int flags; int flags;
@ -2198,25 +2188,28 @@ void nonblock(socket_t s)
/* signal-handling functions (formerly signals.c). UNIX only. */ /* signal-handling functions (formerly signals.c). UNIX only. */
#if defined(CIRCLE_UNIX) || defined(CIRCLE_MACINTOSH) #if defined(CIRCLE_UNIX) || defined(CIRCLE_MACINTOSH)
RETSIGTYPE reread_wizlists(int sig) static RETSIGTYPE reread_wizlists(int sig)
{ {
reread_wizlist = TRUE; reread_wizlist = TRUE;
} }
RETSIGTYPE unrestrict_game(int sig) /* Orphaned right now in place of Webster ...
static RETSIGTYPE unrestrict_game(int sig)
{ {
emergency_unban = TRUE; emergency_unban = TRUE;
} }
*/
RETSIGTYPE websterlink(int sig) static RETSIGTYPE websterlink(int sig)
{ {
webster_file_ready = TRUE; webster_file_ready = TRUE;
} }
#ifdef CIRCLE_UNIX #ifdef CIRCLE_UNIX
/* clean up our zombie kids to avoid defunct processes */ /* clean up our zombie kids to avoid defunct processes */
RETSIGTYPE reap(int sig) static RETSIGTYPE reap(int sig)
{ {
while (waitpid(-1, NULL, WNOHANG) > 0); while (waitpid(-1, NULL, WNOHANG) > 0);
@ -2224,7 +2217,7 @@ RETSIGTYPE reap(int sig)
} }
/* Dying anyway... */ /* Dying anyway... */
RETSIGTYPE checkpointing(int sig) static RETSIGTYPE checkpointing(int sig)
{ {
#ifndef MEMORY_DEBUG #ifndef MEMORY_DEBUG
if (!tics_passed) { if (!tics_passed) {
@ -2236,7 +2229,7 @@ RETSIGTYPE checkpointing(int sig)
} }
/* Dying anyway... */ /* Dying anyway... */
RETSIGTYPE hupsig(int sig) static RETSIGTYPE hupsig(int sig)
{ {
log("SYSERR: Received SIGHUP, SIGINT, or SIGTERM. Shutting down..."); log("SYSERR: Received SIGHUP, SIGINT, or SIGTERM. Shutting down...");
exit(1); /* perhaps something more elegant should substituted */ exit(1); /* perhaps something more elegant should substituted */
@ -2257,7 +2250,7 @@ RETSIGTYPE hupsig(int sig)
#ifndef POSIX #ifndef POSIX
#define my_signal(signo, func) signal(signo, func) #define my_signal(signo, func) signal(signo, func)
#else #else
sigfunc *my_signal(int signo, sigfunc *func) static sigfunc *my_signal(int signo, sigfunc *func)
{ {
struct sigaction sact, oact; struct sigaction sact, oact;
@ -2275,7 +2268,7 @@ sigfunc *my_signal(int signo, sigfunc *func)
} }
#endif /* POSIX */ #endif /* POSIX */
void signal_setup(void) static void signal_setup(void)
{ {
#ifndef CIRCLE_MACINTOSH #ifndef CIRCLE_MACINTOSH
struct itimerval itime; struct itimerval itime;
@ -2582,7 +2575,6 @@ char *act(const char *str, int hide_invisible, struct char_data *ch,
return NULL; return NULL;
} }
#include "screen.h"
if (type == TO_GMOTE && !IS_NPC(ch)) { if (type == TO_GMOTE && !IS_NPC(ch)) {
struct descriptor_data *i; struct descriptor_data *i;
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
@ -2623,7 +2615,7 @@ char *act(const char *str, int hide_invisible, struct char_data *ch,
} }
/* Prefer the file over the descriptor. */ /* Prefer the file over the descriptor. */
void setup_log(const char *filename, int fd) static void setup_log(const char *filename, int fd)
{ {
FILE *s_fp; FILE *s_fp;
@ -2667,7 +2659,7 @@ void setup_log(const char *filename, int fd)
exit(1); exit(1);
} }
int open_logfile(const char *filename, FILE *stderr_fp) static int open_logfile(const char *filename, FILE *stderr_fp)
{ {
if (stderr_fp) /* freopen() the descriptor. */ if (stderr_fp) /* freopen() the descriptor. */
logfile = freopen(filename, "w", stderr_fp); logfile = freopen(filename, "w", stderr_fp);
@ -2692,7 +2684,7 @@ void circle_sleep(struct timeval *timeout)
} }
#else #else
void circle_sleep(struct timeval *timeout) static void circle_sleep(struct timeval *timeout)
{ {
if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, timeout) < 0) { if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, timeout) < 0) {
if (errno != EINTR) { if (errno != EINTR) {
@ -2703,3 +2695,41 @@ void circle_sleep(struct timeval *timeout)
} }
#endif /* CIRCLE_WINDOWS */ #endif /* CIRCLE_WINDOWS */
static void handle_webster_file(void) {
FILE *fl;
struct char_data *ch = find_char(last_webster_teller);
char info[MAX_STRING_LENGTH], line[READ_SIZE];
size_t len = 0, nlen = 0;
last_webster_teller = -1L;
if (!ch) /* they quit ? */
return;
fl = fopen("websterinfo", "r");
if (!fl) {
send_to_char(ch, "It seems Merriam-Webster is offline..\r\n");
return;
}
unlink("websterinfo");
get_line(fl, line);
while (!feof(fl)) {
nlen = snprintf(info + len, sizeof(info) - len, "%s\r\n", line);
if (len + nlen >= sizeof(info) || nlen < 0)
break;
len += nlen;
get_line(fl, line);
}
if (len >= sizeof(info)) {
const char *overflow = "\r\n**OVERFLOW**\r\n";
strcpy(info + sizeof(info) - strlen(overflow) - 1, overflow); /* strcpy: OK */
}
fclose(fl);
send_to_char(ch, "You get this feedback from Merriam-Webster:\r\n");
page_string(ch->desc, info, 1);
}

View file

@ -1,17 +1,23 @@
/************************************************************************** /**
* File: comm.h Part of tbaMUD * * @file comm.h
* Usage: Header file, prototypes of public communication functions. * * Header file, prototypes of public communication functions.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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 _COMM_H_
#define _COMM_H_
#define NUM_RESERVED_DESCS 8 #define NUM_RESERVED_DESCS 8
#define COPYOVER_FILE "copyover.dat" #define COPYOVER_FILE "copyover.dat"
/* comm.c */ /* comm.c */
void close_socket(struct descriptor_data *d);
size_t send_to_char(struct char_data *ch, const char *messg, ...) __attribute__ size_t send_to_char(struct char_data *ch, const char *messg, ...) __attribute__
((format (printf, 2, 3))); ((format (printf, 2, 3)));
void send_to_all(const char *messg, ...) __attribute__ ((format (printf, 1, void send_to_all(const char *messg, ...) __attribute__ ((format (printf, 1,
@ -23,29 +29,53 @@ void send_to_outdoor(const char *messg, ...) __attribute__ ((format (printf, 1,
void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...) void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...)
__attribute__ ((format (printf, 3, 4))); __attribute__ ((format (printf, 3, 4)));
void close_socket(struct descriptor_data *d); /* Act type settings and flags */
#define TO_ROOM 1 /**< act() type: to everyone in room, except ch. */
#define TO_VICT 2 /**< act() type: to vict_obj. */
#define TO_NOTVICT 3 /**< act() type: to everyone in room, not ch or vict_obj. */
#define TO_CHAR 4 /**< act() type: to ch. */
#define TO_GMOTE 5 /**< act() type: to gemote channel (global emote) */
#define TO_SLEEP 128 /**< act() flag: to char, even if sleeping */
#define DG_NO_TRIG 256 /**< act() flag: don't check act trigger */
/* act functions */
void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj, const void *vict_obj, const struct char_data *to); void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj, const void *vict_obj, const struct char_data *to);
char * act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, const void *vict_obj, int type); char * act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, const void *vict_obj, int type);
#define TO_ROOM 1
#define TO_VICT 2
#define TO_NOTVICT 3
#define TO_CHAR 4
#define TO_GMOTE 5
#define TO_SLEEP 128 /* to char, even if sleeping */
#define DG_NO_TRIG 256 /* don't check act trigger */
/* I/O functions */ /* I/O functions */
void write_to_q(const char *txt, struct txt_q *queue, int aliased); void write_to_q(const char *txt, struct txt_q *queue, int aliased);
int write_to_descriptor(socket_t desc, const char *txt); int write_to_descriptor(socket_t desc, const char *txt);
size_t write_to_output(struct descriptor_data *d, const char *txt, ...) __attribute__ ((format (printf, 2, 3))); size_t write_to_output(struct descriptor_data *d, const char *txt, ...) __attribute__ ((format (printf, 2, 3)));
size_t vwrite_to_output(struct descriptor_data *d, const char *format, va_list args); size_t vwrite_to_output(struct descriptor_data *d, const char *format, va_list args);
void string_add(struct descriptor_data *d, char *str);
void string_write(struct descriptor_data *d, char **txt, size_t len, long mailto, void *data);
#define PAGE_LENGTH 22
#define PAGE_WIDTH 80
void page_string(struct descriptor_data *d, char *str, int keep_internal);
typedef RETSIGTYPE sigfunc(int); typedef RETSIGTYPE sigfunc(int);
void echo_off(struct descriptor_data *d);
void echo_on(struct descriptor_data *d);
void game_loop(socket_t mother_desc);
void heartbeat(int heart_pulse);
void copyover_recover(void);
/* global buffering system - allow access to global variables within comm.c */
#ifndef __COMM_C__
/** webster dictionary lookup */
extern long last_webster_teller;
extern struct descriptor_data *descriptor_list;
extern int buf_largecount;
extern int buf_overflows;
extern int buf_switches;
extern int circle_shutdown;
extern int circle_reboot;
extern int no_specials;
extern int scheck;
extern FILE *logfile;
extern unsigned long pulse;
extern ush_int port;
extern socket_t mother_desc;
#endif /* __COMM_C__ */
#endif /* _COMM_H_ */

View file

@ -2,6 +2,9 @@
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */ /* src/conf.h.in. Generated automatically from configure.in by autoheader. */
#ifndef _CONF_H_
#define _CONF_H_
#undef CIRCLE_WINDOWS #undef CIRCLE_WINDOWS
#define AMIGA 1 #define AMIGA 1
@ -102,3 +105,4 @@
/* Define if your compiler does not prototype strerror(). */ /* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */ /* #undef NEED_STRERROR_PROTO */
#endif /* _CONF_H_ */

View file

@ -1,5 +1,8 @@
/* CircleMUD for ACORN conf.h file - manually created (G. Duncan 13 June 98) /* CircleMUD for ACORN conf.h file - manually created (G. Duncan 13 June 98)
#ifndef _CONF_H_
#define _CONF_H_
#define CIRCLE_ACORN #define CIRCLE_ACORN
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
@ -76,3 +79,4 @@
/* Define if your compiler does not prototype strerror(). */ /* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */ /* #undef NEED_STRERROR_PROTO */
#endif /* _CONF_H_ */

View file

@ -1,5 +1,8 @@
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */ /* src/conf.h.in. Generated automatically from configure.in by autoheader. */
#ifndef _CONF_H_
#define _CONF_H_
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
#undef const #undef const
@ -330,3 +333,5 @@
/* Check for a prototype to write. */ /* Check for a prototype to write. */
#undef NEED_WRITE_PROTO #undef NEED_WRITE_PROTO
#endif /* _CONF_H_ */

View file

@ -1,5 +1,8 @@
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */ /* src/conf.h.in. Generated automatically from configure.in by autoheader. */
#ifndef _CONF_H_
#define _CONF_H_
#define CIRCLE_MACINTOSH 1 #define CIRCLE_MACINTOSH 1
#define HAVE_SYS_ERRNO_H 1 #define HAVE_SYS_ERRNO_H 1
@ -253,3 +256,4 @@
/* Define if your crypt isn't safe with only 10 characters. */ /* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT #undef HAVE_UNSAFE_CRYPT
#endif /* _CONF_H_ */

View file

@ -1,5 +1,8 @@
/* src/conf.h.os2. Manually written by David Carver. */ /* src/conf.h.os2. Manually written by David Carver. */
#ifndef _CONF_H_
#define _CONF_H_
/* Define if we are compiling under OS2 */ /* Define if we are compiling under OS2 */
#define CIRCLE_OS2 #define CIRCLE_OS2
@ -102,3 +105,4 @@
/* Define if your crypt isn't safe with only 10 characters. */ /* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT #undef HAVE_UNSAFE_CRYPT
#endif /* _CONF_H_ */

View file

@ -1,5 +1,8 @@
/* src/conf.h.in. Generated automatically from cnf/configure.in by autoheader. */ /* src/conf.h.in. Generated automatically from cnf/configure.in by autoheader. */
#ifndef _CONF_H_
#define _CONF_H_
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
/* #undef const */ /* #undef const */
@ -293,3 +296,5 @@
/* Define if your compiler does not prototype write(). */ /* Define if your compiler does not prototype write(). */
/* #undef NEED_WRITE_PROTO */ /* #undef NEED_WRITE_PROTO */
#endif /* _CONF_H_ */

View file

@ -3,6 +3,9 @@
* Created by Jeremy Elson, 1 July 1998 * Created by Jeremy Elson, 1 July 1998
*/ */
#ifndef _CONF_H_
#define _CONF_H_
#define CIRCLE_WINDOWS #define CIRCLE_WINDOWS
/* Define to empty if the keyword does not work. */ /* Define to empty if the keyword does not work. */
@ -334,3 +337,5 @@
/* Check for a prototype to write. */ /* Check for a prototype to write. */
#undef NEED_WRITE_PROTO #undef NEED_WRITE_PROTO
#endif /* _CONF_H_ */

View file

@ -13,7 +13,10 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "interpreter.h" /* alias_data definition for structs.h */ #include "interpreter.h" /* alias_data definition for structs.h */
#include "config.h"
#include "asciimap.h"
/* Update: The following constants and variables are now the default values /* Update: The following constants and variables are now the default values
* for backwards compatibility with the new cedit game configurator. If you * for backwards compatibility with the new cedit game configurator. If you
@ -33,22 +36,7 @@
* I've decided the convenience of having all your options in this one file * I've decided the convenience of having all your options in this one file
* outweighs the efficency of doing it the other way. */ * outweighs the efficency of doing it the other way. */
/* GAME PLAY OPTIONS */ /* YES / NO; TRUE / FALSE are all defined in utils.h */
#if !defined(NO)
#define NO 0
#endif
#if !defined(YES)
#define YES 1
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE (!FALSE)
#endif
/* pk_allowed sets the tone of the entire game. If pk_allowed is set to NO, /* pk_allowed sets the tone of the entire game. If pk_allowed is set to NO,
* then players will not be allowed to kill, summon, charm, or sleep other * then players will not be allowed to kill, summon, charm, or sleep other
@ -302,3 +290,10 @@ int min_wizlist_lev = LVL_GOD;
/* To mimic stock behavior set to NO. To allow mortals to see doors in exits /* To mimic stock behavior set to NO. To allow mortals to see doors in exits
* set to YES. */ * set to YES. */
int display_closed_doors = YES; int display_closed_doors = YES;
/* Automap and map options */
/* Default is to have automap and map command only enabled for immortals */
int map_option = MAP_IMM_ONLY;
int default_map_size = 6;
int default_minimap_size = 2;

View file

@ -1,26 +1,41 @@
/************************************************************************** /**
* File: constants.c Part of tbaMUD * * @file constants.c
* Usage: Numeric and string contants used by the MUD. * * Numeric and string contants used by the MUD.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license for complete information.
**************************************************************************/ * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.
*
* @todo Come up with a standard for descriptive arrays. Either all end with
* newlines or all of them don not.
*/
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "interpreter.h" /* alias_data */ #include "interpreter.h" /* alias_data */
/** Current tbaMUD version.
* @todo defined with _TBAMUD so we don't have multiple constants to change.
* @todo cpp_extern isn't needed here (or anywhere) as the extern reserved word
* works correctly with C compilers (at least in my Experience)
* Jeremy Osborne 1/28/2008 */
cpp_extern const char *tbamud_version = "tbaMUD, version 3.55"; cpp_extern const char *tbamud_version = "tbaMUD, version 3.55";
/** Current Oasis Online Creation version. */
cpp_extern const char *oasisolc_version = "OasisOLC 2.0.6"; cpp_extern const char *oasisolc_version = "OasisOLC 2.0.6";
/** Current ASCII player files version. */
cpp_extern const char *ascii_pfiles_version = "ASCII Player Files 3.0.1"; cpp_extern const char *ascii_pfiles_version = "ASCII Player Files 3.0.1";
/* strings corresponding to ordinals/bitvectors in structs.h */ /* strings corresponding to ordinals/bitvectors in structs.h */
/* (Note: strings for class definitions in class.c instead of here) */ /* (Note: strings for class definitions in class.c instead of here) */
/* cardinal directions */ /** Description of cardinal directions.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *dirs[] = const char *dirs[] =
{ {
"north", "north",
@ -29,10 +44,12 @@ const char *dirs[] =
"west", "west",
"up", "up",
"down", "down",
"\n" "\n"
}; };
/* ROOM_x */ /** Room flag descriptions.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *room_bits[] = { const char *room_bits[] = {
"DARK", "DARK",
"DEATH", "DEATH",
@ -49,11 +66,14 @@ const char *room_bits[] = {
"HCRSH", "HCRSH",
"ATRIUM", "ATRIUM",
"OLC", "OLC",
"*", /* BFS MARK */ "*", /* The BFS Mark. */
"\n" "WORLDMAP",
"\n"
}; };
/* EX_x */ /** Exit bits for doors.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *exit_bits[] = { const char *exit_bits[] = {
"DOOR", "DOOR",
"CLOSED", "CLOSED",
@ -62,7 +82,9 @@ const char *exit_bits[] = {
"\n" "\n"
}; };
/* SECT_ */ /** Description of the room sector type.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *sector_types[] = { const char *sector_types[] = {
"Inside", "Inside",
"City", "City",
@ -77,7 +99,9 @@ const char *sector_types[] = {
"\n" "\n"
}; };
/* SEX_x. Not used in sprinttype() so no \n. */ /** PC and NPC sex.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *genders[] = const char *genders[] =
{ {
"neutral", "neutral",
@ -86,7 +110,9 @@ const char *genders[] =
"\n" "\n"
}; };
/* POS_x */ /** Character positions.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *position_types[] = { const char *position_types[] = {
"Dead", "Dead",
"Mortally wounded", "Mortally wounded",
@ -100,7 +126,9 @@ const char *position_types[] = {
"\n" "\n"
}; };
/* PLR_x */ /** Player flags.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *player_bits[] = { const char *player_bits[] = {
"KILLER", "KILLER",
"THIEF", "THIEF",
@ -118,7 +146,7 @@ const char *player_bits[] = {
"NO_DEL", "NO_DEL",
"INVST", "INVST",
"CRYO", "CRYO",
"DEAD", /* You should never see this. */ "DEAD", /* You should never see this flag on a character in game. */
"UNUSED1", "UNUSED1",
"UNUSED2", "UNUSED2",
"UNUSED3", "UNUSED3",
@ -127,7 +155,9 @@ const char *player_bits[] = {
"\n" "\n"
}; };
/* MOB_x */ /** Mob action flags.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *action_bits[] = { const char *action_bits[] = {
"SPEC", "SPEC",
"SENTINEL", "SENTINEL",
@ -151,7 +181,9 @@ const char *action_bits[] = {
"\n" "\n"
}; };
/* PRF_x */ /** PC Preference flags.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *preference_bits[] = { const char *preference_bits[] = {
"BRIEF", "BRIEF",
"COMPACT", "COMPACT",
@ -184,10 +216,13 @@ const char *preference_bits[] = {
"AUTOSPLIT", "AUTOSPLIT",
"AUTOSAC", "AUTOSAC",
"AUTOASSIST", "AUTOASSIST",
"AUTOMAP",
"\n" "\n"
}; };
/* AFF_x */ /** Affected bits.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *affected_bits[] = const char *affected_bits[] =
{ {
"\0", /* DO NOT REMOVE!! */ "\0", /* DO NOT REMOVE!! */
@ -216,7 +251,9 @@ const char *affected_bits[] =
"\n" "\n"
}; };
/* CON_x */ /** Connection type descriptions.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *connected_types[] = { const char *connected_types[] = {
"Playing", "Playing",
"Disconnecting", "Disconnecting",
@ -249,7 +286,9 @@ const char *connected_types[] = {
"\n" "\n"
}; };
/* WEAR_x - for eq list. Not used in sprinttype() so no \n. */ /** Describes the position in the equipment listing.
* @pre Must be in the same order as the defines.
* Not used in sprinttype() so no \n. */
const char *wear_where[] = { const char *wear_where[] = {
"<used as light> ", "<used as light> ",
"<worn on finger> ", "<worn on finger> ",
@ -271,7 +310,9 @@ const char *wear_where[] = {
"<held> " "<held> "
}; };
/* WEAR_x - for stat */ /* Describes where an item can be worn.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *equipment_types[] = { const char *equipment_types[] = {
"Used as light", "Used as light",
"Worn on right finger", "Worn on right finger",
@ -294,7 +335,9 @@ const char *equipment_types[] = {
"\n" "\n"
}; };
/* ITEM_x (ordinal object types) */ /** Describes the type of object.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *item_types[] = { const char *item_types[] = {
"UNDEFINED", "UNDEFINED",
"LIGHT", "LIGHT",
@ -323,7 +366,9 @@ const char *item_types[] = {
"\n" "\n"
}; };
/* ITEM_WEAR_ (wear bitvector) */ /** Describes the wear flags set on an item.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *wear_bits[] = { const char *wear_bits[] = {
"TAKE", "TAKE",
"FINGER", "FINGER",
@ -343,7 +388,9 @@ const char *wear_bits[] = {
"\n" "\n"
}; };
/* ITEM_x (extra bits) */ /** Describes the extra flags applied to an item.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *extra_bits[] = { const char *extra_bits[] = {
"GLOW", "GLOW",
"HUM", "HUM",
@ -362,10 +409,13 @@ const char *extra_bits[] = {
"ANTI_THIEF", "ANTI_THIEF",
"ANTI_WARRIOR", "ANTI_WARRIOR",
"NO_SELL", "NO_SELL",
"QUEST_ITEM",
"\n" "\n"
}; };
/* APPLY_x */ /** Describes the apply types.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *apply_types[] = { const char *apply_types[] = {
"NONE", "NONE",
"STR", "STR",
@ -395,7 +445,9 @@ const char *apply_types[] = {
"\n" "\n"
}; };
/* CONT_x */ /** Describes the closure mechanism for a container.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *container_bits[] = { const char *container_bits[] = {
"CLOSEABLE", "CLOSEABLE",
"PICKPROOF", "PICKPROOF",
@ -404,7 +456,9 @@ const char *container_bits[] = {
"\n", "\n",
}; };
/* LIQ_x */ /** Describes the liquid description.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *drinks[] = const char *drinks[] =
{ {
"water", "water",
@ -426,7 +480,9 @@ const char *drinks[] =
"\n" "\n"
}; };
/* Other constants for liquids, one-word alias for each drink. */ /** Describes a one word alias for each type of liquid.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *drinknames[] = const char *drinknames[] =
{ {
"water", "water",
@ -448,7 +504,9 @@ const char *drinknames[] =
"\n" "\n"
}; };
/* effect of drinks on hunger, thirst, and drunkenness -- see values.doc */ /** Define the effect of liquids on hunger, thirst, and drunkenness, in that
* order. See values.doc for more information.
* @pre Must be in the same order as the defines. */
int drink_aff[][3] = { int drink_aff[][3] = {
{0, 1, 10}, {0, 1, 10},
{3, 2, 5}, {3, 2, 5},
@ -468,7 +526,9 @@ int drink_aff[][3] = {
{0, 0, 13} {0, 0, 13}
}; };
/* color of the various drinks */ /** Describes the color of the various drinks.
* @pre Must be in the same order as the defines.
* Must end array with a single newline. */
const char *color_liquid[] = const char *color_liquid[] =
{ {
"clear", "clear",
@ -490,7 +550,8 @@ const char *color_liquid[] =
"\n" "\n"
}; };
/* level of fullness for drink containers. Not used in sprinttype() so no \n. */ /** Used to describe the level of fullness of a drink container. Not used in
* sprinttype() so no \n. */
const char *fullness[] = const char *fullness[] =
{ {
"less than half ", "less than half ",
@ -499,7 +560,9 @@ const char *fullness[] =
"" ""
}; };
/* str, int, wis, dex, con applies, [ch] strength apply (all) */ /** Strength attribute affects.
* The fields are hit mod, damage mod, weight carried mod, and weight wielded
* mod. */
cpp_extern const struct str_app_type str_app[] = { cpp_extern const struct str_app_type str_app[] = {
{-5, -4, 0, 0}, /* str = 0 */ {-5, -4, 0, 0}, /* str = 0 */
{-5, -4, 3, 1}, /* str = 1 */ {-5, -4, 3, 1}, /* str = 1 */
@ -534,7 +597,8 @@ cpp_extern const struct str_app_type str_app[] = {
{3, 6, 480, 30} /* str = 18/100 */ {3, 6, 480, 30} /* str = 18/100 */
}; };
/* [dex] skill apply (thieves only) */ /** Dexterity skill modifiers for thieves.
* The fields are for pick pockets, pick locks, find traps, sneak and hide. */
cpp_extern const struct dex_skill_type dex_app_skill[] = { cpp_extern const struct dex_skill_type dex_app_skill[] = {
{-99, -99, -90, -99, -60}, /* dex = 0 */ {-99, -99, -90, -99, -60}, /* dex = 0 */
{-90, -90, -60, -90, -50}, /* dex = 1 */ {-90, -90, -60, -90, -50}, /* dex = 1 */
@ -564,7 +628,8 @@ cpp_extern const struct dex_skill_type dex_app_skill[] = {
{25, 30, 15, 25, 25} /* dex = 25 */ {25, 30, 15, 25, 25} /* dex = 25 */
}; };
/* [dex] apply (all) */ /** Dexterity attribute affects.
* The fields are reaction, missile attacks, and defensive (armor class). */
cpp_extern const struct dex_app_type dex_app[] = { cpp_extern const struct dex_app_type dex_app[] = {
{-7, -7, 6}, /* dex = 0 */ {-7, -7, 6}, /* dex = 0 */
{-6, -6, 5}, /* dex = 1 */ {-6, -6, 5}, /* dex = 1 */
@ -594,7 +659,8 @@ cpp_extern const struct dex_app_type dex_app[] = {
{5, 5, -6} /* dex = 25 */ {5, 5, -6} /* dex = 25 */
}; };
/* [con] apply (all) */ /** Constitution attribute affects.
* The fields referenced are hit points and system shock survival. */
cpp_extern const struct con_app_type con_app[] = { cpp_extern const struct con_app_type con_app[] = {
{-4, 20}, /* con = 0 */ {-4, 20}, /* con = 0 */
{-3, 25}, /* con = 1 */ {-3, 25}, /* con = 1 */
@ -624,7 +690,8 @@ cpp_extern const struct con_app_type con_app[] = {
{6, 99} /* con = 25 */ {6, 99} /* con = 25 */
}; };
/* [int] apply (all) */ /** Intelligence attribute affects.
* The field shows how much practicing affects a skill/spell. */
cpp_extern const struct int_app_type int_app[] = { cpp_extern const struct int_app_type int_app[] = {
{3}, /* int = 0 */ {3}, /* int = 0 */
{5}, /* int = 1 */ {5}, /* int = 1 */
@ -654,7 +721,8 @@ cpp_extern const struct int_app_type int_app[] = {
{60} /* int = 25 */ {60} /* int = 25 */
}; };
/* [wis] apply (all) */ /** Wisdom attribute affects.
* The field represents how many extra practice points are gained per level. */
cpp_extern const struct wis_app_type wis_app[] = { cpp_extern const struct wis_app_type wis_app[] = {
{0}, /* wis = 0 */ {0}, /* wis = 0 */
{0}, /* wis = 1 */ {0}, /* wis = 1 */
@ -684,16 +752,18 @@ cpp_extern const struct wis_app_type wis_app[] = {
{7} /* wis = 25 */ {7} /* wis = 25 */
}; };
/** Define a set of opposite directions from the cardinal directions. */
int rev_dir[] = int rev_dir[] =
{ {
2, SOUTH,
3, WEST,
0, NORTH,
1, EAST,
5, DOWN,
4 UP
}; };
/** How much movement is lost moving through a particular sector type. */
int movement_loss[] = int movement_loss[] =
{ {
1, /* Inside */ 1, /* Inside */
@ -705,10 +775,10 @@ int movement_loss[] =
4, /* Swimming */ 4, /* Swimming */
1, /* Unswimable */ 1, /* Unswimable */
1, /* Flying */ 1, /* Flying */
5 /* Underwater */ 5 /* Underwater */
}; };
/* Not used in sprinttype(). */ /** The names of the days of the mud week. Not used in sprinttype(). */
const char *weekdays[] = { const char *weekdays[] = {
"the Day of the Moon", "the Day of the Moon",
"the Day of the Bull", "the Day of the Bull",
@ -719,7 +789,7 @@ const char *weekdays[] = {
"the Day of the Sun" "the Day of the Sun"
}; };
/* Not used in sprinttype(). */ /** The names of the mud months. Not used in sprinttype(). */
const char *month_name[] = { const char *month_name[] = {
"Month of Winter", /* 0 */ "Month of Winter", /* 0 */
"Month of the Winter Wolf", "Month of the Winter Wolf",
@ -740,7 +810,7 @@ const char *month_name[] = {
"Month of the Great Evil" "Month of the Great Evil"
}; };
/* mob trigger types */ /** Names for mob trigger types. */
const char *trig_types[] = { const char *trig_types[] = {
"Global", "Global",
"Random", "Random",
@ -765,7 +835,7 @@ const char *trig_types[] = {
"\n" "\n"
}; };
/* obj trigger types */ /** Names for object trigger types. */
const char *otrig_types[] = { const char *otrig_types[] = {
"Global", "Global",
"Random", "Random",
@ -790,7 +860,7 @@ const char *otrig_types[] = {
"\n" "\n"
}; };
/* wld trigger types */ /** Names for world (room) trigger types. */
const char *wtrig_types[] = { const char *wtrig_types[] = {
"Global", "Global",
"Random", "Random",
@ -815,6 +885,9 @@ const char *wtrig_types[] = {
"\n" "\n"
}; };
/** The names of the different channels that history is stored for.
* @todo Only referenced by do_history at the moment. Should be moved local
* to that function. */
const char *history_types[] = { const char *history_types[] = {
"all", "all",
"say", "say",
@ -831,9 +904,14 @@ const char *history_types[] = {
/* Various arrays we count so we can check the world files. These /* Various arrays we count so we can check the world files. These
* must be at the bottom of the file so they're pre-declared. */ * must be at the bottom of the file so they're pre-declared. */
size_t room_bits_count = sizeof(room_bits) / sizeof(room_bits[0]) - 1, /** Number of defined room bit descriptions. */
size_t room_bits_count = sizeof(room_bits) / sizeof(room_bits[0]) - 1,
/** Number of defined action bit descriptions. */
action_bits_count = sizeof(action_bits) / sizeof(action_bits[0]) - 1, action_bits_count = sizeof(action_bits) / sizeof(action_bits[0]) - 1,
/** Number of defined affected bit descriptions. */
affected_bits_count = sizeof(affected_bits) / sizeof(affected_bits[0]) - 1, affected_bits_count = sizeof(affected_bits) / sizeof(affected_bits[0]) - 1,
/** Number of defined extra bit descriptions. */
extra_bits_count = sizeof(extra_bits) / sizeof(extra_bits[0]) - 1, extra_bits_count = sizeof(extra_bits) / sizeof(extra_bits[0]) - 1,
/** Number of defined wear bit descriptions. */
wear_bits_count = sizeof(wear_bits) / sizeof(wear_bits[0]) - 1; wear_bits_count = sizeof(wear_bits) / sizeof(wear_bits[0]) - 1;

View file

@ -1,12 +1,16 @@
/************************************************************************** /**
* File: constants.h Part of tbaMUD * * @file constants.h
* Usage: Header file for constants. * * Declares the global constants defined in constants.c.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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 _CONSTANTS_H_
#define _CONSTANTS_H_
extern const char *tbamud_version; extern const char *tbamud_version;
extern const char *oasisolc_version; extern const char *oasisolc_version;
@ -53,3 +57,5 @@ extern size_t action_bits_count;
extern size_t affected_bits_count; extern size_t affected_bits_count;
extern size_t extra_bits_count; extern size_t extra_bits_count;
extern size_t wear_bits_count; extern size_t wear_bits_count;
#endif /* _CONSTANTS_H_ */

305
src/db.c
View file

@ -25,6 +25,17 @@
#include "oasis.h" #include "oasis.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "dg_event.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 */ /* declarations of most of the 'global' variables */
struct config_data config_info; /* Game configuration list. */ 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 */ struct obj_data *obj_proto; /* prototypes for objs */
obj_rnum top_of_objt = 0; /* top of object index table */ obj_rnum top_of_objt = 0; /* top of object index table */
struct zone_data *zone_table; /* zone table */ struct zone_data *zone_table; /* zone table */
zone_rnum top_of_zone_table = 0;/* top element of zone tab */ 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 message_list fight_messages[MAX_MESSAGES]; /* fighting messages */
struct index_data **trig_index; /* index table for triggers */ 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 */ long max_obj_id = OBJ_ID_BASE; /* for unique obj id's */
int dg_owner_purged; /* For control of scripts */ 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 */ struct shop_data *shop_index; /* index table for shops */
int top_shop = -1; /* top of shop table */ int top_shop = -1; /* top of shop table */
int no_mail = 0; /* mail disabled? */ int no_mail = 0; /* mail disabled? */
int mini_mud = 0; /* mini-mud mode? */ int mini_mud = 0; /* mini-mud mode? */
int no_rent_check = 0; /* skip rent check on boot? */ int no_rent_check = 0; /* skip rent check on boot? */
time_t boot_time = 0; /* time of mud boot */ time_t boot_time = 0; /* time of mud boot */
int circle_restrict = 0; /* level of game restriction */ int circle_restrict = 0; /* level of game restriction */
room_rnum r_mortal_start_room; /* rnum of mortal start room */ 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_immort_start_room; /* rnum of immort start room */
room_rnum r_frozen_start_room; /* rnum of frozen start room */ room_rnum r_frozen_start_room; /* rnum of frozen start room */
int converting = FALSE;
char *credits = NULL; /* game credits */ char *credits = NULL; /* game credits */
char *news = NULL; /* mud news */ 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 */ struct social_messg *soc_mess_list = NULL; /* list of socials */
int top_of_socialt = -1; /* number 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 weather_data weather_info; /* the infomation about the weather */
struct player_special_data dummy_mob; /* dummy spec area for mobs */ 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 */ /* declaration of local (file scope) variables */
void paginate_string(char *str, struct descriptor_data *d); static int converting = FALSE;
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);
/* 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 */ /* routines for booting the system */
char *fread_action(FILE *fl, int nr) char *fread_action(FILE *fl, int nr)
@ -473,9 +442,13 @@ void boot_world(void)
log("Loading shops."); log("Loading shops.");
index_boot(DB_BOOT_SHP); 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; struct extra_descr_data *enext;
@ -582,6 +555,9 @@ void destroy_db(void)
/* Shops */ /* Shops */
destroy_shops(); destroy_shops();
/* Quests */
destroy_quests();
/* Zones */ /* Zones */
#define THIS_CMD zone_table[cnt].cmd[itr] #define THIS_CMD zone_table[cnt].cmd[itr]
@ -706,6 +682,8 @@ void boot_db(void)
assign_objects(); assign_objects();
log(" Rooms."); log(" Rooms.");
assign_rooms(); assign_rooms();
log(" Questmasters.");
assign_the_quests();
} }
log("Assigning spell and skill levels."); log("Assigning spell and skill levels.");
@ -742,7 +720,6 @@ void boot_db(void)
#if 1 #if 1
{ {
int i; int i;
extern SPECIAL(shop_keeper);
for (i = 0 ; i < top_of_objt; i++) { for (i = 0 ; i < top_of_objt; i++) {
if (obj_proto[i].script == (struct script_data *)&shop_keeper) { 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 */ /* reset the time in the game from file */
void reset_time(void) static void reset_time(void)
{ {
time_t beginning_of_time = 0; time_t beginning_of_time = 0;
FILE *bgtime; FILE *bgtime;
@ -776,7 +753,7 @@ void reset_time(void)
if ((bgtime = fopen(TIME_FILE, "r")) == NULL) if ((bgtime = fopen(TIME_FILE, "r")) == NULL)
log("No time file '%s' starting from the beginning.", TIME_FILE); log("No time file '%s' starting from the beginning.", TIME_FILE);
else { else {
fscanf(bgtime, "%ld\n", &beginning_of_time); fscanf(bgtime, "%ld\n", (long *)&beginning_of_time);
fclose(bgtime); fclose(bgtime);
} }
@ -825,14 +802,14 @@ void save_mud_time(struct time_info_data *when)
if ((bgtime = fopen(TIME_FILE, "w")) == NULL) if ((bgtime = fopen(TIME_FILE, "w")) == NULL)
log("SYSERR: Can't write to '%s' time file.", TIME_FILE); log("SYSERR: Can't write to '%s' time file.", TIME_FILE);
else { else {
fprintf(bgtime, "%ld\n", mud_time_to_secs(when)); fprintf(bgtime, "%ld\n", (long)mud_time_to_secs(when));
fclose(bgtime); fclose(bgtime);
} }
} }
/* Thanks to Andrey (andrey@alex-ua.com) for this bit of code, although I did /* 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 */ * 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 key[READ_SIZE], next_key[READ_SIZE];
char line[READ_SIZE], *scan; char line[READ_SIZE], *scan;
@ -914,6 +891,9 @@ void index_boot(int mode)
case DB_BOOT_TRG: case DB_BOOT_TRG:
prefix = TRG_PREFIX; prefix = TRG_PREFIX;
break; break;
case DB_BOOT_QST:
prefix = QST_PREFIX;
break;
default: default:
log("SYSERR: Unknown subcommand %d to index_boot!", mode); log("SYSERR: Unknown subcommand %d to index_boot!", mode);
exit(1); exit(1);
@ -954,7 +934,7 @@ void index_boot(int mode)
/* Exit if 0 records, unless this is shops */ /* Exit if 0 records, unless this is shops */
if (!rec_count) { if (!rec_count) {
if (mode == DB_BOOT_SHP) if (mode == DB_BOOT_SHP || mode == DB_BOOT_QST)
return; return;
log("SYSERR: boot error - 0 records counted in %s/%s.", prefix, log("SYSERR: boot error - 0 records counted in %s/%s.", prefix,
index_filename); index_filename);
@ -995,6 +975,11 @@ void index_boot(int mode)
size[0] = sizeof(struct help_index_element) * rec_count; size[0] = sizeof(struct help_index_element) * rec_count;
log(" %d entries, %d bytes.", rec_count, size[0]); log(" %d entries, %d bytes.", rec_count, size[0]);
break; 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); rewind(db_index);
@ -1010,6 +995,7 @@ void index_boot(int mode)
case DB_BOOT_OBJ: case DB_BOOT_OBJ:
case DB_BOOT_MOB: case DB_BOOT_MOB:
case DB_BOOT_TRG: case DB_BOOT_TRG:
case DB_BOOT_QST:
discrete_load(db_file, mode, buf2); discrete_load(db_file, mode, buf2);
break; break;
case DB_BOOT_ZON: case DB_BOOT_ZON:
@ -1040,7 +1026,7 @@ void discrete_load(FILE *fl, int mode, char *filename)
int nr = -1, last; int nr = -1, last;
char line[READ_SIZE]; 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 */ /* modes positions correspond to DB_BOOT_xxx in db.h */
for (;;) { for (;;) {
@ -1083,6 +1069,9 @@ void discrete_load(FILE *fl, int mode, char *filename)
case DB_BOOT_OBJ: case DB_BOOT_OBJ:
strlcpy(line, parse_object(fl, nr), sizeof(line)); strlcpy(line, parse_object(fl, nr), sizeof(line));
break; break;
case DB_BOOT_QST:
parse_quest(fl, nr);
break;
} }
} else { } else {
log("SYSERR: Format error in %s file %s near %s #%d", modes[mode], 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; char c;
do { do {
@ -1114,7 +1103,8 @@ bitvector_t asciiflag_conv(char *flag)
else if (isupper(*p)) else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A')); 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; is_num = FALSE;
} }
@ -1124,7 +1114,7 @@ bitvector_t asciiflag_conv(char *flag)
return (flags); return (flags);
} }
bitvector_t asciiflag_conv_aff(char *flag) static bitvector_t asciiflag_conv_aff(char *flag)
{ {
bitvector_t flags = 0; bitvector_t flags = 0;
int is_num = TRUE; int is_num = TRUE;
@ -1136,7 +1126,8 @@ bitvector_t asciiflag_conv_aff(char *flag)
else if (isupper(*p)) else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A' + 1)); 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; 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 */ /* 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) { if ((r_mortal_start_room = real_room(CONFIG_MORTAL_START)) == NOWHERE) {
log("SYSERR: Mortal start room does not exist. Change in config.c."); 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); 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] #define ZCMD zone_table[zone].cmd[cmd_no]
/* Resolve vnums into rnums in the zone reset tables. In English: Once all of /* 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 * is running. This does make adding any room, mobile, or object a little more
* difficult while the game is running. Assumes NOWHERE == NOBODY == NOTHING. * difficult while the game is running. Assumes NOWHERE == NOBODY == NOTHING.
* Assumes sizeof(room_rnum) >= (sizeof(mob_rnum) and sizeof(obj_rnum)) */ * 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; int cmd_no;
room_rnum a, b, c, olda, oldb, oldc; 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]; int j, t[10];
char line[READ_SIZE]; char line[READ_SIZE];
@ -1510,7 +1506,7 @@ void parse_simple_mob(FILE *mob_f, int i, int nr)
#define RANGE(low, high) \ #define RANGE(low, high) \
(num_arg = MAX((low), MIN((high), (num_arg)))) (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; 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 BOOL_CASE
#undef RANGE #undef RANGE
void parse_espec(char *buf, int i, int nr) static void parse_espec(char *buf, int i, int nr)
{ {
char *ptr; char *ptr;
@ -1581,7 +1577,7 @@ void parse_espec(char *buf, int i, int nr)
interpret_espec(buf, ptr, i, 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]; char line[READ_SIZE];
@ -1946,7 +1942,7 @@ char *parse_object(FILE *obj_f, int nr)
#define Z zone_table[zone] #define Z zone_table[zone]
/* load the zone table and command tables */ /* 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; static zone_rnum zone = 0;
int cmd_no, num_of_cmds = 0, line_num = 0, tmp, error; 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 #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) { if (fgets(buf, READ_SIZE, fl) == NULL) {
log("SYSERR: error reading help file: not terminated with $?"); 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; 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: zone file: %s", message);
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: ...offending cmd: '%c' cmd in zone #%d, line %d", 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 */ /* 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) if (!k)
return; return;
@ -2747,6 +2743,8 @@ void free_char(struct char_data *ch)
free(ch->player_specials->poofin); free(ch->player_specials->poofin);
if (ch->player_specials->poofout) if (ch->player_specials->poofout)
free(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)) if (GET_HOST(ch))
free(GET_HOST(ch)); free(GET_HOST(ch));
if (IS_NPC(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 * 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 * trying to replace, give everybody using it a different copy so as to avoid
* special cases. */ * 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; int temppage;
char temp[MAX_STRING_LENGTH]; 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 */ /* 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; FILE *fl;
char tmp[READ_SIZE + 3]; char tmp[READ_SIZE + 3];
@ -2996,6 +2994,10 @@ void init_char(struct char_data *ch)
ch->player.long_descr = NULL; ch->player.long_descr = NULL;
ch->player.description = 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.birth = time(0);
ch->player.time.logon = time(0); ch->player.time.logon = time(0);
ch->player.time.played = 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_COND(ch, i) = (GET_LEVEL(ch) == LVL_IMPL ? -1 : 24);
GET_LOADROOM(ch) = NOWHERE; GET_LOADROOM(ch) = NOWHERE;
GET_SCREEN_WIDTH(ch) = PAGE_WIDTH;
} }
/* returns the real number of the room with given virtual number */ /* 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. */ /* 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]; char objname[MAX_INPUT_LENGTH + 32];
int error = FALSE, y; int error = FALSE, y;
@ -3205,7 +3208,6 @@ int check_object(struct obj_data *obj)
break; break;
case ITEM_NOTE: case ITEM_NOTE:
if (obj->ex_description) { if (obj->ex_description) {
extern char *find_exdesc(char *word, struct extra_descr_data *list);
char onealias[MAX_INPUT_LENGTH],*next_name; char onealias[MAX_INPUT_LENGTH],*next_name;
next_name = any_one_arg(obj->name, onealias); next_name = any_one_arg(obj->name, onealias);
do { do {
@ -3228,7 +3230,7 @@ int check_object(struct obj_data *obj)
return (error); 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; int error = FALSE;
const char *spellname; const char *spellname;
@ -3262,7 +3264,7 @@ int check_object_spell_number(struct obj_data *obj, int val)
return (error); 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; int error = FALSE;
@ -3273,7 +3275,7 @@ int check_object_level(struct obj_data *obj, int val)
return (error); 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; unsigned int flagnum;
bool error = FALSE; 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++) for (flagnum = namecount; flagnum < sizeof(bitvector_t) * 8; flagnum++)
if ((1 << flagnum) & bits) { 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; error = TRUE;
} }
return (error); return (error);
} }
/* External variables from config.c */ static void load_default_config( void )
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 )
{ {
/* This function is called only once, at boot-time. We assume config_info is /* This function is called only once, at boot-time. We assume config_info is
* empty. -Welcor */ * empty. -Welcor */
@ -3366,6 +3318,9 @@ void load_default_config( void )
CONFIG_TRACK_T_DOORS = track_through_doors; CONFIG_TRACK_T_DOORS = track_through_doors;
CONFIG_NO_MORT_TO_IMMORT = no_mort_to_immort; CONFIG_NO_MORT_TO_IMMORT = no_mort_to_immort;
CONFIG_DISP_CLOSED_DOORS = display_closed_doors; 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. */ /* Rent / crashsave options. */
CONFIG_FREE_RENT = free_rent; CONFIG_FREE_RENT = free_rent;
@ -3425,7 +3380,7 @@ void load_config( void )
load_default_config(); 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")) ) { if ( !(fl = fopen(CONFIG_CONFFILE, "r")) && !(fl = fopen(buf, "r")) ) {
snprintf(buf, sizeof(buf), "No %s file, using defaults", CONFIG_CONFFILE); snprintf(buf, sizeof(buf), "No %s file, using defaults", CONFIG_CONFFILE);
perror(buf); perror(buf);
@ -3488,6 +3443,10 @@ void load_config( void )
CONFIG_DFLT_IP = NULL; CONFIG_DFLT_IP = NULL;
} else if (!str_cmp(tag, "dflt_port")) } else if (!str_cmp(tag, "dflt_port"))
CONFIG_DFLT_PORT = num; 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; break;
case 'f': case 'f':
@ -3558,6 +3517,8 @@ void load_config( void )
CONFIG_MIN_WIZLIST_LEV = num; CONFIG_MIN_WIZLIST_LEV = num;
else if (!str_cmp(tag, "mortal_start_room")) else if (!str_cmp(tag, "mortal_start_room"))
CONFIG_MORTAL_START = num; CONFIG_MORTAL_START = num;
else if (!str_cmp(tag, "map_option"))
CONFIG_MAP = num;
break; break;
case 'n': case 'n':

248
src/db.h
View file

@ -1,12 +1,18 @@
/************************************************************************** /**
* File: db.h Part of tbaMUD * * @file db.h
* Usage: Header file for database handling. * * Header file for database handling.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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) */ /* arbitrary constants used by index_boot() (must be unique) */
#define DB_BOOT_WLD 0 #define DB_BOOT_WLD 0
@ -16,6 +22,7 @@
#define DB_BOOT_SHP 4 #define DB_BOOT_SHP 4
#define DB_BOOT_HLP 5 #define DB_BOOT_HLP 5
#define DB_BOOT_TRG 6 #define DB_BOOT_TRG 6
#define DB_BOOT_QST 7
#if defined(CIRCLE_MACINTOSH) #if defined(CIRCLE_MACINTOSH)
#define LIB_WORLD ":world:" #define LIB_WORLD ":world:"
@ -69,13 +76,14 @@
/* names of various files and directories */ /* names of various files and directories */
#define INDEX_FILE "index" /* index of world files */ #define INDEX_FILE "index" /* index of world files */
#define MINDEX_FILE "index.mini" /* ... and for mini-mud-mode */ #define MINDEX_FILE "index.mini" /* ... and for mini-mud-mode */
#define WLD_PREFIX LIB_WORLD"wld"SLASH /* room definitions */ #define WLD_PREFIX LIB_WORLD"wld"SLASH /* room definitions */
#define MOB_PREFIX LIB_WORLD"mob"SLASH /* monster prototypes */ #define MOB_PREFIX LIB_WORLD"mob"SLASH /* monster prototypes */
#define OBJ_PREFIX LIB_WORLD"obj"SLASH /* object prototypes */ #define OBJ_PREFIX LIB_WORLD"obj"SLASH /* object prototypes */
#define ZON_PREFIX LIB_WORLD"zon"SLASH /* zon defs & command tables */ #define ZON_PREFIX LIB_WORLD"zon"SLASH /* zon defs & command tables */
#define SHP_PREFIX LIB_WORLD"shp"SLASH /* shop definitions */ #define SHP_PREFIX LIB_WORLD"shp"SLASH /* shop definitions */
#define TRG_PREFIX LIB_WORLD"trg"SLASH /* trigger files */ #define TRG_PREFIX LIB_WORLD"trg"SLASH /* trigger files */
#define HLP_PREFIX LIB_TEXT"help"SLASH /* Help files */ #define HLP_PREFIX LIB_TEXT"help"SLASH /* Help files */
#define QST_PREFIX LIB_WORLD"qst"SLASH /* quest files */
#define CREDITS_FILE LIB_TEXT"credits" /* for the 'credits' command */ #define CREDITS_FILE LIB_TEXT"credits" /* for the 'credits' command */
#define NEWS_FILE LIB_TEXT"news" /* for the 'news' command */ #define NEWS_FILE LIB_TEXT"news" /* for the 'news' command */
@ -100,6 +108,27 @@
#define SOCMESS_FILE_NEW LIB_MISC"socials.new" /* messages for social acts with aedit patch*/ #define SOCMESS_FILE_NEW LIB_MISC"socials.new" /* messages for social acts with aedit patch*/
#define XNAME_FILE LIB_MISC"xnames" /* invalid name substrings */ #define XNAME_FILE LIB_MISC"xnames" /* invalid name substrings */
/* BEGIN: Assumed default locations for logfiles, mainly used in do_file. */
/**/
#define SYSLOG_LOGFILE "../syslog"
#define CRASH_LOGFILE "../syslog.CRASH"
#define PREFIX_LOGFILE "../log/"
#define LEVELS_LOGFILE PREFIX_LOGFILE"levels"
#define RIP_LOGFILE PREFIX_LOGFILE"rip"
#define NEWPLAYERS_LOGFILE PREFIX_LOGFILE"newplayers"
#define RENTGONE_LOGFILE PREFIX_LOGFILE"rentgone"
#define ERRORS_LOGFILE PREFIX_LOGFILE"errors"
#define GODCMDS_LOGFILE PREFIX_LOGFILE"godcmds"
#define HELP_LOGFILE PREFIX_LOGFILE"help"
#define DELETES_LOGFILE PREFIX_LOGFILE"delete"
#define RESTARTS_LOGFILE PREFIX_LOGFILE"restarts"
#define USAGE_LOGFILE PREFIX_LOGFILE"usage"
#define BADPWS_LOGFILE PREFIX_LOGFILE"badpws"
#define OLC_LOGFILE PREFIX_LOGFILE"olc"
#define TRIGGER_LOGFILE PREFIX_LOGFILE"trigger"
/**/
/* END: Assumed default locations for logfiles, mainly used in do_file. */
#define CONFIG_FILE LIB_ETC"config" /* OasisOLC * GAME CONFIG FL */ #define CONFIG_FILE LIB_ETC"config" /* OasisOLC * GAME CONFIG FL */
#define PLAYER_FILE LIB_ETC"players" /* the player database */ #define PLAYER_FILE LIB_ETC"players" /* the player database */
#define MAIL_FILE LIB_ETC"plrmail" /* for the mudmail system */ #define MAIL_FILE LIB_ETC"plrmail" /* for the mudmail system */
@ -115,47 +144,6 @@
#define PINDEX_SELFDELETE (1 << 2) /* player is selfdeleting*/ #define PINDEX_SELFDELETE (1 << 2) /* player is selfdeleting*/
#define PINDEX_NOWIZLIST (1 << 3) /* Player shouldn't be on wizlist*/ #define PINDEX_NOWIZLIST (1 << 3) /* Player shouldn't be on wizlist*/
/* public procedures in db.c */
void boot_db(void);
void destroy_db(void);
int create_entry(char *name);
void zone_update(void);
char *fread_string(FILE *fl, const char *error);
long get_id_by_name(const char *name);
char *get_name_by_id(long id);
void save_mud_time(struct time_info_data *when);
void free_text_files(void);
void free_help_table(void);
void free_player_index(void);
void load_help(FILE *fl, char *name);
void clean_pfiles(void);
zone_rnum real_zone(zone_vnum vnum);
room_rnum real_room(room_vnum vnum);
mob_rnum real_mobile(mob_vnum vnum);
obj_rnum real_object(obj_vnum vnum);
int load_char(const char *name, struct char_data *ch);
void save_char(struct char_data *ch);
void init_char(struct char_data *ch);
struct char_data* create_char(void);
struct char_data *read_mobile(mob_vnum nr, int type);
int vnum_mobile(char *searchname, struct char_data *ch);
void clear_char(struct char_data *ch);
void reset_char(struct char_data *ch);
void free_char(struct char_data *ch);
void save_player_index(void);
long get_ptable_by_name(const char *name);
void remove_player(int pfilepos);
struct obj_data *create_obj(void);
void clear_object(struct obj_data *obj);
void free_obj(struct obj_data *obj);
struct obj_data *read_object(obj_vnum nr, int type);
int vnum_object(char *searchname, struct char_data *ch);
int vnum_room(char *, struct char_data *);
int vnum_trig(char *, struct char_data *);
#define REAL 0 #define REAL 0
#define VIRTUAL 1 #define VIRTUAL 1
@ -233,20 +221,7 @@ struct help_index_element {
int min_level; /*Min Level to read help entry*/ int min_level; /*Min Level to read help entry*/
}; };
/* don't change these */ /* The ban defines and structs were moved to ban.h */
#define BAN_NOT 0
#define BAN_NEW 1
#define BAN_SELECT 2
#define BAN_ALL 3
#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;
};
/* for the "buffered" rent and house object loading */ /* for the "buffered" rent and house object loading */
struct obj_save_data_t { struct obj_save_data_t {
@ -257,18 +232,132 @@ struct obj_save_data_t {
typedef struct obj_save_data_t obj_save_data; typedef struct obj_save_data_t obj_save_data;
/* public procedures in db.c */
void boot_db(void);
void destroy_db(void);
char *fread_action(FILE *fl, int nr);
int create_entry(char *name);
void zone_update(void);
char *fread_string(FILE *fl, const char *error);
long get_id_by_name(const char *name);
char *get_name_by_id(long id);
void save_mud_time(struct time_info_data *when);
void free_text_files(void);
void free_help_table(void);
void free_player_index(void);
void load_help(FILE *fl, char *name);
zone_rnum real_zone(zone_vnum vnum);
room_rnum real_room(room_vnum vnum);
mob_rnum real_mobile(mob_vnum vnum);
obj_rnum real_object(obj_vnum vnum);
/* Public Procedures from objsave.c */
void Crash_save_all(void);
void Crash_idlesave(struct char_data *ch);
void Crash_crashsave(struct char_data *ch);
int Crash_load(struct char_data *ch);
void Crash_listrent(struct char_data *ch, char *name);
int Crash_clean_file(char *name);
int Crash_delete_crashfile(struct char_data *ch);
int Crash_delete_file(char *name);
void update_obj_file(void);
void Crash_rentsave(struct char_data *ch, int cost);
obj_save_data *objsave_parse_objects(FILE *fl);
int objsave_save_obj_record(struct obj_data *obj, FILE *fl, int location);
/* Special functions */
SPECIAL(receptionist);
SPECIAL(cryogenicist);
/* Functions from players.c */
void tag_argument(char *argument, char *tag);
int load_char(const char *name, struct char_data *ch);
void save_char(struct char_data *ch);
void init_char(struct char_data *ch);
struct char_data* create_char(void);
struct char_data *read_mobile(mob_vnum nr, int type);
int vnum_mobile(char *searchname, struct char_data *ch);
void clear_char(struct char_data *ch);
void reset_char(struct char_data *ch);
void free_char(struct char_data *ch);
void save_player_index(void);
long get_ptable_by_name(const char *name);
void remove_player(int pfilepos);
void clean_pfiles(void);
void build_player_index(void);
struct obj_data *create_obj(void);
void clear_object(struct obj_data *obj);
void free_obj(struct obj_data *obj);
struct obj_data *read_object(obj_vnum nr, int type);
int vnum_object(char *searchname, struct char_data *ch);
int vnum_room(char *, struct char_data *);
int vnum_trig(char *, struct char_data *);
void setup_dir(FILE *fl, int room, int dir);
void index_boot(int mode);
void discrete_load(FILE *fl, int mode, char *filename);
void parse_room(FILE *fl, int virtual_nr);
void parse_mobile(FILE *mob_f, int nr);
char *parse_object(FILE *obj_f, int nr);
int is_empty(zone_rnum zone_nr);
void reset_zone(zone_rnum zone);
void reboot_wizlists(void);
ACMD(do_reboot);
void boot_world(void);
int count_hash_records(FILE *fl);
bitvector_t asciiflag_conv(char *flag);
void renum_world(void);
void load_config( void );
/* global buffering system */ /* global buffering system */
#ifndef __DB_C__ #ifndef __DB_C__
/* Various Files */
extern char *credits;
extern char *news;
extern char *motd;
extern char *imotd;
extern char *GREETINGS;
extern char *help;
extern char *ihelp;
extern char *info;
extern char *wizlist;
extern char *immlist;
extern char *background;
extern char *handbook;
extern char *policies;
/* The ingame helpfile */
extern int top_of_helpt;
extern struct help_index_element *help_table;
/* Mud configurable variables */
extern int no_mail;
extern int mini_mud;
extern int no_rent_check;
extern time_t boot_time;
extern int circle_restrict;
extern room_rnum r_mortal_start_room;
extern room_rnum r_immort_start_room;
extern room_rnum r_frozen_start_room;
extern struct config_data config_info; extern struct config_data config_info;
extern struct time_info_data time_info;
extern struct weather_data weather_info;
extern struct player_special_data dummy_mob;
extern struct reset_q_type reset_q;
extern struct room_data *world; extern struct room_data *world;
extern room_rnum top_of_world; extern room_rnum top_of_world;
extern struct zone_data *zone_table; extern struct zone_data *zone_table;
extern zone_rnum top_of_zone_table; extern zone_rnum top_of_zone_table;
extern struct descriptor_data *descriptor_list;
extern struct char_data *character_list; extern struct char_data *character_list;
extern struct player_special_data dummy_mob; extern struct player_special_data dummy_mob;
@ -294,4 +383,19 @@ extern long max_mob_id;
extern long max_obj_id; extern long max_obj_id;
extern int dg_owner_purged; extern int dg_owner_purged;
extern struct message_list fight_messages[MAX_MESSAGES];
/* autoquest globals */
extern struct aq_data *aquest_table;
extern qst_rnum total_quests;
/* begin previously located in players.c, returned to db.c */
extern struct player_index_element *player_table;
extern int top_of_p_table;
extern int top_of_p_file;
extern long top_idnum;
/* end previously located in players.c */
#endif /* __DB_C__ */ #endif /* __DB_C__ */
#endif /* _DB_H_ */

View file

@ -23,7 +23,7 @@
#include "constants.h" #include "constants.h"
/* local functions */ /* local functions */
void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]); static void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]);
/* same as any_one_arg except that it stops at punctuation */ /* same as any_one_arg except that it stops at punctuation */
char *any_one_name(char *argument, char *first_arg) char *any_one_name(char *argument, char *first_arg)
@ -44,7 +44,7 @@ char *any_one_name(char *argument, char *first_arg)
return argument; return argument;
} }
void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]) static void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[])
{ {
char sb[MAX_STRING_LENGTH]; char sb[MAX_STRING_LENGTH];
int i; int i;

View file

@ -22,12 +22,10 @@
#include "dg_event.h" #include "dg_event.h"
#include "comm.h" #include "comm.h"
#include "constants.h" #include "constants.h"
#include "interpreter.h" /* For half_chop */
extern void half_chop(char *string, char *arg1, char *arg2);
extern bitvector_t asciiflag_conv(char *flag);
/* local functions */ /* local functions */
void trig_data_init(trig_data *this_data); static void trig_data_init(trig_data *this_data);
void parse_trigger(FILE *trig_f, int nr) void parse_trigger(FILE *trig_f, int nr)
{ {
@ -93,7 +91,7 @@ trig_data *read_trigger(int nr)
return trig; return trig;
} }
void trig_data_init(trig_data *this_data) static void trig_data_init(trig_data *this_data)
{ {
this_data->nr = NOTHING; this_data->nr = NOTHING;
this_data->data_type = 0; this_data->data_type = 0;

View file

@ -1,33 +1,59 @@
/************************************************************************** /**
* File: dg_event.c Part of tbaMUD * * @file dg_event.c
* Usage: This file contains a simplified event system to allow trigedit * * This file contains a simplified event system to allow trigedit
* to use the "wait" command, causing a delay in the middle of a script. * * to use the "wait" command, causing a delay in the middle of a script.
* * * This system could easily be expanded by coders who wish to implement
* $Author: Mark A. Heilpern/egreen/Welcor $ * * an event driven mud.
* $Date: 2004/10/11 12:07:00$ * *
* $Revision: 1.0.14 $ * * Part of the core tbaMUD source code distribution, which is a derivative
**************************************************************************/ * of, and continuation of, CircleMUD.
*
* This source code, which was not part of the CircleMUD legacy code,
* was created by the following people:
* $Author: Mark A. Heilpern/egreen/Welcor $
* $Date: 2004/10/11 12:07:00$
* $Revision: 1.0.14 $
*/
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "db.h"
#include "utils.h" #include "utils.h"
#include "db.h"
#include "dg_event.h" #include "dg_event.h"
#include "constants.h" #include "constants.h"
#include "comm.h" /* For access to the game pulse */
struct queue *event_q; /* the event queue */
extern long pulse; /***************************************************************************
* Begin mud specific event queue functions
**************************************************************************/
/* file scope variables */
/** The mud specific queue of events. */
static struct dg_queue *event_q;
/* initializes the event queue */
/** Initializes the main event queue event_q.
* @post The main event queue, event_q, has been created and initialized.
*/
void event_init(void) void event_init(void)
{ {
event_q = queue_init(); event_q = queue_init();
} }
/* Add an event to the current list. Creates an event and returns it. */ /** Creates a new event 'object' that is then enqueued to the global event_q.
* @post If the newly created event is valid, it is always added to event_q.
* @param func The function to be called when this event fires. This function
* will be passed event_obj when it fires. The function must match the form
* described by EVENTFUNC.
* @param event_obj An optional 'something' to be passed to func when this
* event fires. It is func's job to cast event_obj. If event_obj is not needed,
* pass in NULL.
* @param when Number of pulses between firing(s) of this event.
* @retval event * Returns a pointer to the newly created event.
* */
struct event *event_create(EVENTFUNC(*func), void *event_obj, long when) struct event *event_create(EVENTFUNC(*func), void *event_obj, long when)
{ {
struct event *new_event; struct event *new_event;
@ -43,7 +69,9 @@ struct event *event_create(EVENTFUNC(*func), void *event_obj, long when)
return new_event; return new_event;
} }
/* removes the event from the system */ /** Removes an event from event_q and frees the event.
* @param event Pointer to the event to be dequeued and removed.
*/
void event_cancel(struct event *event) void event_cancel(struct event *event)
{ {
if (!event) { if (!event) {
@ -61,7 +89,9 @@ void event_cancel(struct event *event)
free(event); free(event);
} }
/* Process any events whose time has come. */ /** Process any events whose time has come. Should be called from, and at, every
* pulse of heartbeat. Re-enqueues multi-use events.
*/
void event_process(void) void event_process(void)
{ {
struct event *the_event; struct event *the_event;
@ -82,11 +112,17 @@ void event_process(void)
if ((new_time = (the_event->func)(the_event->event_obj)) > 0) if ((new_time = (the_event->func)(the_event->event_obj)) > 0)
the_event->q_el = queue_enq(event_q, the_event, new_time + pulse); the_event->q_el = queue_enq(event_q, the_event, new_time + pulse);
else else
{
/* It is assumed that the_event will already have freed ->event_obj. */
free(the_event); free(the_event);
}
} }
} }
/* returns the time remaining before the event */ /** Returns the time remaining before the event as how many pulses from now.
* @param event Check this event for it's scheduled activation time.
* @retval long Number of pulses before this event will fire. */
long event_time(struct event *event) long event_time(struct event *event)
{ {
long when; long when;
@ -96,13 +132,16 @@ long event_time(struct event *event)
return (when - pulse); return (when - pulse);
} }
/* frees all events in the queue */ /** Frees all events from event_q. */
void event_free_all(void) void event_free_all(void)
{ {
queue_free(event_q); queue_free(event_q);
} }
/* boolean function to tell whether an event is queued or not */ /** Boolean function to tell whether an event is queued or not. Does this by
* checking if event->q_el points to anything but null.
* @retval int 1 if the event has been queued, 0 if the event has not been
* queued. */
int event_is_queued(struct event *event) int event_is_queued(struct event *event)
{ {
if (event->q_el) if (event->q_el)
@ -110,20 +149,35 @@ int event_is_queued(struct event *event)
else else
return 0; return 0;
} }
/***************************************************************************
* End mud specific event queue functions
**************************************************************************/
/* Generic queue functions for building and using a priority queue. */ /***************************************************************************
/* returns a new, initialized queue */ * Begin generic (abstract) priority queue functions
struct queue *queue_init(void) **************************************************************************/
/** Create a new, empty, priority queue and return it.
* @retval dg_queue * Pointer to the newly created queue structure. */
struct dg_queue *queue_init(void)
{ {
struct queue *q; struct dg_queue *q;
CREATE(q, struct queue, 1); CREATE(q, struct dg_queue, 1);
return q; return q;
} }
/* add data into the priority queue q with key */ /** Add some 'data' to a priority queue.
struct q_element *queue_enq(struct queue *q, void *data, long key) * @pre The paremeter q must have been previously created by queue_init.
* @post A new q_element is created to hold the data parameter.
* @param q The existing dg_queue to add an element to.
* @param data The data to be associated with, and theoretically used, when
* the element comes up in q. data is wrapped in a new q_element.
* @param key Indicates where this event should be located in the queue, and
* when the element should be activated.
* @retval q_element * Pointer to the created q_element that contains
* the data. */
struct q_element *queue_enq(struct dg_queue *q, void *data, long key)
{ {
struct q_element *qe, *i; struct q_element *qe, *i;
int bucket; int bucket;
@ -166,8 +220,13 @@ struct q_element *queue_enq(struct queue *q, void *data, long key)
return qe; return qe;
} }
/* remove queue element qe from the priority queue q */ /** Remove queue element qe from the priority queue q.
void queue_deq(struct queue *q, struct q_element *qe) * @pre qe->data has been dealt with in some way.
* @post qe has been freed.
* @param q Pointer to the queue containing qe.
* @param qe Pointer to the q_element to remove from q.
*/
void queue_deq(struct dg_queue *q, struct q_element *qe)
{ {
int i; int i;
@ -188,8 +247,14 @@ void queue_deq(struct queue *q, struct q_element *qe)
free(qe); free(qe);
} }
/* Removes and returns the data of the first element of the priority queue q. */ /** Removes and returns the data of the first element of the priority queue q.
void *queue_head(struct queue *q) * @pre pulse must be defined. This is a multi-headed queue, the current
* head is determined by the current pulse.
* @post the q->head is dequeued.
* @param q The queue to return the head of.
* @retval void * NULL if there is not a currently available head, pointer
* to any data object associated with the queue element. */
void *queue_head(struct dg_queue *q)
{ {
void *dg_data; void *dg_data;
int i; int i;
@ -204,9 +269,13 @@ void *queue_head(struct queue *q)
return dg_data; return dg_data;
} }
/* Returns the key of the head element of the priority queue if q is NULL, then /** Returns the key of the head element of the priority queue.
* return the largest unsigned number. */ * @pre pulse must be defined. This is a multi-headed queue, the current
long queue_key(struct queue *q) * head is determined by the current pulse.
* @param q Queue to check for.
* @retval long Return the key element of the head q_element. If no head
* q_element is available, return LONG_MAX. */
long queue_key(struct dg_queue *q)
{ {
int i; int i;
@ -218,29 +287,39 @@ long queue_key(struct queue *q)
return LONG_MAX; return LONG_MAX;
} }
/* returns the key of queue element qe */ /** Returns the key of queue element qe.
* @param qe Pointer to the keyed q_element.
* @retval long Key of qe. */
long queue_elmt_key(struct q_element *qe) long queue_elmt_key(struct q_element *qe)
{ {
return qe->key; return qe->key;
} }
/* free q and contents */ /** Free q and all contents.
void queue_free(struct queue *q) * @pre Function requires definition of struct event.
* @post All items associeated qith q, including non-abstract data, are freed.
* @param q The priority queue to free.
*/
void queue_free(struct dg_queue *q)
{ {
int i; int i;
struct q_element *qe, *next_qe; struct q_element *qe, *next_qe;
struct event *event; struct event *event;
for (i = 0; i < NUM_EVENT_QUEUES; i++) for (i = 0; i < NUM_EVENT_QUEUES; i++)
for (qe = q->head[i]; qe; qe = next_qe) { {
for (qe = q->head[i]; qe; qe = next_qe)
{
next_qe = qe->next; next_qe = qe->next;
if ((event = (struct event *) qe->data) != NULL) { if ((event = (struct event *) qe->data) != NULL)
if (event->event_obj) {
free(event->event_obj); if (event->event_obj)
free(event); free(event->event_obj);
free(event);
} }
free(qe); free(qe);
} }
}
free(q); free(q);
} }

View file

@ -1,42 +1,66 @@
/************************************************************************** /**
* File: dg_event.h Part of tbaMUD * * @file dg_event.h
* Usage: Structures and prototypes for events. * * This file contains defines for the simplified event system to allow trigedit
* * * to use the "wait" command, causing a delay in the middle of a script.
* $Author: Mark A. Heilpern/egreen/Welcor $ * * This system could easily be expanded by coders who wish to implement
* $Date: 2004/10/11 12:07:00$ * * an event driven mud.
* $Revision: 1.0.14 $ * *
**************************************************************************/ * Part of the core tbaMUD source code distribution, which is a derivative
* of, and continuation of, CircleMUD.
*
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* $Author: Mark A. Heilpern/egreen/Welcor $
* $Date: 2004/10/11 12:07:00$
* $Revision: 1.0.14 $
*/
#ifndef _DG_EVENT_H_
#define _DG_EVENT_H_
/* How often will heartbeat() call the 'wait' event function? */ /** How often will heartbeat() call the 'wait' event function?
* @deprecated Currently not used. */
#define PULSE_DG_EVENT 1 #define PULSE_DG_EVENT 1
/* Event related section.*/ /**************************************************************************
* Begin event structures and defines.
**************************************************************************/
/** All Functions handled by the event system must be of this format. */
#define EVENTFUNC(name) long (name)(void *event_obj) #define EVENTFUNC(name) long (name)(void *event_obj)
/* Define event related structures. */ /** The event structure. Events get attached to the queue and are executed
* when their turn comes up in the queue. */
struct event { struct event {
EVENTFUNC(*func); EVENTFUNC(*func); /**< The function called when this event comes up. */
void *event_obj; void *event_obj; /**< event_obj is passed to func when func is called */
struct q_element *q_el; struct q_element *q_el; /**< Where this event is located in the queue */
}; };
/* End of Event related info. */ /**************************************************************************
* End event structures and defines.
**************************************************************************/
/* Queue related info. */ /**************************************************************************
/* number of queues to use (reduces enqueue cost) */ * Begin priority queue structures and defines.
**************************************************************************/
/** Number of buckets available in each queue. Reduces enqueue cost. */
#define NUM_EVENT_QUEUES 10 #define NUM_EVENT_QUEUES 10
struct queue { /** The priority queue. */
struct q_element *head[NUM_EVENT_QUEUES], *tail[NUM_EVENT_QUEUES]; struct dg_queue {
struct q_element *head[NUM_EVENT_QUEUES]; /**< Front of each queue bucket. */
struct q_element *tail[NUM_EVENT_QUEUES]; /**< Rear of each queue bucket. */
}; };
/** Queued elements. */
struct q_element { struct q_element {
void *data; void *data; /**< The event to be handled. */
long key; long key; /**< When the event should be handled. */
struct q_element *prev, *next; struct q_element *prev, *next; /**< Points to other q_elements in line. */
}; };
/* End of Queue related info. */ /**************************************************************************
* End priority queue structures and defines.
**************************************************************************/
/* - events - function protos need by other modules */ /* - events - function protos needed by other modules */
void event_init(void); void event_init(void);
struct event *event_create(EVENTFUNC(*func), void *event_obj, long when); struct event *event_create(EVENTFUNC(*func), void *event_obj, long when);
void event_cancel(struct event *event); void event_cancel(struct event *event);
@ -45,11 +69,13 @@ long event_time(struct event *event);
void event_free_all(void); void event_free_all(void);
/* - queues - function protos need by other modules */ /* - queues - function protos need by other modules */
struct queue *queue_init(void); struct dg_queue *queue_init(void);
struct q_element *queue_enq(struct queue *q, void *data, long key); struct q_element *queue_enq(struct dg_queue *q, void *data, long key);
void queue_deq(struct queue *q, struct q_element *qe); void queue_deq(struct dg_queue *q, struct q_element *qe);
void *queue_head(struct queue *q); void *queue_head(struct dg_queue *q);
long queue_key(struct queue *q); long queue_key(struct dg_queue *q);
long queue_elmt_key(struct q_element *qe); long queue_elmt_key(struct q_element *qe);
void queue_free(struct queue *q); void queue_free(struct dg_queue *q);
int event_is_queued(struct event *event); int event_is_queued(struct event *event);
#endif /* _DG_EVENT_H_ */

View file

@ -15,8 +15,8 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "dg_scripts.h"
#include "utils.h" #include "utils.h"
#include "dg_scripts.h"
#include "comm.h" #include "comm.h"
#include "db.h" #include "db.h"
#include "handler.h" #include "handler.h"

View file

@ -10,8 +10,8 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "dg_scripts.h"
#include "utils.h" #include "utils.h"
#include "dg_scripts.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "handler.h" #include "handler.h"
@ -20,14 +20,12 @@
#include "screen.h" #include "screen.h"
#include "spells.h" #include "spells.h"
#include "constants.h" #include "constants.h"
#include "fight.h"
void die(struct char_data *ch, struct char_data * killer);
/* copied from spell_parser.c: */ /* copied from spell_parser.c: */
#define SINFO spell_info[spellnum] #define SINFO spell_info[spellnum]
/* external vars */
extern struct spell_info_type spell_info[];
/* Cast a spell; can be called by mobiles, objects and rooms, and no level /* Cast a spell; can be called by mobiles, objects and rooms, and no level
* check is required. Note that mobs should generally use the normal 'cast' * check is required. Note that mobs should generally use the normal 'cast'

View file

@ -10,48 +10,26 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "screen.h" #include "screen.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "db.h" #include "db.h"
#include "utils.h"
#include "handler.h" #include "handler.h"
#include "interpreter.h" #include "interpreter.h"
#include "comm.h" #include "comm.h"
#include "spells.h" #include "spells.h"
#include "constants.h" #include "constants.h"
#include "genzon.h" /* for real_zone_by_thing */
#include "act.h"
#include "fight.h"
/* External functions */
bitvector_t asciiflag_conv(char *flag);
zone_rnum real_zone_by_thing(room_vnum vznum);
void die(struct char_data *ch, struct char_data *killer);
room_rnum find_target_room(struct char_data *ch, char *rawroomstr);
/* Local functions. */ /* Local file scope functions. */
void mob_log(char_data *mob, const char *format, ...); static void mob_log(char_data *mob, const char *format, ...);
ACMD(do_masound);
ACMD(do_mkill);
ACMD(do_mjunk);
ACMD(do_mechoaround);
ACMD(do_msend);
ACMD(do_mecho);
ACMD(do_mzoneecho);
ACMD(do_mload);
ACMD(do_mpurge);
ACMD(do_mgoto);
ACMD(do_mat);
ACMD(do_mteleport);
ACMD(do_mdamage);
ACMD(do_mforce);
ACMD(do_mhunt);
ACMD(do_mremember);
ACMD(do_mforget);
ACMD(do_mtransform);
ACMD(do_mdoor);
ACMD(do_mfollow);
ACMD(do_mrecho);
/* attaches mob's name and vnum to msg and sends it to script_log */ /* attaches mob's name and vnum to msg and sends it to script_log */
void mob_log(char_data *mob, const char *format, ...) static void mob_log(char_data *mob, const char *format, ...)
{ {
va_list args; va_list args;
char output[MAX_STRING_LENGTH]; char output[MAX_STRING_LENGTH];

View file

@ -18,33 +18,33 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "constants.h" #include "constants.h"
#include "genzon.h" /* for access to real_zone_by_thing */
#include "fight.h" /* for die() */
void die(struct char_data * ch, struct char_data *killer);
bitvector_t asciiflag_conv(char *flag);
zone_rnum real_zone_by_thing(room_vnum vznum);
/* Local functions */ /* Local functions */
#define OCMD(name) \ #define OCMD(name) \
void (name)(obj_data *obj, char *argument, int cmd, int subcmd) void (name)(obj_data *obj, char *argument, int cmd, int subcmd)
void obj_log(obj_data *obj, const char *format, ...); static void obj_log(obj_data *obj, const char *format, ...);
room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr); static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr);
OCMD(do_oecho); static OCMD(do_oecho);
OCMD(do_oforce); static OCMD(do_oforce);
OCMD(do_ozoneecho); static OCMD(do_ozoneecho);
OCMD(do_osend); static OCMD(do_osend);
OCMD(do_orecho); static OCMD(do_orecho);
OCMD(do_otimer); static OCMD(do_otimer);
OCMD(do_otransform); static OCMD(do_otransform);
OCMD(do_opurge); static OCMD(do_opurge);
OCMD(do_oteleport); static OCMD(do_oteleport);
OCMD(do_dgoload); static OCMD(do_dgoload);
OCMD(do_odamage); static OCMD(do_odamage);
OCMD(do_oasound); static OCMD(do_oasound);
OCMD(do_odoor); static OCMD(do_odoor);
OCMD(do_osetval); static OCMD(do_osetval);
OCMD(do_oat); static OCMD(do_oat);
void obj_command_interpreter(obj_data *obj, char *argument);
struct obj_command_info { struct obj_command_info {
char *command; char *command;
@ -57,7 +57,7 @@ struct obj_command_info {
#define SCMD_OECHOAROUND 1 #define SCMD_OECHOAROUND 1
/* attaches object name and vnum to msg and sends it to script_log */ /* attaches object name and vnum to msg and sends it to script_log */
void obj_log(obj_data *obj, const char *format, ...) static void obj_log(obj_data *obj, const char *format, ...)
{ {
va_list args; va_list args;
char output[MAX_STRING_LENGTH]; char output[MAX_STRING_LENGTH];
@ -85,7 +85,7 @@ room_rnum obj_room(obj_data *obj)
} }
/* returns the real room number, or NOWHERE if not found or invalid */ /* returns the real room number, or NOWHERE if not found or invalid */
room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr) static room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
{ {
int tmp; int tmp;
room_rnum location; room_rnum location;
@ -133,7 +133,7 @@ room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
} }
/* Object commands */ /* Object commands */
OCMD(do_oecho) static OCMD(do_oecho)
{ {
int room; int room;
@ -154,7 +154,7 @@ OCMD(do_oecho)
obj_log(obj, "oecho called by object in NOWHERE"); obj_log(obj, "oecho called by object in NOWHERE");
} }
OCMD(do_oforce) static OCMD(do_oforce)
{ {
char_data *ch, *next_ch; char_data *ch, *next_ch;
int room; int room;
@ -200,7 +200,7 @@ OCMD(do_oforce)
} }
} }
OCMD(do_ozoneecho) static OCMD(do_ozoneecho)
{ {
int zone; int zone;
char room_number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH], *msg; char room_number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH], *msg;
@ -220,7 +220,7 @@ OCMD(do_ozoneecho)
} }
} }
OCMD(do_osend) static OCMD(do_osend)
{ {
char buf[MAX_INPUT_LENGTH], *msg; char buf[MAX_INPUT_LENGTH], *msg;
char_data *ch; char_data *ch;
@ -255,7 +255,7 @@ OCMD(do_osend)
/* Prints the message to everyone in the range of numbers. Thanks to Jamie /* Prints the message to everyone in the range of numbers. Thanks to Jamie
* Nelson of 4D for this contribution. */ * Nelson of 4D for this contribution. */
OCMD(do_orecho) static OCMD(do_orecho)
{ {
char start[MAX_INPUT_LENGTH], finish[MAX_INPUT_LENGTH], *msg; char start[MAX_INPUT_LENGTH], finish[MAX_INPUT_LENGTH], *msg;
@ -271,7 +271,7 @@ OCMD(do_orecho)
} }
/* set the object's timer value */ /* set the object's timer value */
OCMD(do_otimer) static OCMD(do_otimer)
{ {
char arg[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH];
@ -287,7 +287,7 @@ OCMD(do_otimer)
/* Transform into a different object. Note: this shouldn't be used with /* Transform into a different object. Note: this shouldn't be used with
* containers unless both objects are containers! */ * containers unless both objects are containers! */
OCMD(do_otransform) static OCMD(do_otransform)
{ {
char arg[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH];
obj_data *o, tmpobj; obj_data *o, tmpobj;
@ -337,7 +337,7 @@ OCMD(do_otransform)
} }
/* purge all objects an npcs in room, or specified object or mob */ /* purge all objects an npcs in room, or specified object or mob */
OCMD(do_opurge) static OCMD(do_opurge)
{ {
char arg[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH];
char_data *ch, *next_ch; char_data *ch, *next_ch;
@ -386,7 +386,7 @@ OCMD(do_opurge)
extract_char(ch); extract_char(ch);
} }
OCMD(do_oteleport) static OCMD(do_oteleport)
{ {
char_data *ch, *next_ch; char_data *ch, *next_ch;
room_rnum target, rm; room_rnum target, rm;
@ -437,7 +437,7 @@ OCMD(do_oteleport)
} }
} }
OCMD(do_dgoload) static OCMD(do_dgoload)
{ {
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int number = 0, room; int number = 0, room;
@ -539,7 +539,7 @@ OCMD(do_dgoload)
} }
OCMD(do_odamage) { static OCMD(do_odamage) {
char name[MAX_INPUT_LENGTH], amount[MAX_INPUT_LENGTH]; char name[MAX_INPUT_LENGTH], amount[MAX_INPUT_LENGTH];
int dam = 0; int dam = 0;
char_data *ch; char_data *ch;
@ -562,7 +562,7 @@ OCMD(do_odamage) {
script_damage(ch, dam); script_damage(ch, dam);
} }
OCMD(do_oasound) static OCMD(do_oasound)
{ {
room_rnum room; room_rnum room;
int door; int door;
@ -590,7 +590,7 @@ OCMD(do_oasound)
} }
} }
OCMD(do_odoor) static OCMD(do_odoor)
{ {
char target[MAX_INPUT_LENGTH], direction[MAX_INPUT_LENGTH]; char target[MAX_INPUT_LENGTH], direction[MAX_INPUT_LENGTH];
char field[MAX_INPUT_LENGTH], *value; char field[MAX_INPUT_LENGTH], *value;
@ -682,7 +682,7 @@ OCMD(do_odoor)
} }
} }
OCMD(do_osetval) static OCMD(do_osetval)
{ {
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int position, new_value; int position, new_value;
@ -703,7 +703,7 @@ OCMD(do_osetval)
} }
/* Submitted by PurpleOnyx */ /* Submitted by PurpleOnyx */
OCMD(do_oat) static OCMD(do_oat)
{ {
room_rnum loc = NOWHERE; room_rnum loc = NOWHERE;
struct char_data *ch; struct char_data *ch;

View file

@ -18,20 +18,17 @@
#include "oasis.h" #include "oasis.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "dg_event.h" #include "dg_event.h"
#include "genzon.h" /* for real_zone_by_thing */
#include "constants.h" /* for the *trig_types */
#include "modify.h" /* for smash_tilde */
/* external functions */
extern const char *trig_types[], *otrig_types[], *wtrig_types[];
zone_rnum real_zone_by_thing(room_vnum vznum);
/* local functions */ /* local functions */
void trigedit_disp_menu(struct descriptor_data *d); static void trigedit_disp_menu(struct descriptor_data *d);
void trigedit_disp_types(struct descriptor_data *d); static void trigedit_disp_types(struct descriptor_data *d);
void trigedit_save(struct descriptor_data *d); static void trigedit_create_index(int znum, char *type);
void trigedit_create_index(int znum, char *type); static void trigedit_setup_new(struct descriptor_data *d);
void trigedit_string_cleanup(struct descriptor_data *d, int terminator);
int format_script(struct descriptor_data *d);
void trigedit_setup_existing(struct descriptor_data *d, int rtrg_num);
void trigedit_setup_new(struct descriptor_data *d);
/* Trigedit */ /* Trigedit */
ACMD(do_oasis_trigedit) ACMD(do_oasis_trigedit)
@ -130,7 +127,7 @@ void script_save_to_disk(FILE *fp, void *item, int type)
} }
} }
void trigedit_setup_new(struct descriptor_data *d) static void trigedit_setup_new(struct descriptor_data *d)
{ {
struct trig_data *trig; struct trig_data *trig;
@ -180,7 +177,7 @@ void trigedit_setup_existing(struct descriptor_data *d, int rtrg_num)
OLC_VAL(d) = 0; /* Has changed flag. (It hasn't so far, we just made it.) */ OLC_VAL(d) = 0; /* Has changed flag. (It hasn't so far, we just made it.) */
} }
void trigedit_disp_menu(struct descriptor_data *d) static void trigedit_disp_menu(struct descriptor_data *d)
{ {
struct trig_data *trig = OLC_TRIG(d); struct trig_data *trig = OLC_TRIG(d);
char *attach_type; char *attach_type;
@ -225,7 +222,7 @@ void trigedit_disp_menu(struct descriptor_data *d)
OLC_MODE(d) = TRIGEDIT_MAIN_MENU; OLC_MODE(d) = TRIGEDIT_MAIN_MENU;
} }
void trigedit_disp_types(struct descriptor_data *d) static void trigedit_disp_types(struct descriptor_data *d)
{ {
int i, columns = 0; int i, columns = 0;
const char **types; const char **types;
@ -637,7 +634,7 @@ void trigedit_save(struct descriptor_data *d)
trigedit_create_index(zone, "trg"); trigedit_create_index(zone, "trg");
} }
void trigedit_create_index(int znum, char *type) static void trigedit_create_index(int znum, char *type)
{ {
FILE *newfile, *oldfile; FILE *newfile, *oldfile;
char new_name[128], old_name[128], *prefix; char new_name[128], old_name[128], *prefix;

View file

@ -1,12 +1,18 @@
/************************************************************************** /**
* File: dg_olc.h Part of tbaMUD * * @file dg_olc.h
* * * This source file is used in extending Oasis OLC for trigedit.
* Usage: This source file is used in extending Oasis OLC for trigedit. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* $Author: Mark A. Heilpern/egreen/Welcor $ * * of, and continuation of, CircleMUD.
* $Date: 2004/10/11 12:07:00$ * *
* $Revision: 1.0.14 $ * * This source code, which was not part of the CircleMUD legacy code,
**************************************************************************/ * was created by the following people:
* $Author: Mark A. Heilpern/egreen/Welcor $
* $Date: 2004/10/11 12:07:00$
* $Revision: 1.0.14 $
*/
#ifndef _DG_OLC_H_
#define _DG_OLC_H_
#include "dg_scripts.h" #include "dg_scripts.h"
@ -39,3 +45,5 @@ void dg_olc_script_copy(struct descriptor_data *d);
void dg_script_menu(struct descriptor_data *d); void dg_script_menu(struct descriptor_data *d);
int dg_script_edit_parse(struct descriptor_data *d, char *arg); int dg_script_edit_parse(struct descriptor_data *d, char *arg);
#endif /* _DG_OLC_H_ */

View file

@ -1,11 +1,16 @@
/************************************************************************** /**
* File: dg_scripts.c Part of tbaMUD * * @file dg_scripts.c
* Usage: Contains the main script driver interface. * * Contains the main script driver interface.
* * *
* $Author: Mark A. Heilpern/egreen/Welcor $ * * Part of the core tbaMUD source code distribution, which is a derivative
* $Date: 2004/10/11 12:07:00$ * * of, and continuation of, CircleMUD.
* $Revision: 1.0.14 $ * *
**************************************************************************/ * This source code, which was not part of the CircleMUD legacy code,
* was created by the following people:
* $Author: Mark A. Heilpern/egreen/Welcor $
* $Date: 2004/10/11 12:07:00$
* $Revision: 1.0.14 $
*/
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
@ -21,71 +26,64 @@
#include "constants.h" #include "constants.h"
#include "spells.h" #include "spells.h"
#include "oasis.h" #include "oasis.h"
#include "genzon.h" /* for real_zone_by_thing */
#include "act.h"
#include "modify.h"
#define PULSES_PER_MUD_HOUR (SECS_PER_MUD_HOUR*PASSES_PER_SEC) #define PULSES_PER_MUD_HOUR (SECS_PER_MUD_HOUR*PASSES_PER_SEC)
/* external vars */
extern unsigned long pulse;
extern struct spell_info_type spell_info[];
extern struct time_info_data time_info;
/* external functions */
int is_empty(zone_rnum zone_nr);
room_rnum find_target_room(struct char_data *ch, char *rawroomstr);
zone_rnum real_zone_by_thing(room_vnum vznum);
/* Local functions not used elsewhere */ /* Local functions not used elsewhere */
obj_data *find_obj(long n); static obj_data *find_obj(long n);
room_data *find_room(long n); static room_data *find_room(long n);
void do_stat_trigger(struct char_data *ch, trig_data *trig); static void do_stat_trigger(struct char_data *ch, trig_data *trig);
void script_stat (char_data *ch, struct script_data *sc); static void script_stat(char_data *ch, struct script_data *sc);
int remove_trigger(struct script_data *sc, char *name); static int remove_trigger(struct script_data *sc, char *name);
int is_num(char *arg); static int is_num(char *arg);
void eval_op(char *op, char *lhs, char *rhs, char *result, void *go, static void eval_op(char *op, char *lhs, char *rhs, char *result, void *go,
struct script_data *sc, trig_data *trig); struct script_data *sc, trig_data *trig);
char *matching_paren(char *p); static char *matching_paren(char *p);
void eval_expr(char *line, char *result, void *go, struct script_data *sc, static void eval_expr(char *line, char *result, void *go, struct script_data *sc,
trig_data *trig, int type); trig_data *trig, int type);
int eval_lhs_op_rhs(char *expr, char *result, void *go, struct script_data *sc, static int eval_lhs_op_rhs(char *expr, char *result, void *go, struct script_data *sc,
trig_data *trig, int type); trig_data *trig, int type);
int process_if(char *cond, void *go, struct script_data *sc, static int process_if(char *cond, void *go, struct script_data *sc,
trig_data *trig, int type); trig_data *trig, int type);
struct cmdlist_element *find_end(trig_data *trig, struct cmdlist_element *cl); static struct cmdlist_element *find_end(trig_data *trig, struct cmdlist_element *cl);
struct cmdlist_element *find_else_end(trig_data *trig, static struct cmdlist_element *find_else_end(trig_data *trig,
struct cmdlist_element *cl, void *go, struct cmdlist_element *cl, void *go, struct script_data *sc, int type);
struct script_data *sc, int type); static void process_wait(void *go, trig_data *trig, int type, char *cmd,
void process_wait(void *go, trig_data *trig, int type, char *cmd, struct cmdlist_element *cl);
struct cmdlist_element *cl); static void process_set(struct script_data *sc, trig_data *trig, char *cmd);
void process_set(struct script_data *sc, trig_data *trig, char *cmd); static void process_attach(void *go, struct script_data *sc, trig_data *trig,
void process_attach(void *go, struct script_data *sc, trig_data *trig, int type, char *cmd);
int type, char *cmd); static void process_detach(void *go, struct script_data *sc, trig_data *trig,
void process_detach(void *go, struct script_data *sc, trig_data *trig, int type, char *cmd);
int type, char *cmd); static void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
void makeuid_var(void *go, struct script_data *sc, trig_data *trig, int type, char *cmd);
int type, char *cmd); static int process_return(trig_data *trig, char *cmd);
int process_return(trig_data *trig, char *cmd); static void process_unset(struct script_data *sc, trig_data *trig, char *cmd);
void process_unset(struct script_data *sc, trig_data *trig, char *cmd); static void process_remote(struct script_data *sc, trig_data *trig, char *cmd);
void process_remote(struct script_data *sc, trig_data *trig, char *cmd); static void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd);
void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd); static void process_global(struct script_data *sc, trig_data *trig, char *cmd, long id);
void process_global(struct script_data *sc, trig_data *trig, char *cmd, long id); static void process_context(struct script_data *sc, trig_data *trig, char *cmd);
void process_context(struct script_data *sc, trig_data *trig, char *cmd); static void extract_value(struct script_data *sc, trig_data *trig, char *cmd);
void extract_value(struct script_data *sc, trig_data *trig, char *cmd); static void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd);
void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd); static struct cmdlist_element * find_case(struct trig_data *trig, struct cmdlist_element *cl,
struct cmdlist_element *
find_case(struct trig_data *trig, struct cmdlist_element *cl,
void *go, struct script_data *sc, int type, char *cond); void *go, struct script_data *sc, int type, char *cond);
struct cmdlist_element *find_done(struct cmdlist_element *cl); static struct cmdlist_element *find_done(struct cmdlist_element *cl);
int fgetline(FILE *file, char *p); static struct char_data *find_char_by_uid_in_lookup_table(long uid);
struct char_data *find_char_by_uid_in_lookup_table(long uid); static struct obj_data *find_obj_by_uid_in_lookup_table(long uid);
struct obj_data *find_obj_by_uid_in_lookup_table(long uid); static EVENTFUNC(trig_wait_event);
EVENTFUNC(trig_wait_event);
ACMD(do_attach) ;
ACMD(do_detach);
ACMD(do_vdelete);
ACMD(do_tstat);
/* Return pointer to first occurrence of string ct in cs, or NULL if not /* Return pointer to first occurrence of string ct in cs, or NULL if not
* present. Case insensitive */ * present. Case insensitive. All of ct must be found in cs for it to be
* a match.
* @todo Move this function to string util library.
* @param cs The string to search.
* @param ct What to search for in cs.
* @retval char * NULL if ct is not a substring of cs, or pointer to the
* location in cs where substring ct begins. */
char *str_str(char *cs, char *ct) char *str_str(char *cs, char *ct)
{ {
char *s, *t; char *s, *t;
@ -106,6 +104,8 @@ char *str_str(char *cs, char *ct)
cs++; cs++;
} }
/* If there we haven reached the end of ct via t,
* then the whole string was found. */
if (!*t) if (!*t)
return s; return s;
} }
@ -113,7 +113,12 @@ char *str_str(char *cs, char *ct)
return NULL; return NULL;
} }
int trgvar_in_room(room_vnum vnum) { /** Returns the number of people in a room.
* @param vnum The virtual number of a room.
* @retval int Returns -1 if the room does not exist, or the total number of
* PCs and NPCs in the room. */
int trgvar_in_room(room_vnum vnum)
{
room_rnum rnum = real_room(vnum); room_rnum rnum = real_room(vnum);
int i = 0; int i = 0;
char_data *ch; char_data *ch;
@ -129,6 +134,14 @@ int trgvar_in_room(room_vnum vnum) {
return i; return i;
} }
/** Find out if an object is within a list of objects.
* @param name Either the unique id of an object or a string identifying the
* object. Note the unique id must be prefixed with UID_CHAR.
* @param list The list of objects to look through.
* @retval obj_data * Pointer to the object if it is found in the list of
* objects, NULL if the object is not found in the list.
*/
obj_data *get_obj_in_list(char *name, obj_data *list) obj_data *get_obj_in_list(char *name, obj_data *list)
{ {
obj_data *i; obj_data *i;
@ -140,6 +153,7 @@ obj_data *get_obj_in_list(char *name, obj_data *list)
for (i = list; i; i = i->next_content) for (i = list; i; i = i->next_content)
if (id == GET_ID(i)) if (id == GET_ID(i))
return i; return i;
} else { } else {
for (i = list; i; i = i->next_content) for (i = list; i; i = i->next_content)
if (isname(name, i->name)) if (isname(name, i->name))
@ -149,6 +163,13 @@ obj_data *get_obj_in_list(char *name, obj_data *list)
return NULL; return NULL;
} }
/** Find out if an NPC or PC is carrying an object.
* @param ch Pointer to the NPC/PC to search through.
* @param name String describing either the name of the object or the unique
* id of the object. Note the unique id must be prefixed with UID_CHAR.
* @retval obj_data * Either a pointer to the first object found that matches
* the name argument, or the NULL if the object isn't found.
*/
obj_data *get_object_in_equip(char_data * ch, char *name) obj_data *get_object_in_equip(char_data * ch, char *name)
{ {
int j, n = 0, number; int j, n = 0, number;
@ -185,8 +206,14 @@ obj_data *get_object_in_equip(char_data * ch, char *name)
return NULL; return NULL;
} }
/* Handles 'held', 'light' and 'wield' positions - Welcor. After idea from /** Figures out if the argument is a valid location to 'wear' equipment.
* Byron Ellacott. */ * Handles 'held', 'light' and 'wield' positions - Welcor. After idea from
* Byron Ellacott.
* @param arg Either the name of the position, or the number of a wear
* location definition to check for.
* @retval int If arg is not a valid wear location name or number, return
* -1, else return the defined number of the wear location.
*/
int find_eq_pos_script(char *arg) int find_eq_pos_script(char *arg)
{ {
int i; int i;
@ -226,6 +253,11 @@ int find_eq_pos_script(char *arg)
return (-1); return (-1);
} }
/** Figures out if an object can be worn on a defined wear location.
* @param obj The object to check.
* @param pos The defined wear location to check.
* @retval int TRUE if obj can be worn on pos, FALSE if not.
*/
int can_wear_on_pos(struct obj_data *obj, int pos) int can_wear_on_pos(struct obj_data *obj, int pos)
{ {
switch (pos) { switch (pos) {
@ -251,7 +283,11 @@ int can_wear_on_pos(struct obj_data *obj, int pos)
} }
} }
/* Search by number routines. Return char with UID n. */ /** Search for an NPC or PC by number routines.
* @param n The unique ID (PC or NPC) to look for.
* @retval char_data * Pointer to the character structure if it exists, or NULL
* if it cannot be found.
*/
struct char_data *find_char(long n) struct char_data *find_char(long n)
{ {
if (n>=ROOM_ID_BASE) /* See note in dg_scripts.h */ if (n>=ROOM_ID_BASE) /* See note in dg_scripts.h */
@ -260,8 +296,12 @@ struct char_data *find_char(long n)
return find_char_by_uid_in_lookup_table(n); return find_char_by_uid_in_lookup_table(n);
} }
/* return object with UID n */ /** Search for an object by number routines.
obj_data *find_obj(long n) * @param n The unique ID to look for.
* @retval obj_data * Pointer to the object if it exists, or NULL if it cannot
* be found.
*/
static obj_data *find_obj(long n)
{ {
if (n < OBJ_ID_BASE) /* see note in dg_scripts.h */ if (n < OBJ_ID_BASE) /* see note in dg_scripts.h */
return NULL; return NULL;
@ -269,8 +309,12 @@ obj_data *find_obj(long n)
return find_obj_by_uid_in_lookup_table(n); return find_obj_by_uid_in_lookup_table(n);
} }
/* return room with UID n */ /* Search for a room with UID n.
room_data *find_room(long n) * @param n the Unique ID to look for.
* @retval room_data * Pointer to the room if it exists, or NULL if it cannot
* be found.
*/
static room_data *find_room(long n)
{ {
room_rnum rnum; room_rnum rnum;
@ -286,7 +330,10 @@ room_data *find_room(long n)
} }
/* Generic searches based only on name. */ /* Generic searches based only on name. */
/* search the entire world for a char, and return a pointer */ /** Search the entire world for an NPC or PC by name.
* @param name String describing the name or the unique id of the char.
* Note the unique id must be prefixed with UID_CHAR.
* @retval char_data * Pointer to the char or NULL if char is not found. */
char_data *get_char(char *name) char_data *get_char(char *name)
{ {
char_data *i; char_data *i;
@ -306,7 +353,15 @@ char_data *get_char(char *name)
return NULL; return NULL;
} }
/* Finds a char in the same room as the object with the name 'name.' */ /** Find a character by name in the same room as a known object.
* @todo Should this function not be constrained to the same room as an object
* if 'name' is a unique id?
* @param obj An object that will constrain the search to the location that
* the object is in *if* the name argument is not a unique id.
* @param name Character name keyword to search for, or unique ID. Unique
* id must be prefixed with UID_CHAR.
* @retval char_data * Pointer to the the char if found, NULL if not. Will
* only find god characters if DG_ALLOW_GODS is on. */
char_data *get_char_near_obj(obj_data *obj, char *name) char_data *get_char_near_obj(obj_data *obj, char *name)
{ {
char_data *ch; char_data *ch;
@ -328,8 +383,15 @@ char_data *get_char_near_obj(obj_data *obj, char *name)
return NULL; return NULL;
} }
/* Returns a pointer to the first character in world by name name, or NULL if /** Find a character by name in a specific room.
* none found. Starts searching in room room first. */ * @todo Should this function not be constrained to the room
* if 'name' is a unique id?
* @param room A room that will constrain the search to that location
* *if* the name argument is not a unique id.
* @param name Character name keyword to search for, or unique ID. Unique
* id must be prefixed with UID_CHAR.
* @retval char_data * Pointer to the the char if found, NULL if not. Will
* only find god characters if DG_ALLOW_GODS is on. */
char_data *get_char_in_room(room_data *room, char *name) char_data *get_char_in_room(room_data *room, char *name)
{ {
char_data *ch; char_data *ch;
@ -349,7 +411,13 @@ char_data *get_char_in_room(room_data *room, char *name)
return NULL; return NULL;
} }
/* searches the room with the object for an object with name 'name'*/ /** Find a named object near another object (either in the same room, as
* a container or contained by).
* @param obj The obj with which to constrain the search.
* @param name The keyword of the object to search for. If 'self' or 'me'
* are passed in as arguments, obj is returned. Can also be a unique object
* id, and if so it must be prefixed with UID_CHAR.
* @retval obj_data * Pointer to the object if found, NULL if not. */
obj_data *get_obj_near_obj(obj_data *obj, char *name) obj_data *get_obj_near_obj(obj_data *obj, char *name)
{ {
obj_data *i = NULL; obj_data *i = NULL;
@ -635,7 +703,7 @@ void check_time_triggers(void)
} }
} }
EVENTFUNC(trig_wait_event) static EVENTFUNC(trig_wait_event)
{ {
struct wait_event_data *wait_event_obj = (struct wait_event_data *)event_obj; struct wait_event_data *wait_event_obj = (struct wait_event_data *)event_obj;
trig_data *trig; trig_data *trig;
@ -684,7 +752,7 @@ EVENTFUNC(trig_wait_event)
return 0; return 0;
} }
void do_stat_trigger(struct char_data *ch, trig_data *trig) static void do_stat_trigger(struct char_data *ch, trig_data *trig)
{ {
struct cmdlist_element *cmd_list; struct cmdlist_element *cmd_list;
char sb[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH]; char sb[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];
@ -749,7 +817,7 @@ void find_uid_name(char *uid, char *name, size_t nlen)
} }
/* general function to display stats on script sc */ /* general function to display stats on script sc */
void script_stat (char_data *ch, struct script_data *sc) static void script_stat (char_data *ch, struct script_data *sc)
{ {
struct trig_var_data *tv; struct trig_var_data *tv;
trig_data *t; trig_data *t;
@ -1009,7 +1077,7 @@ ACMD(do_attach)
* trigger, otherwise 1. If it matters, you might need to check to see if all * trigger, otherwise 1. If it matters, you might need to check to see if all
* the triggers were removed after this function returns, in order to remove * the triggers were removed after this function returns, in order to remove
* the script. */ * the script. */
int remove_trigger(struct script_data *sc, char *name) static int remove_trigger(struct script_data *sc, char *name)
{ {
trig_data *i, *j; trig_data *i, *j;
int num = 0, string = FALSE, n; int num = 0, string = FALSE, n;
@ -1256,7 +1324,7 @@ void script_log(const char *format, ...)
/* Returns 1 if string is all digits, else 0. Bugfixed - would have returned /* Returns 1 if string is all digits, else 0. Bugfixed - would have returned
* true on num="------". */ * true on num="------". */
int is_num(char *arg) static int is_num(char *arg)
{ {
if (*arg == '\0') if (*arg == '\0')
return FALSE; return FALSE;
@ -1274,7 +1342,7 @@ int is_num(char *arg)
} }
/* evaluates 'lhs op rhs', and copies to result */ /* evaluates 'lhs op rhs', and copies to result */
void eval_op(char *op, char *lhs, char *rhs, char *result, void *go, static void eval_op(char *op, char *lhs, char *rhs, char *result, void *go,
struct script_data *sc, trig_data *trig) struct script_data *sc, trig_data *trig)
{ {
unsigned char *p; unsigned char *p;
@ -1389,7 +1457,7 @@ char *matching_quote(char *p)
/* p points to the first paren. returns a pointer to the matching closing /* p points to the first paren. returns a pointer to the matching closing
* paren, or the last non-null char in p. */ * paren, or the last non-null char in p. */
char *matching_paren(char *p) static char *matching_paren(char *p)
{ {
int i; int i;
@ -1406,7 +1474,7 @@ char *matching_paren(char *p)
} }
/* evaluates line, and returns answer in result */ /* evaluates line, and returns answer in result */
void eval_expr(char *line, char *result, void *go, struct script_data *sc, static void eval_expr(char *line, char *result, void *go, struct script_data *sc,
trig_data *trig, int type) trig_data *trig, int type)
{ {
char expr[MAX_INPUT_LENGTH], *p; char expr[MAX_INPUT_LENGTH], *p;
@ -1429,7 +1497,7 @@ void eval_expr(char *line, char *result, void *go, struct script_data *sc,
/* Evaluates expr if it is in the form lhs op rhs, and copies answer in result. /* Evaluates expr if it is in the form lhs op rhs, and copies answer in result.
* Returns 1 if expr is evaluated, else 0. */ * Returns 1 if expr is evaluated, else 0. */
int eval_lhs_op_rhs(char *expr, char *result, void *go, struct script_data *sc, static int eval_lhs_op_rhs(char *expr, char *result, void *go, struct script_data *sc,
trig_data *trig, int type) trig_data *trig, int type)
{ {
char *p, *tokens[MAX_INPUT_LENGTH]; char *p, *tokens[MAX_INPUT_LENGTH];
@ -1492,7 +1560,7 @@ int eval_lhs_op_rhs(char *expr, char *result, void *go, struct script_data *sc,
} }
/* returns 1 if cond is true, else 0 */ /* returns 1 if cond is true, else 0 */
int process_if(char *cond, void *go, struct script_data *sc, static int process_if(char *cond, void *go, struct script_data *sc,
trig_data *trig, int type) trig_data *trig, int type)
{ {
char result[MAX_INPUT_LENGTH], *p; char result[MAX_INPUT_LENGTH], *p;
@ -1510,7 +1578,7 @@ int process_if(char *cond, void *go, struct script_data *sc,
/* Scans for end of if-block. returns the line containg 'end', or the last /* Scans for end of if-block. returns the line containg 'end', or the last
* line of the trigger if not found. */ * line of the trigger if not found. */
struct cmdlist_element *find_end(trig_data *trig, struct cmdlist_element *cl) static struct cmdlist_element *find_end(trig_data *trig, struct cmdlist_element *cl)
{ {
struct cmdlist_element *c; struct cmdlist_element *c;
char *p; char *p;
@ -1542,7 +1610,7 @@ struct cmdlist_element *find_end(trig_data *trig, struct cmdlist_element *cl)
/* Searches for valid elseif, else, or end to continue execution at. Returns /* Searches for valid elseif, else, or end to continue execution at. Returns
* line of elseif, else, or end if found, or last line of trigger. */ * line of elseif, else, or end if found, or last line of trigger. */
struct cmdlist_element *find_else_end(trig_data *trig, static struct cmdlist_element *find_else_end(trig_data *trig,
struct cmdlist_element *cl, void *go, struct script_data *sc, int type) struct cmdlist_element *cl, void *go, struct script_data *sc, int type)
{ {
struct cmdlist_element *c; struct cmdlist_element *c;
@ -1587,7 +1655,7 @@ struct cmdlist_element *find_else_end(trig_data *trig,
} }
/* processes any 'wait' commands in a trigger */ /* processes any 'wait' commands in a trigger */
void process_wait(void *go, trig_data *trig, int type, char *cmd, static void process_wait(void *go, trig_data *trig, int type, char *cmd,
struct cmdlist_element *cl) struct cmdlist_element *cl)
{ {
char buf[MAX_INPUT_LENGTH], *arg; char buf[MAX_INPUT_LENGTH], *arg;
@ -1644,7 +1712,7 @@ void process_wait(void *go, trig_data *trig, int type, char *cmd,
} }
/* processes a script set command */ /* processes a script set command */
void process_set(struct script_data *sc, trig_data *trig, char *cmd) static void process_set(struct script_data *sc, trig_data *trig, char *cmd)
{ {
char arg[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH], *value; char arg[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH], *value;
@ -1685,7 +1753,7 @@ void process_eval(void *go, struct script_data *sc, trig_data *trig,
} }
/* script attaching a trigger to something */ /* script attaching a trigger to something */
void process_attach(void *go, struct script_data *sc, trig_data *trig, static void process_attach(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd) int type, char *cmd)
{ {
char arg[MAX_INPUT_LENGTH], trignum_s[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH], trignum_s[MAX_INPUT_LENGTH];
@ -1767,7 +1835,7 @@ void process_attach(void *go, struct script_data *sc, trig_data *trig,
} }
/* script detaching a trigger from something */ /* script detaching a trigger from something */
void process_detach(void *go, struct script_data *sc, trig_data *trig, static void process_detach(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd) int type, char *cmd)
{ {
char arg[MAX_INPUT_LENGTH], trignum_s[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH], trignum_s[MAX_INPUT_LENGTH];
@ -1864,7 +1932,7 @@ struct room_data *dg_room_of_obj(struct obj_data *obj)
} }
/* create a UID variable from the id number */ /* create a UID variable from the id number */
void makeuid_var(void *go, struct script_data *sc, trig_data *trig, static void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd) int type, char *cmd)
{ {
char junk[MAX_INPUT_LENGTH], varname[MAX_INPUT_LENGTH]; char junk[MAX_INPUT_LENGTH], varname[MAX_INPUT_LENGTH];
@ -1963,7 +2031,7 @@ void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
/* Processes a script return command. Returns the new value for the script to /* Processes a script return command. Returns the new value for the script to
* return. */ * return. */
int process_return(trig_data *trig, char *cmd) static int process_return(trig_data *trig, char *cmd)
{ {
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
@ -1981,7 +2049,7 @@ int process_return(trig_data *trig, char *cmd)
/* Removes a variable from the global vars of sc, or the local vars of trig if /* Removes a variable from the global vars of sc, or the local vars of trig if
* not found in global list. */ * not found in global list. */
void process_unset(struct script_data *sc, trig_data *trig, char *cmd) static void process_unset(struct script_data *sc, trig_data *trig, char *cmd)
{ {
char arg[MAX_INPUT_LENGTH], *var; char arg[MAX_INPUT_LENGTH], *var;
@ -2001,7 +2069,7 @@ void process_unset(struct script_data *sc, trig_data *trig, char *cmd)
/* Copy a locally owned variable to the globals of another script. /* Copy a locally owned variable to the globals of another script.
* 'remote <variable_name> <uid>' */ * 'remote <variable_name> <uid>' */
void process_remote(struct script_data *sc, trig_data *trig, char *cmd) static void process_remote(struct script_data *sc, trig_data *trig, char *cmd)
{ {
struct trig_var_data *vd; struct trig_var_data *vd;
struct script_data *sc_remote=NULL; struct script_data *sc_remote=NULL;
@ -2182,7 +2250,7 @@ int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_a
/* Delete a variable from the globals of another script. /* Delete a variable from the globals of another script.
* 'rdelete <variable_name> <uid>' */ * 'rdelete <variable_name> <uid>' */
void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd) static void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd)
{ {
struct trig_var_data *vd, *vd_prev=NULL; struct trig_var_data *vd, *vd_prev=NULL;
struct script_data *sc_remote=NULL; struct script_data *sc_remote=NULL;
@ -2249,7 +2317,7 @@ void process_rdelete(struct script_data *sc, trig_data *trig, char *cmd)
} }
/* Makes a local variable into a global variable. */ /* Makes a local variable into a global variable. */
void process_global(struct script_data *sc, trig_data *trig, char *cmd, long id) static void process_global(struct script_data *sc, trig_data *trig, char *cmd, long id)
{ {
struct trig_var_data *vd; struct trig_var_data *vd;
char arg[MAX_INPUT_LENGTH], *var; char arg[MAX_INPUT_LENGTH], *var;
@ -2279,7 +2347,7 @@ void process_global(struct script_data *sc, trig_data *trig, char *cmd, long id)
} }
/* set the current context for a script */ /* set the current context for a script */
void process_context(struct script_data *sc, trig_data *trig, char *cmd) static void process_context(struct script_data *sc, trig_data *trig, char *cmd)
{ {
char arg[MAX_INPUT_LENGTH], *var; char arg[MAX_INPUT_LENGTH], *var;
@ -2296,7 +2364,7 @@ void process_context(struct script_data *sc, trig_data *trig, char *cmd)
sc->context = atol(var); sc->context = atol(var);
} }
void extract_value(struct script_data *sc, trig_data *trig, char *cmd) static void extract_value(struct script_data *sc, trig_data *trig, char *cmd)
{ {
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH]; char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
char *buf3; char *buf3;
@ -2331,7 +2399,7 @@ void extract_value(struct script_data *sc, trig_data *trig, char *cmd)
* dg_letter var2 11 %string% * dg_letter var2 11 %string%
* now %var1% == 7 and %var2% == g * now %var1% == 7 and %var2% == g
* Note that the index starts at 1. */ * Note that the index starts at 1. */
void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd) static void dg_letter_value(struct script_data *sc, trig_data *trig, char *cmd)
{ {
/* Set the letter/number at position 'num' as the variable. */ /* Set the letter/number at position 'num' as the variable. */
char junk[MAX_INPUT_LENGTH]; char junk[MAX_INPUT_LENGTH];
@ -2667,7 +2735,7 @@ ACMD(do_tstat)
/* Scans for a case/default instance. Returns the line containg the correct /* Scans for a case/default instance. Returns the line containg the correct
* case instance, or the last line of the trigger if not found. */ * case instance, or the last line of the trigger if not found. */
struct cmdlist_element * static struct cmdlist_element *
find_case(struct trig_data *trig, struct cmdlist_element *cl, find_case(struct trig_data *trig, struct cmdlist_element *cl,
void *go, struct script_data *sc, int type, char *cond) void *go, struct script_data *sc, int type, char *cond)
{ {
@ -2704,7 +2772,7 @@ find_case(struct trig_data *trig, struct cmdlist_element *cl,
/* Scans for end of while/switch-blocks. Returns the line containg 'end', or /* Scans for end of while/switch-blocks. Returns the line containg 'end', or
* the last line of the trigger if not found. Malformed scripts may cause NULL * the last line of the trigger if not found. Malformed scripts may cause NULL
* to be returned. */ * to be returned. */
struct cmdlist_element *find_done(struct cmdlist_element *cl) static struct cmdlist_element *find_done(struct cmdlist_element *cl)
{ {
struct cmdlist_element *c; struct cmdlist_element *c;
char *p; char *p;
@ -2724,23 +2792,6 @@ struct cmdlist_element *find_done(struct cmdlist_element *cl)
return c; return c;
} }
/* read a line in from a file, return the number of chars read */
int fgetline(FILE *file, char *p)
{
int count = 0;
do {
*p = fgetc(file);
if (*p != '\n' && !feof(file)) {
p++;
count++;
}
} while (*p != '\n' && !feof(file));
if (*p == '\n') *p = '\0';
return count;
}
/* load in a character's saved variables */ /* load in a character's saved variables */
void read_saved_vars(struct char_data *ch) void read_saved_vars(struct char_data *ch)
@ -2916,7 +2967,7 @@ void init_lookup_table(void)
} }
} }
struct char_data *find_char_by_uid_in_lookup_table(long uid) static struct char_data *find_char_by_uid_in_lookup_table(long uid)
{ {
int bucket = (int) (uid & (BUCKET_COUNT - 1)); int bucket = (int) (uid & (BUCKET_COUNT - 1));
struct lookup_table_t *lt = &lookup_table[bucket]; struct lookup_table_t *lt = &lookup_table[bucket];
@ -2930,7 +2981,7 @@ struct char_data *find_char_by_uid_in_lookup_table(long uid)
return NULL; return NULL;
} }
struct obj_data *find_obj_by_uid_in_lookup_table(long uid) static struct obj_data *find_obj_by_uid_in_lookup_table(long uid)
{ {
int bucket = (int) (uid & (BUCKET_COUNT - 1)); int bucket = (int) (uid & (BUCKET_COUNT - 1));
struct lookup_table_t *lt = &lookup_table[bucket]; struct lookup_table_t *lt = &lookup_table[bucket];

View file

@ -1,13 +1,21 @@
/************************************************************************** /**
* File: dg_scripts.h Part of tbaMUD * * @file dg_scripts.h
* * * Header file for script structures, constants, and function prototypes for
* Usage: header file for script structures, constants, and function * * dg_scripts.c
* prototypes for dg_scripts.c * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* $Author: Mark A. Heilpern/egreen/Welcor $ * * of, and continuation of, CircleMUD.
* $Date: 2004/10/11 12:07:00$ * *
* $Revision: 1.0.14 $ * * This source code, which was not part of the CircleMUD legacy code,
**************************************************************************/ * was created by the following people:
* $Author: Mark A. Heilpern/egreen/Welcor $
* $Date: 2004/10/11 12:07:00$
* $Revision: 1.0.14 $
*/
#ifndef _DG_SCRIPTS_H_
#define _DG_SCRIPTS_H_
#include "utils.h" /* To make sure ACMD is defined */
#define DG_SCRIPT_VERSION "DG Scripts 1.0.14" #define DG_SCRIPT_VERSION "DG Scripts 1.0.14"
@ -138,36 +146,36 @@ struct trig_var_data {
struct trig_var_data *next; struct trig_var_data *next;
}; };
/* structure for triggers */ /** structure for triggers */
struct trig_data { struct trig_data {
IDXTYPE nr; /* trigger's rnum */ IDXTYPE nr; /**< trigger's rnum */
byte attach_type; /* mob/obj/wld intentions */ byte attach_type; /**< mob/obj/wld intentions */
byte data_type; /* type of game_data for trig */ byte data_type; /**< type of game_data for trig */
char *name; /* name of trigger */ char *name; /**< name of trigger */
long trigger_type; /* type of trigger (for bitvector) */ long trigger_type; /**< type of trigger (for bitvector) */
struct cmdlist_element *cmdlist; /* top of command list */ struct cmdlist_element *cmdlist; /**< top of command list */
struct cmdlist_element *curr_state; /* ptr to current line of trigger */ struct cmdlist_element *curr_state; /**< ptr to current line of trigger */
int narg; /* numerical argument */ int narg; /**< numerical argument */
char *arglist; /* argument list */ char *arglist; /**< argument list */
int depth; /* depth into nest ifs/whiles/etc */ int depth; /**< depth into nest ifs/whiles/etc */
int loops; /* loop iteration counter */ int loops; /**< loop iteration counter */
struct event *wait_event; /* event to pause the trigger */ struct event *wait_event; /**< event to pause the trigger */
ubyte purged; /* trigger is set to be purged */ ubyte purged; /**< trigger is set to be purged */
struct trig_var_data *var_list; /* list of local vars for trigger */ struct trig_var_data *var_list; /**< list of local vars for trigger */
struct trig_data *next; struct trig_data *next;
struct trig_data *next_in_world; /* next in the global trigger list */ struct trig_data *next_in_world; /**< next in the global trigger list */
}; };
/* a complete script (composed of several triggers) */ /** a complete script (composed of several triggers) */
struct script_data { struct script_data {
long types; /* bitvector of trigger types */ long types; /**< bitvector of trigger types */
struct trig_data *trig_list; /* list of triggers */ struct trig_data *trig_list; /**< list of triggers */
struct trig_var_data *global_vars; /* list of global variables */ struct trig_var_data *global_vars; /**< list of global variables */
ubyte purged; /* script is set to be purged */ ubyte purged; /**< script is set to be purged */
long context; /* current context for statics */ long context; /**< current context for statics */
struct script_data *next; /* used for purged_scripts */ struct script_data *next; /**< used for purged_scripts */
}; };
/* The event data for the wait command */ /* The event data for the wait command */
@ -177,6 +185,13 @@ struct wait_event_data {
int type; int type;
}; };
/* used for actor memory triggers */
struct script_memory {
long id; /* id of who to remember */
char *cmd; /* command, or NULL for generic */
struct script_memory *next;
};
/* typedefs that the dg functions rely on */ /* typedefs that the dg functions rely on */
typedef struct index_data index_data; typedef struct index_data index_data;
typedef struct room_data room_data; typedef struct room_data room_data;
@ -184,12 +199,6 @@ typedef struct obj_data obj_data;
typedef struct trig_data trig_data; typedef struct trig_data trig_data;
typedef struct char_data char_data; typedef struct char_data char_data;
/* used for actor memory triggers */
struct script_memory {
long id; /* id of who to remember */
char *cmd; /* command, or NULL for generic */
struct script_memory *next;
};
/* function prototypes from dg_triggers.c */ /* function prototypes from dg_triggers.c */
char *one_phrase(char *arg, char *first_arg); char *one_phrase(char *arg, char *first_arg);
@ -254,6 +263,10 @@ void time_otrigger(obj_data *obj);
void time_wtrigger(room_data *room); void time_wtrigger(room_data *room);
/* function prototypes from dg_scripts.c */ /* function prototypes from dg_scripts.c */
ACMD(do_attach) ;
ACMD(do_detach);
ACMD(do_vdelete);
ACMD(do_tstat);
char *str_str(char *cs, char *ct); char *str_str(char *cs, char *ct);
int find_eq_pos_script(char *arg); int find_eq_pos_script(char *arg);
int can_wear_on_pos(struct obj_data *obj, int pos); int can_wear_on_pos(struct obj_data *obj, int pos);
@ -283,6 +296,10 @@ void script_vlog(const char *format, va_list args);
void script_log(const char *format, ...) __attribute__ ((format (printf, 1, 2))); void script_log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
char *matching_quote(char *p); char *matching_quote(char *p);
struct room_data *dg_room_of_obj(struct obj_data *obj); struct room_data *dg_room_of_obj(struct obj_data *obj);
bool check_flags_by_name_ar(int *array, int numflags, char *search, const char *namelist[]);
void read_saved_vars_ascii(FILE *file, struct char_data *ch, int count);
void save_char_vars_ascii(FILE *file, struct char_data *ch);
int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_arg);
/* To maintain strict-aliasing we'll have to do this trick with a union */ /* To maintain strict-aliasing we'll have to do this trick with a union */
/* Thanks to Chris Gilbert for reminding me that there are other options. */ /* Thanks to Chris Gilbert for reminding me that there are other options. */
@ -343,8 +360,41 @@ void send_char_pos(struct char_data *ch, int dam);
int valid_dg_target(char_data *ch, int bitvector); int valid_dg_target(char_data *ch, int bitvector);
void script_damage(char_data *vict, int dam); void script_damage(char_data *vict, int dam);
/* from dg_mobcmd.c */
ACMD(do_masound);
ACMD(do_mat);
ACMD(do_mdamage);
ACMD(do_mdoor);
ACMD(do_mecho);
ACMD(do_mechoaround);
ACMD(do_mfollow);
ACMD(do_mforce);
ACMD(do_mforget);
ACMD(do_mgoto);
ACMD(do_mhunt);
ACMD(do_mjunk);
ACMD(do_mkill);
ACMD(do_mload);
ACMD(do_mpurge);
ACMD(do_mrecho);
ACMD(do_mremember);
ACMD(do_msend);
ACMD(do_mteleport);
ACMD(do_mtransform);
ACMD(do_mzoneecho);
/* from dg_olc.c... thinking these should be moved to oasis.h */
void trigedit_save(struct descriptor_data *d);
void trigedit_string_cleanup(struct descriptor_data *d, int terminator);
int format_script(struct descriptor_data *d);
void trigedit_setup_existing(struct descriptor_data *d, int rtrg_num);
/* from dg_objcmd.c */ /* from dg_objcmd.c */
room_rnum obj_room(obj_data *obj); room_rnum obj_room(obj_data *obj);
void obj_command_interpreter(obj_data *obj, char *argument);
/* from dg_wldcmd.c */
void wld_command_interpreter(room_data *room, char *argument);
/* defines for valid_dg_target */ /* defines for valid_dg_target */
#define DG_ALLOW_GODS (1<<0) #define DG_ALLOW_GODS (1<<0)
@ -388,3 +438,4 @@ room_rnum obj_room(obj_data *obj);
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(go)); \ sprintf(buf, "%c%ld", UID_CHAR, GET_ID(go)); \
add_var(&GET_TRIG_VARS(trig), name, buf, context); } while (0) add_var(&GET_TRIG_VARS(trig), name, buf, context); } while (0)
#endif /* _DG_SCRIPTS_H_ */

View file

@ -23,12 +23,8 @@
#include "db.h" #include "db.h"
#include "oasis.h" #include "oasis.h"
#include "constants.h" #include "constants.h"
#include "spells.h" /* for skill_name() */
extern const char *cmd_door[]; #include "act.h" /* for cmd_door[] */
extern struct time_info_data time_info;
/* external functions */
const char *skill_name(int num);
/* General functions used by several triggers. */ /* General functions used by several triggers. */

View file

@ -21,12 +21,8 @@
#include "constants.h" #include "constants.h"
#include "spells.h" #include "spells.h"
#include "oasis.h" #include "oasis.h"
#include "class.h"
/* External variables and functions */
extern const char *pc_class_types[];
extern struct time_info_data time_info;
int find_eq_pos_script(char *arg);
bool check_flags_by_name_ar(int *array, int numflags, char *search, const char *namelist[]);
/* Utility functions */ /* Utility functions */
@ -141,7 +137,7 @@ int text_processed(char *field, char *subfield, struct trig_var_data *vd,
char tmpvar[MAX_STRING_LENGTH]; char tmpvar[MAX_STRING_LENGTH];
if (!str_cmp(field, "strlen")) { /* strlen */ if (!str_cmp(field, "strlen")) { /* strlen */
snprintf(str, slen, "%d", strlen(vd->value)); snprintf(str, slen, "%d", (int)strlen(vd->value));
return TRUE; return TRUE;
} else if (!str_cmp(field, "trim")) { /* trim */ } else if (!str_cmp(field, "trim")) { /* trim */
/* trim whitespace from ends */ /* trim whitespace from ends */
@ -188,7 +184,6 @@ int text_processed(char *field, char *subfield, struct trig_var_data *vd,
/* find the mud command returned from this text */ /* find the mud command returned from this text */
/* NOTE: you may need to replace "cmd_info" with "complete_cmd_info", */ /* NOTE: you may need to replace "cmd_info" with "complete_cmd_info", */
/* depending on what patches you've got applied. */ /* depending on what patches you've got applied. */
extern const struct command_info cmd_info[];
/* on older source bases: extern struct command_info *cmd_info; */ /* on older source bases: extern struct command_info *cmd_info; */
int length, cmd; int length, cmd;
for (length = strlen(vd->value), cmd = 0; for (length = strlen(vd->value), cmd = 0;
@ -851,9 +846,21 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
} }
snprintf(str, slen, "%d", GET_PRACTICES(c)); snprintf(str, slen, "%d", GET_PRACTICES(c));
} }
else if (!str_cmp(field, "pref")) {
if (subfield && *subfield) {
int pref = get_flag_by_name(preference_bits, subfield);
if (pref != NOFLAG && PRF_FLAGGED(c, pref))
strcpy(str, "1");
else
strcpy(str, "0");
} else
strcpy(str, "0");
}
break; break;
case 'q': case 'q':
if (!str_cmp(field, "questpoints")) { if (!str_cmp(field, "questpoints") ||
!str_cmp(field, "qp") || !str_cmp(field, "qpnts"))
{
if (subfield && *subfield) { if (subfield && *subfield) {
int addition = atoi(subfield); int addition = atoi(subfield);
GET_QUESTPOINTS(c) += addition; GET_QUESTPOINTS(c) += addition;

View file

@ -18,17 +18,25 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "constants.h" #include "constants.h"
#include "genzon.h" /* for zone_rnum real_zone_by_thing */
#include "fight.h" /* for die() */
/* External functions. */ /* Local functions, macros, defines and structs */
void die(struct char_data * ch, struct char_data * killer);
zone_rnum real_zone_by_thing(room_vnum vznum);
bitvector_t asciiflag_conv(char *flag);
/* Local functions. */
#define WCMD(name) \ #define WCMD(name) \
void (name)(room_data *room, char *argument, int cmd, int subcmd) void (name)(room_data *room, char *argument, int cmd, int subcmd)
/* for do_wsend */
#define SCMD_WSEND 0
#define SCMD_WECHOAROUND 1
struct wld_command_info {
char *command;
void (*command_pointer)
(room_data *room, char *argument, int cmd, int subcmd);
int subcmd;
};
void wld_log(room_data *room, const char *format, ...); void wld_log(room_data *room, const char *format, ...);
void act_to_room(char *str, room_data *room); void act_to_room(char *str, room_data *room);
WCMD(do_wasound); WCMD(do_wasound);
@ -43,18 +51,8 @@ WCMD(do_wpurge);
WCMD(do_wload); WCMD(do_wload);
WCMD(do_wdamage); WCMD(do_wdamage);
WCMD(do_wat); WCMD(do_wat);
void wld_command_interpreter(room_data *room, char *argument);
struct wld_command_info {
char *command;
void (*command_pointer)
(room_data *room, char *argument, int cmd, int subcmd);
int subcmd;
};
/* do_wsend */
#define SCMD_WSEND 0
#define SCMD_WECHOAROUND 1
/* attaches room vnum to msg and sends it to script_log */ /* attaches room vnum to msg and sends it to script_log */
void wld_log(room_data *room, const char *format, ...) void wld_log(room_data *room, const char *format, ...)

1294
src/dox_noGraphs.doxyfile Normal file

File diff suppressed because it is too large Load diff

1294
src/dox_withGraphs.doxyfile Normal file

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,8 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/ **************************************************************************/
#define __FIGHT_C__
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
@ -20,65 +22,52 @@
#include "screen.h" #include "screen.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "act.h"
#include "class.h"
#include "fight.h"
#include "shop.h"
#include "quest.h"
/* Structures */
struct char_data *combat_list = NULL; /* head of l-list of fighting chars */
struct char_data *next_combat_list = NULL;
/* External structures */
extern struct message_list fight_messages[MAX_MESSAGES];
/* External procedures */
char *fread_action(FILE *fl, int nr);
ACMD(do_flee);
ACMD(do_get);
ACMD(do_split);
ACMD(do_sac);
ACMD(do_assist);
int backstab_mult(int level);
int thaco(int ch_class, int level);
int ok_damage_shopkeeper(struct char_data *ch, struct char_data *victim);
/* local functions */
void perform_group_gain(struct char_data *ch, int base, struct char_data *victim);
void dam_message(int dam, struct char_data *ch, struct char_data *victim, int w_type);
void appear(struct char_data *ch);
void load_messages(void);
void free_messages(void);
void free_messages_type(struct msg_type *msg);
void check_killer(struct char_data *ch, struct char_data *vict);
void make_corpse(struct char_data *ch);
void change_alignment(struct char_data *ch, struct char_data *victim);
void death_cry(struct char_data *ch);
void raw_kill(struct char_data * ch, struct char_data * killer);
void die(struct char_data * ch, struct char_data * killer);
void group_gain(struct char_data *ch, struct char_data *victim);
void solo_gain(struct char_data *ch, struct char_data *victim);
char *replace_string(const char *str, const char *weapon_singular, const char *weapon_plural);
void perform_violence(void);
int compute_armor_class(struct char_data *ch);
int compute_thaco(struct char_data *ch, struct char_data *vict);
/* locally defined global variables, used externally */
/* head of l-list of fighting chars */
struct char_data *combat_list = NULL;
/* Weapon attack texts */ /* Weapon attack texts */
struct attack_hit_type attack_hit_text[] = struct attack_hit_type attack_hit_text[] =
{ {
{"hit", "hits"}, /* 0 */ {"hit", "hits"}, /* 0 */
{"sting", "stings"}, {"sting", "stings"},
{"whip", "whips"}, {"whip", "whips"},
{"slash", "slashes"}, {"slash", "slashes"},
{"bite", "bites"}, {"bite", "bites"},
{"bludgeon", "bludgeons"}, /* 5 */ {"bludgeon", "bludgeons"}, /* 5 */
{"crush", "crushes"}, {"crush", "crushes"},
{"pound", "pounds"}, {"pound", "pounds"},
{"claw", "claws"}, {"claw", "claws"},
{"maul", "mauls"}, {"maul", "mauls"},
{"thrash", "thrashes"}, /* 10 */ {"thrash", "thrashes"}, /* 10 */
{"pierce", "pierces"}, {"pierce", "pierces"},
{"blast", "blasts"}, {"blast", "blasts"},
{"punch", "punches"}, {"punch", "punches"},
{"stab", "stabs"} {"stab", "stabs"}
}; };
/* local (file scope only) variables */
static struct char_data *next_combat_list = NULL;
/* local file scope utility functions */
static void perform_group_gain(struct char_data *ch, int base, struct char_data *victim);
static void dam_message(int dam, struct char_data *ch, struct char_data *victim, int w_type);
static void free_messages_type(struct msg_type *msg);
static void make_corpse(struct char_data *ch);
static void change_alignment(struct char_data *ch, struct char_data *victim);
static void group_gain(struct char_data *ch, struct char_data *victim);
static void solo_gain(struct char_data *ch, struct char_data *victim);
/** @todo refactor this function name */
static char *replace_string(const char *str, const char *weapon_singular, const char *weapon_plural);
static int compute_thaco(struct char_data *ch, struct char_data *vict);
#define IS_WEAPON(type) (((type) >= TYPE_HIT) && ((type) < TYPE_SUFFERING)) #define IS_WEAPON(type) (((type) >= TYPE_HIT) && ((type) < TYPE_SUFFERING))
/* The Fight related routines */ /* The Fight related routines */
void appear(struct char_data *ch) void appear(struct char_data *ch)
@ -106,7 +95,7 @@ int compute_armor_class(struct char_data *ch)
return (MAX(-100, armorclass)); /* -100 is lowest */ return (MAX(-100, armorclass)); /* -100 is lowest */
} }
void free_messages_type(struct msg_type *msg) static void free_messages_type(struct msg_type *msg)
{ {
if (msg->attacker_msg) free(msg->attacker_msg); if (msg->attacker_msg) free(msg->attacker_msg);
if (msg->victim_msg) free(msg->victim_msg); if (msg->victim_msg) free(msg->victim_msg);
@ -257,7 +246,7 @@ void stop_fighting(struct char_data *ch)
update_pos(ch); update_pos(ch);
} }
void make_corpse(struct char_data *ch) static void make_corpse(struct char_data *ch)
{ {
char buf2[MAX_NAME_LENGTH + 64]; char buf2[MAX_NAME_LENGTH + 64];
struct obj_data *corpse, *o; struct obj_data *corpse, *o;
@ -328,7 +317,7 @@ void make_corpse(struct char_data *ch)
} }
/* When ch kills victim */ /* When ch kills victim */
void change_alignment(struct char_data *ch, struct char_data *victim) static void change_alignment(struct char_data *ch, struct char_data *victim)
{ {
/* new alignment change algorithm: if you kill a monster with alignment A, /* new alignment change algorithm: if you kill a monster with alignment A,
* you move 1/16th of the way to having alignment -A. Simple and fast. */ * you move 1/16th of the way to having alignment -A. Simple and fast. */
@ -363,10 +352,18 @@ void raw_kill(struct char_data * ch, struct char_data * killer)
} else } else
death_cry(ch); death_cry(ch);
if (killer)
autoquest_trigger_check(killer, ch, NULL, AQ_MOB_KILL);
update_pos(ch); update_pos(ch);
make_corpse(ch); make_corpse(ch);
extract_char(ch); extract_char(ch);
if (killer) {
autoquest_trigger_check(killer, NULL, NULL, AQ_MOB_SAVE);
autoquest_trigger_check(killer, NULL, NULL, AQ_ROOM_CLEAR);
}
} }
void die(struct char_data * ch, struct char_data * killer) void die(struct char_data * ch, struct char_data * killer)
@ -379,7 +376,7 @@ void die(struct char_data * ch, struct char_data * killer)
raw_kill(ch, killer); raw_kill(ch, killer);
} }
void perform_group_gain(struct char_data *ch, int base, static void perform_group_gain(struct char_data *ch, int base,
struct char_data *victim) struct char_data *victim)
{ {
int share; int share;
@ -395,7 +392,7 @@ void perform_group_gain(struct char_data *ch, int base,
change_alignment(ch, victim); change_alignment(ch, victim);
} }
void group_gain(struct char_data *ch, struct char_data *victim) static void group_gain(struct char_data *ch, struct char_data *victim)
{ {
int tot_members, base, tot_gain; int tot_members, base, tot_gain;
struct char_data *k; struct char_data *k;
@ -433,7 +430,7 @@ void group_gain(struct char_data *ch, struct char_data *victim)
perform_group_gain(f->follower, base, victim); perform_group_gain(f->follower, base, victim);
} }
void solo_gain(struct char_data *ch, struct char_data *victim) static void solo_gain(struct char_data *ch, struct char_data *victim)
{ {
int exp; int exp;
@ -456,7 +453,7 @@ void solo_gain(struct char_data *ch, struct char_data *victim)
change_alignment(ch, victim); change_alignment(ch, victim);
} }
char *replace_string(const char *str, const char *weapon_singular, const char *weapon_plural) static char *replace_string(const char *str, const char *weapon_singular, const char *weapon_plural)
{ {
static char buf[256]; static char buf[256];
char *cp = buf; char *cp = buf;
@ -484,7 +481,7 @@ char *replace_string(const char *str, const char *weapon_singular, const char *w
} }
/* message for doing damage with a weapon */ /* message for doing damage with a weapon */
void dam_message(int dam, struct char_data *ch, struct char_data *victim, static void dam_message(int dam, struct char_data *ch, struct char_data *victim,
int w_type) int w_type)
{ {
char *buf; char *buf;
@ -856,7 +853,7 @@ int damage(struct char_data *ch, struct char_data *victim, int dam, int attackty
/* Calculate the THAC0 of the attacker. 'victim' currently isn't used but you /* Calculate the THAC0 of the attacker. 'victim' currently isn't used but you
* could use it for special cases like weapons that hit evil creatures easier * could use it for special cases like weapons that hit evil creatures easier
* or a weapon that always misses attacking an animal. */ * or a weapon that always misses attacking an animal. */
int compute_thaco(struct char_data *ch, struct char_data *victim) static int compute_thaco(struct char_data *ch, struct char_data *victim)
{ {
int calc_thaco; int calc_thaco;

View file

@ -18,7 +18,7 @@
#include "dg_olc.h" #include "dg_olc.h"
/* local functions */ /* local functions */
void extract_mobile_all(mob_vnum vnum); static void extract_mobile_all(mob_vnum vnum);
int add_mobile(struct char_data *mob, mob_vnum vnum) int add_mobile(struct char_data *mob, mob_vnum vnum)
{ {
@ -98,7 +98,7 @@ int copy_mobile(struct char_data *to, struct char_data *from)
return TRUE; return TRUE;
} }
void extract_mobile_all(mob_vnum vnum) static void extract_mobile_all(mob_vnum vnum)
{ {
struct char_data *next, *ch; struct char_data *next, *ch;

View file

@ -1,10 +1,16 @@
/************************************************************************** /**
* File: genmob.h Part of tbaMUD * * @file genmob.h
* * * Generic OLC Library - Mobiles.
* Usage: Generic OLC Library - Mobiles. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENMOB_H_
#define _GENMOB_H_
int delete_mobile(mob_rnum); int delete_mobile(mob_rnum);
int copy_mobile(struct char_data *to, struct char_data *from); int copy_mobile(struct char_data *to, struct char_data *from);
@ -32,3 +38,5 @@ int write_mobile_mobprog(mob_vnum mvnum, struct char_data *mob, FILE *fd);
#define GET_LDESC(mob) ((mob)->player.long_descr) #define GET_LDESC(mob) ((mob)->player.long_descr)
#define GET_DDESC(mob) ((mob)->player.description) #define GET_DDESC(mob) ((mob)->player.description)
#define GET_ATTACK(mob) ((mob)->mob_specials.attack_type) #define GET_ATTACK(mob) ((mob)->mob_specials.attack_type)
#endif /* _GENMOB_H_ */

View file

@ -17,14 +17,12 @@
#include "genzon.h" #include "genzon.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "handler.h" #include "handler.h"
#include "boards.h" /* for board_info */
/* extern functions */
extern struct board_info_type board_info[];
/* local functions */ /* local functions */
void free_object_strings_proto(struct obj_data *obj); static int update_all_objects(struct obj_data *obj);
int update_all_objects(struct obj_data *obj); static void copy_object_strings(struct obj_data *to, struct obj_data *from);
void copy_object_strings(struct obj_data *to, struct obj_data *from);
obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum) obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum)
{ {
@ -49,7 +47,7 @@ obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum)
* and every object currently in the game to see which ones are pointing to * and every object currently in the game to see which ones are pointing to
* this prototype. If object is pointing to this prototype, then we need to * this prototype. If object is pointing to this prototype, then we need to
* replace it with the new one. */ * replace it with the new one. */
int update_all_objects(struct obj_data *refobj) static int update_all_objects(struct obj_data *refobj)
{ {
struct obj_data *obj, swap; struct obj_data *obj, swap;
int count = 0; int count = 0;
@ -341,7 +339,7 @@ void free_object_strings_proto(struct obj_data *obj)
} }
} }
void copy_object_strings(struct obj_data *to, struct obj_data *from) static void copy_object_strings(struct obj_data *to, struct obj_data *from)
{ {
to->name = from->name ? strdup(from->name) : NULL; to->name = from->name ? strdup(from->name) : NULL;
to->description = from->description ? strdup(from->description) : NULL; to->description = from->description ? strdup(from->description) : NULL;

View file

@ -1,11 +1,18 @@
/************************************************************************** /**
* File: genobj.h Part of tbaMUD * * @file genobj.h
* * * Generic OLC Library - Objects.
* Usage: Generic OLC Library - Objects. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENOBJ_H_
#define _GENOBJ_H_
void free_object_strings_proto(struct obj_data *obj);
void free_object_strings(struct obj_data *obj); void free_object_strings(struct obj_data *obj);
int copy_object(struct obj_data *to, struct obj_data *from); int copy_object(struct obj_data *to, struct obj_data *from);
int copy_object_preserve(struct obj_data *to, struct obj_data *from); int copy_object_preserve(struct obj_data *to, struct obj_data *from);
@ -13,8 +20,8 @@ int save_objects(zone_rnum vznum);
obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum); obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum);
obj_rnum adjust_objects(obj_rnum refpt); obj_rnum adjust_objects(obj_rnum refpt);
obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum); obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum);
int update_objects(struct obj_data *refobj);
obj_rnum add_object(struct obj_data *, obj_vnum ovnum); obj_rnum add_object(struct obj_data *, obj_vnum ovnum);
int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object); int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object);
int delete_object(obj_rnum); int delete_object(obj_rnum);
#endif /* _GENOBJ_H_ */

View file

@ -25,14 +25,17 @@
#include "dg_olc.h" #include "dg_olc.h"
#include "constants.h" #include "constants.h"
#include "interpreter.h" #include "interpreter.h"
#include "act.h" /* for the space_to_minus function */
#include "modify.h" /* for smash_tilde */
#include "quest.h"
int save_config( IDXTYPE nowhere ); /* Exported from cedit.c */ /* Global variables defined here, used elsewhere */
/* List of zones to be saved. */ /* List of zones to be saved. */
struct save_list_data *save_list; struct save_list_data *save_list;
/* Local (file scope) variables */
/* Structure defining all known save types. */ /* Structure defining all known save types. */
struct { static struct {
int save_type; int save_type;
int (*func)(IDXTYPE rnum); int (*func)(IDXTYPE rnum);
const char *message; const char *message;
@ -43,10 +46,26 @@ struct {
{ SL_WLD, save_rooms, "room" }, { SL_WLD, save_rooms, "room" },
{ SL_ZON, save_zone, "zone" }, { SL_ZON, save_zone, "zone" },
{ SL_CFG, save_config, "config" }, { SL_CFG, save_config, "config" },
{ SL_QST, save_quests, "quest" },
{ SL_ACT, NULL, "social" }, { SL_ACT, NULL, "social" },
{ SL_HLP, NULL, "help" }, { SL_HLP, NULL, "help" },
{ -1, NULL, NULL }, { -1, NULL, NULL },
}; };
/* for Zone Export */
static int zone_exits = 0;
/* Local (file scope) functions */
/* Zone export functions */
static int export_save_shops(zone_rnum zrnum);
static int export_save_mobiles(zone_rnum rznum);
static int export_save_zone(zone_rnum zrnum);
static int export_save_objects(zone_rnum zrnum);
static int export_save_rooms(zone_rnum zrnum);
static int export_save_triggers(zone_rnum zrnum);
static int export_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd);
static void export_script_save_to_disk(FILE *fp, void *item, int type);
static int export_info_file(zone_rnum zrnum);
int genolc_checkstring(struct descriptor_data *d, char *arg) int genolc_checkstring(struct descriptor_data *d, char *arg)
{ {
@ -59,6 +78,20 @@ char *str_udup(const char *txt)
return strdup((txt && *txt) ? txt : "undefined"); return strdup((txt && *txt) ? txt : "undefined");
} }
char *str_udupnl(const char *txt)
{
char *str = NULL, undef[] = "undefined";
const char *ptr = NULL;
ptr = (txt && *txt) ? txt : undef;
CREATE(str, char, strlen(ptr) + 3);
strlcpy(str, ptr, strlen(ptr));
strcat(str, "\r\n");
return str;
}
/* Original use: to be called at shutdown time. */ /* Original use: to be called at shutdown time. */
int save_all(void) int save_all(void)
{ {
@ -244,67 +277,109 @@ int sprintascii(char *out, bitvector_t bits)
return j; return j;
} }
/* Zone export functions */ /* converts illegal filename chars into appropriate equivalents */
int export_save_shops(zone_rnum zrnum); char *fix_filename(char *str)
int export_save_mobiles(zone_rnum rznum); {
int export_save_zone(zone_rnum zrnum); static char good_file_name[MAX_STRING_LENGTH];
int export_save_objects(zone_rnum zrnum); char *index = good_file_name;
int export_save_rooms(zone_rnum zrnum);
int export_save_triggers(zone_rnum zrnum); while(*str) {
int export_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd); switch(*str) {
void export_script_save_to_disk(FILE *fp, void *item, int type); case ' ': *index = '_'; index++; break;
int export_info_file(zone_rnum zrnum); case '(': *index = '{'; index++; break;
static int zone_exits = 0; case ')': *index = '}'; index++; break;
ACMD(do_export_zone);
/* skip the following */
ACMD(do_export_zone) case '\'': break;
{ case '"': break;
zone_rnum zrnum;
zone_vnum zvnum; /* Legal character */
char sysbuf[MAX_INPUT_LENGTH]; default: *index = *str; index++;break;
char fn[MAX_INPUT_LENGTH], *f; }
void space_to_minus(char *str); str++;
}
if (IS_NPC(ch) || GET_LEVEL(ch) < LVL_IMPL) *index = '\0';
return;
return good_file_name;
skip_spaces(&argument);
zvnum = atoi(argument);
zrnum = real_zone(zvnum);
if (zrnum == NOWHERE) {
send_to_char(ch, "Export which zone?\r\n");
return;
}
if (!export_info_file(zrnum))
send_to_char(ch, "Info file not saved!\r\n");
if (!export_save_shops(zrnum))
send_to_char(ch, "Shops not saved!\r\n");
if (!export_save_mobiles(zrnum))
send_to_char(ch, "Mobiles not saved!\r\n");
if (!export_save_objects(zrnum))
send_to_char(ch, "Objects not saved!\r\n");
if (!export_save_zone(zrnum))
send_to_char(ch, "Zone info not saved!\r\n");
if (!export_save_rooms(zrnum))
send_to_char(ch, "Rooms not saved!\r\n");
if (!export_save_triggers(zrnum))
send_to_char(ch, "Triggers not saved!\r\n");
send_to_char(ch, "Files saved to /lib/world/export.\r\n");
snprintf(fn, sizeof(fn), "%d_%s.tgz", zvnum, zone_table[zrnum].name);
f = fn;
space_to_minus(f);
snprintf(sysbuf, sizeof(sysbuf),
LIB_ETC "export_script.sh %s &",
fn);
system(sysbuf);
send_to_char(ch, "Files tar'ed to \"%s\"\r\n", fn);
} }
int export_info_file(zone_rnum zrnum) /* Export command by Kyle */
ACMD(do_export_zone)
{
zone_rnum zrnum;
zone_vnum zvnum;
char sysbuf[MAX_INPUT_LENGTH];
char zone_name[MAX_INPUT_LENGTH], *f;
int success;
/* system command locations are relative to
* where the binary IS, not where it was run
* from, thus we act like we are in the bin
* folder, because we are*/
char *path = "../lib/world/export/";
if (IS_NPC(ch) || GET_LEVEL(ch) < LVL_IMPL)
return;
skip_spaces(&argument);
zvnum = atoi(argument);
zrnum = real_zone(zvnum);
if (zrnum == NOWHERE) {
send_to_char(ch, "Export which zone?\r\n");
return;
}
/* If we fail, it might just be because the
* directory didn't exist. Can't hurt to try
* again. Do it silently though ( no logs ). */
if (!export_info_file(zrnum)) {
sprintf(sysbuf, "mkdir %s", path);
system(sysbuf);
}
if (!(success = export_info_file(zrnum)))
send_to_char(ch, "Info file not saved!\r\n");
if (!(success = export_save_shops(zrnum)))
send_to_char(ch, "Shops not saved!\r\n");
if (!(success = export_save_mobiles(zrnum)))
send_to_char(ch, "Mobiles not saved!\r\n");
if (!(success = export_save_objects(zrnum)))
send_to_char(ch, "Objects not saved!\r\n");
if (!(success = export_save_zone(zrnum)))
send_to_char(ch, "Zone info not saved!\r\n");
if (!(success = export_save_rooms(zrnum)))
send_to_char(ch, "Rooms not saved!\r\n");
if (!(success = export_save_triggers(zrnum)))
send_to_char(ch, "Triggers not saved!\r\n");
/* If anything went wrong, don't try to tar the files. */
if (success) {
send_to_char(ch, "Individual files saved to /lib/world/export.\r\n");
snprintf(zone_name, sizeof(zone_name), "%s", zone_table[zrnum].name);
} else {
send_to_char(ch, "Ran into problems writing to files.\r\n");
return;
}
/* Make sure the name of the zone doesn't make the filename illegal. */
f = fix_filename(zone_name);
/* Remove the old copy. */
sprintf(sysbuf, "rm %s%s.tar.gz", path, f);
system(sysbuf);
/* Tar the new copy. */
sprintf(sysbuf, "tar -cf %s%s.tar %sqq.info %sqq.wld %sqq.zon %sqq.mob %sqq.obj %sqq.trg", path, f, path, path, path, path, path, path);
system(sysbuf);
/* Gzip it. */
sprintf(sysbuf, "gzip %s%s.tar", path, f);
system(sysbuf);
send_to_char(ch, "Files tar'ed to \"%s%s.tar.gz\"\r\n", path, f);
}
static int export_info_file(zone_rnum zrnum)
{ {
int i; int i;
FILE *info_file; FILE *info_file;
@ -312,7 +387,7 @@ int export_info_file(zone_rnum zrnum)
if (!(info_file = fopen("world/export/qq.info", "w"))) { if (!(info_file = fopen("world/export/qq.info", "w"))) {
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: export_info_file : Cannot open file!"); mudlog(BRF, LVL_GOD, TRUE, "SYSERR: export_info_file : Cannot open file!");
return FALSE; return FALSE;
} else if (fprintf(info_file, "CircleMUD v3.1 Area file.\n") < 0) { } else if (fprintf(info_file, "tbaMUD Area file.\n") < 0) {
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: export_info_file: Cannot write to file!"); mudlog(BRF, LVL_GOD, TRUE, "SYSERR: export_info_file: Cannot write to file!");
fclose(info_file); fclose(info_file);
return FALSE; return FALSE;
@ -357,26 +432,26 @@ int export_info_file(zone_rnum zrnum)
zone_exits = 0; zone_exits = 0;
} else { } else {
fprintf(info_file, "2. This area doesn't have any exits _out_ of the zone.\n"); fprintf(info_file, "2. This area doesn't have any exits _out_ of the zone.\n");
fprintf(info_file, " More info on connections in the zone description room.\n"); fprintf(info_file, " More info on connections can be found in the zone description room (QQ00).\n");
} }
fprintf(info_file, "\nAdditional zone information is available in the zone description room QQ00.\n"); fprintf(info_file, "\nAdditional zone information is available in the zone description room QQ00.\n");
fprintf(info_file, "The Builder's Academy is maintaining and improving these zones. Any typo or\n"); fprintf(info_file, "The Builder's Academy is maintaining and improving these zones. Any typo or\n");
fprintf(info_file, "bug reports should be reported to rumble@builderacademy.net or stop by The Builder Academy\n"); fprintf(info_file, "bug reports should be reported to rumble@tbamud.com or stop by The Builder Academy\n");
fprintf(info_file, "port telnet://builderacademy.net:9091\n"); fprintf(info_file, "port telnet://tbamud.com:9091\n");
fprintf(info_file, "\nAnyone interested in submitting areas or helping improve the existing ones\n"); fprintf(info_file, "\nAnyone interested in submitting areas or helping improve the existing ones\n");
fprintf(info_file, "please stop by TBA and talk to Rumble.\n\n"); fprintf(info_file, "please stop by TBA and talk to Rumble.\n\n");
fprintf(info_file, "We at The Builder's Academy hope you will enjoy using the area.\n\n"); fprintf(info_file, "We at The Builder's Academy hope you will enjoy using the area.\n\n");
fprintf(info_file, "Rumble - Admin of TBA\n"); fprintf(info_file, "Rumble - Admin of TBA\n");
fprintf(info_file, "Welcor - Coder of TBA\n"); fprintf(info_file, "Welcor - Coder of TBA\n");
fprintf(info_file, "\ntelnet://builderacademy.net:9091/\n"); fprintf(info_file, "\ntelnet://tbamud.com:9091/\n");
fclose(info_file); fclose(info_file);
return TRUE; return TRUE;
} }
int export_save_shops(zone_rnum zrnum) static int export_save_shops(zone_rnum zrnum)
{ {
int i, j, rshop; int i, j, rshop;
FILE *shop_file; FILE *shop_file;
@ -466,7 +541,7 @@ int export_save_shops(zone_rnum zrnum)
return TRUE; return TRUE;
} }
int export_save_mobiles(zone_rnum rznum) static int export_save_mobiles(zone_rnum rznum)
{ {
FILE *mob_file; FILE *mob_file;
mob_vnum i; mob_vnum i;
@ -490,7 +565,7 @@ int export_save_mobiles(zone_rnum rznum)
return TRUE; return TRUE;
} }
int export_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd) static int export_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{ {
char ldesc[MAX_STRING_LENGTH]; char ldesc[MAX_STRING_LENGTH];
@ -538,7 +613,7 @@ int export_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
return TRUE; return TRUE;
} }
int export_save_zone(zone_rnum zrnum) static int export_save_zone(zone_rnum zrnum)
{ {
int subcmd; int subcmd;
FILE *zone_file; FILE *zone_file;
@ -665,7 +740,7 @@ int export_save_zone(zone_rnum zrnum)
return TRUE; return TRUE;
} }
int export_save_objects(zone_rnum zrnum) static int export_save_objects(zone_rnum zrnum)
{ {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
char ebuf1[MAX_STRING_LENGTH], ebuf2[MAX_STRING_LENGTH], ebuf3[MAX_STRING_LENGTH], ebuf4[MAX_STRING_LENGTH]; char ebuf1[MAX_STRING_LENGTH], ebuf2[MAX_STRING_LENGTH], ebuf3[MAX_STRING_LENGTH], ebuf4[MAX_STRING_LENGTH];
@ -776,7 +851,7 @@ int export_save_objects(zone_rnum zrnum)
return TRUE; return TRUE;
} }
int export_save_rooms(zone_rnum zrnum) static int export_save_rooms(zone_rnum zrnum)
{ {
int i; int i;
struct room_data *room; struct room_data *room;
@ -891,7 +966,7 @@ int export_save_rooms(zone_rnum zrnum)
return TRUE; return TRUE;
} }
void export_script_save_to_disk(FILE *fp, void *item, int type) static void export_script_save_to_disk(FILE *fp, void *item, int type)
{ {
struct trig_proto_list *t; struct trig_proto_list *t;
@ -914,7 +989,7 @@ void export_script_save_to_disk(FILE *fp, void *item, int type)
} }
/* save the zone's triggers to internal memory and to disk */ /* save the zone's triggers to internal memory and to disk */
int export_save_triggers(zone_rnum zrnum) static int export_save_triggers(zone_rnum zrnum)
{ {
int i; int i;
trig_data *trig; trig_data *trig;

View file

@ -1,15 +1,20 @@
/************************************************************************** /**
* File: genolc.h Part of tbaMUD * * @file genolc.h
* * * Generic OLC Library - General.
* Usage: Generic OLC Library - General. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENOLC_H_
#define _GENOLC_H_
#define STRING_TERMINATOR '~' #define STRING_TERMINATOR '~'
#define CONFIG_GENOLC_MOBPROG 0 #define CONFIG_GENOLC_MOBPROG 0
void smash_tilde(char *str); /* from modify.c */
int genolc_checkstring(struct descriptor_data *d, char *arg); int genolc_checkstring(struct descriptor_data *d, char *arg);
int remove_from_save_list(zone_vnum, int type); int remove_from_save_list(zone_vnum, int type);
int add_to_save_list(zone_vnum, int type); int add_to_save_list(zone_vnum, int type);
@ -17,9 +22,12 @@ int in_save_list(zone_vnum, int type);
void strip_cr(char *); void strip_cr(char *);
int save_all(void); int save_all(void);
char *str_udup(const char *); char *str_udup(const char *);
char *str_udupnl(const char *);
void copy_ex_descriptions(struct extra_descr_data **to, struct extra_descr_data *from); void copy_ex_descriptions(struct extra_descr_data **to, struct extra_descr_data *from);
void free_ex_descriptions(struct extra_descr_data *head); void free_ex_descriptions(struct extra_descr_data *head);
int sprintascii(char *out, bitvector_t bits); int sprintascii(char *out, bitvector_t bits);
ACMD(do_export_zone);
ACMD(do_show_save_list);
struct save_list_data { struct save_list_data {
int zone; int zone;
@ -36,7 +44,8 @@ extern struct save_list_data *save_list;
#define SL_WLD 3 #define SL_WLD 3
#define SL_ZON 4 #define SL_ZON 4
#define SL_CFG 5 #define SL_CFG 5
#define SL_MAX 5 #define SL_QST 6
#define SL_MAX 6
#define SL_ACT SL_MAX + 1 /* must be above MAX */ #define SL_ACT SL_MAX + 1 /* must be above MAX */
#define SL_HLP SL_MAX + 2 #define SL_HLP SL_MAX + 2
@ -46,4 +55,6 @@ extern struct save_list_data *save_list;
room_vnum genolc_zone_bottom(zone_rnum rznum); room_vnum genolc_zone_bottom(zone_rnum rznum);
room_vnum genolc_zonep_bottom(struct zone_data *zone); room_vnum genolc_zonep_bottom(struct zone_data *zone);
extern void free_save_list(void);
#endif /* _GENOLC_H_ */

View file

@ -18,11 +18,11 @@
/* NOTE (gg): Didn't modify sedit much. Don't consider it as 'recent' as the /* NOTE (gg): Didn't modify sedit much. Don't consider it as 'recent' as the
* other editors with regard to updates or style. */ * other editors with regard to updates or style. */
/* local functions */ /* local (file scope) functions */
void copy_shop_list(IDXTYPE **tlist, IDXTYPE *flist); static void copy_shop_list(IDXTYPE **tlist, IDXTYPE *flist);
void copy_shop_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist); static void copy_shop_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist);
void free_shop_strings(struct shop_data *shop); static void free_shop_strings(struct shop_data *shop);
void free_shop_type_list(struct shop_buy_data **list); static void free_shop_type_list(struct shop_buy_data **list);
void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings) void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings)
{ {
@ -61,7 +61,7 @@ void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_st
} }
/* Copy a 'NOTHING' terminated integer array list. */ /* Copy a 'NOTHING' terminated integer array list. */
void copy_shop_list(IDXTYPE **tlist, IDXTYPE *flist) static void copy_shop_list(IDXTYPE **tlist, IDXTYPE *flist)
{ {
int num_items, i; int num_items, i;
@ -81,7 +81,7 @@ void copy_shop_list(IDXTYPE **tlist, IDXTYPE *flist)
} }
/* Copy a -1 terminated (in the type field) shop_buy_data array list. */ /* Copy a -1 terminated (in the type field) shop_buy_data array list. */
void copy_shop_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist) static void copy_shop_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist)
{ {
int num_items, i; int num_items, i;
@ -193,7 +193,7 @@ void remove_shop_from_int_list(IDXTYPE **list, IDXTYPE num)
} }
/* Free all the notice character strings in a shop structure. */ /* Free all the notice character strings in a shop structure. */
void free_shop_strings(struct shop_data *shop) static void free_shop_strings(struct shop_data *shop)
{ {
if (S_NOITEM1(shop)) { if (S_NOITEM1(shop)) {
free(S_NOITEM1(shop)); free(S_NOITEM1(shop));
@ -226,7 +226,7 @@ void free_shop_strings(struct shop_data *shop)
} }
/* Free a type list and all the strings it contains. */ /* Free a type list and all the strings it contains. */
void free_shop_type_list(struct shop_buy_data **list) static void free_shop_type_list(struct shop_buy_data **list)
{ {
int i; int i;
@ -343,7 +343,7 @@ int add_shop(struct shop_data *nshp)
int save_shops(zone_rnum zone_num) int save_shops(zone_rnum zone_num)
{ {
int i, j, rshop; int i, j, rshop, num_shops = 0;
FILE *shop_file; FILE *shop_file;
char fname[128], oldname[128]; char fname[128], oldname[128];
struct shop_data *shop; struct shop_data *shop;
@ -423,7 +423,8 @@ int save_shops(zone_rnum zone_num)
/* Save open/closing times. */ /* Save open/closing times. */
fprintf(shop_file, "%d\n%d\n%d\n%d\n", S_OPEN1(shop), S_CLOSE1(shop), fprintf(shop_file, "%d\n%d\n%d\n%d\n", S_OPEN1(shop), S_CLOSE1(shop),
S_OPEN2(shop), S_CLOSE2(shop)); S_OPEN2(shop), S_CLOSE2(shop));
num_shops++;
} }
} }
fprintf(shop_file, "$~\n"); fprintf(shop_file, "$~\n");
@ -431,6 +432,9 @@ int save_shops(zone_rnum zone_num)
snprintf(oldname, sizeof(oldname), "%s/%d.shp", SHP_PREFIX, zone_table[zone_num].number); snprintf(oldname, sizeof(oldname), "%s/%d.shp", SHP_PREFIX, zone_table[zone_num].number);
remove(oldname); remove(oldname);
rename(fname, oldname); rename(fname, oldname);
if (num_shops > 0)
create_world_index(zone_table[zone_num].number, "shp");
if (in_save_list(zone_table[zone_num].number, SL_SHP)) if (in_save_list(zone_table[zone_num].number, SL_SHP))
remove_from_save_list(zone_table[zone_num].number, SL_SHP); remove_from_save_list(zone_table[zone_num].number, SL_SHP);

View file

@ -1,10 +1,16 @@
/************************************************************************** /**
* File: genshp.h Part of tbaMUD * * @file genshp.h
* * * Generic OLC Library - Shops.
* Usage: Generic OLC Library - Shops. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENSHP_H_
#define _GENSHP_H_
void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings); void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings);
void remove_shop_from_type_list(struct shop_buy_data **list, int num); void remove_shop_from_type_list(struct shop_buy_data **list, int num);
@ -49,3 +55,5 @@ shop_rnum real_shop(shop_vnum vnum);
#define S_NOBUY(i) ((i)->do_not_buy) #define S_NOBUY(i) ((i)->do_not_buy)
#define S_BUY(i) ((i)->message_buy) #define S_BUY(i) ((i)->message_buy)
#define S_SELL(i) ((i)->message_sell) #define S_SELL(i) ((i)->message_sell)
#endif /* _GENSHP_H_ */

View file

@ -18,9 +18,6 @@
#include "shop.h" #include "shop.h"
#include "dg_olc.h" #include "dg_olc.h"
extern room_rnum r_mortal_start_room;
extern room_rnum r_immort_start_room;
extern room_rnum r_frozen_start_room;
/* This function will copy the strings so be sure you free your own copies of /* This function will copy the strings so be sure you free your own copies of
* the description, title, and such. */ * the description, title, and such. */

View file

@ -1,10 +1,16 @@
/************************************************************************** /**
* File: genwld.h Part of tbaMUD * * @file genwld.h
* * * Generic OLC Library - Rooms.
* Usage: Generic OLC Library - Rooms. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* By Levork. Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* By Levork. Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENWLD_H_
#define _GENWLD_H_
room_rnum add_room(struct room_data *); room_rnum add_room(struct room_data *);
int delete_room(room_rnum); int delete_room(room_rnum);
@ -13,3 +19,5 @@ int copy_room(struct room_data *to, struct room_data *from);
room_rnum duplicate_room(room_vnum to, room_rnum from); room_rnum duplicate_room(room_vnum to, room_rnum from);
int copy_room_strings(struct room_data *dest, struct room_data *source); int copy_room_strings(struct room_data *dest, struct room_data *source);
int free_room_strings(struct room_data *); int free_room_strings(struct room_data *);
#endif /* _GENWLD_H_ */

View file

@ -15,8 +15,7 @@
#include "dg_scripts.h" #include "dg_scripts.h"
/* local functions */ /* local functions */
void create_world_index(int znum, const char *type); static void remove_cmd_from_list(struct reset_com **list, int pos);
void remove_cmd_from_list(struct reset_com **list, int pos);
/* real zone of room/mobile/object/shop given */ /* real zone of room/mobile/object/shop given */
zone_rnum real_zone_by_thing(room_vnum vznum) zone_rnum real_zone_by_thing(room_vnum vznum)
@ -124,6 +123,16 @@ zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top,
fprintf(fp, "$~\n"); fprintf(fp, "$~\n");
fclose(fp); fclose(fp);
/* Create the quests file */
snprintf(buf, sizeof(buf), "%s/%d.qst", QST_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new quest file");
*error = "Could not write quest file.\r\n";
return NOWHERE;
}
fprintf(fp, "$~\n");
fclose(fp);
/* Create the trigger file. */ /* Create the trigger file. */
snprintf(buf, sizeof(buf), "%s/%d.trg", TRG_PREFIX, vzone_num); snprintf(buf, sizeof(buf), "%s/%d.trg", TRG_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) { if (!(fp = fopen(buf, "w"))) {
@ -212,6 +221,9 @@ void create_world_index(int znum, const char *type)
case 't': case 't':
prefix = TRG_PREFIX; prefix = TRG_PREFIX;
break; break;
case 'q':
prefix = QST_PREFIX;
break;
default: default:
/* Caller messed up. */ /* Caller messed up. */
return; return;
@ -242,6 +254,12 @@ void create_world_index(int znum, const char *type)
if (num > znum) { if (num > znum) {
found = TRUE; found = TRUE;
fprintf(newfile, "%s\n", buf1); fprintf(newfile, "%s\n", buf1);
} else if (num == znum) {
/* index file already had an entry for this zone. */
fclose(oldfile);
fclose(newfile);
remove(new_name);
return;
} }
} }
fprintf(newfile, "%s\n", buf); fprintf(newfile, "%s\n", buf);
@ -456,7 +474,7 @@ void add_cmd_to_list(struct reset_com **list, struct reset_com *newcmd, int pos)
/* Remove a reset command from a list. Takes a pointer to the list so that it /* Remove a reset command from a list. Takes a pointer to the list so that it
* may play with the memory locations. */ * may play with the memory locations. */
void remove_cmd_from_list(struct reset_com **list, int pos) static void remove_cmd_from_list(struct reset_com **list, int pos)
{ {
int count, i, l; int count, i, l;
struct reset_com *newlist; struct reset_com *newlist;

View file

@ -1,10 +1,16 @@
/************************************************************************** /**
* File: genzon.h Part of tbaMUD * * @file genzon.h
* * * Generic OLC Library - Zones.
* Usage: Generic OLC Library - Zones. * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * * of, and continuation of, CircleMUD.
**************************************************************************/ *
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _GENZON_H_
#define _GENZON_H_
zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top, const char **error); zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top, const char **error);
void remove_room_zone_commands(zone_rnum zone, room_rnum room_num); void remove_room_zone_commands(zone_rnum zone, room_rnum room_num);
@ -14,4 +20,6 @@ void add_cmd_to_list(struct reset_com **list, struct reset_com *newcmd, int pos)
int new_command(struct zone_data *zone, int pos); int new_command(struct zone_data *zone, int pos);
void delete_zone_command(struct zone_data *zone, int pos); void delete_zone_command(struct zone_data *zone, int pos);
zone_rnum real_zone_by_thing(room_vnum vznum); zone_rnum real_zone_by_thing(room_vnum vznum);
void create_world_index(int znum, const char *type);
#endif /* _GENZON_H_ */

View file

@ -17,21 +17,17 @@
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "spells.h" #include "spells.h"
#include "act.h" /* for the do_say command */
/* external functions */ #include "constants.h"
ACMD(do_say); #include "graph.h"
#include "fight.h"
/* external variables */
extern const char *dirs[];
/* local functions */ /* local functions */
int VALID_EDGE(room_rnum x, int y); static int VALID_EDGE(room_rnum x, int y);
void bfs_enqueue(room_rnum room, int dir); static void bfs_enqueue(room_rnum room, int dir);
void bfs_dequeue(void); static void bfs_dequeue(void);
void bfs_clear_queue(void); static void bfs_clear_queue(void);
int find_first_step(room_rnum src, room_rnum target); static int find_first_step(room_rnum src, room_rnum target);
ACMD(do_track);
void hunt_victim(struct char_data *ch);
struct bfs_queue_struct { struct bfs_queue_struct {
room_rnum room; room_rnum room;
@ -48,7 +44,7 @@ static struct bfs_queue_struct *queue_head = 0, *queue_tail = 0;
#define TOROOM(x, y) (world[(x)].dir_option[(y)]->to_room) #define TOROOM(x, y) (world[(x)].dir_option[(y)]->to_room)
#define IS_CLOSED(x, y) (EXIT_FLAGGED(world[(x)].dir_option[(y)], EX_CLOSED)) #define IS_CLOSED(x, y) (EXIT_FLAGGED(world[(x)].dir_option[(y)], EX_CLOSED))
int VALID_EDGE(room_rnum x, int y) static int VALID_EDGE(room_rnum x, int y)
{ {
if (world[x].dir_option[y] == NULL || TOROOM(x, y) == NOWHERE) if (world[x].dir_option[y] == NULL || TOROOM(x, y) == NOWHERE)
return 0; return 0;
@ -60,7 +56,7 @@ int VALID_EDGE(room_rnum x, int y)
return 1; return 1;
} }
void bfs_enqueue(room_rnum room, int dir) static void bfs_enqueue(room_rnum room, int dir)
{ {
struct bfs_queue_struct *curr; struct bfs_queue_struct *curr;
@ -76,7 +72,7 @@ void bfs_enqueue(room_rnum room, int dir)
queue_head = queue_tail = curr; queue_head = queue_tail = curr;
} }
void bfs_dequeue(void) static void bfs_dequeue(void)
{ {
struct bfs_queue_struct *curr; struct bfs_queue_struct *curr;
@ -87,7 +83,7 @@ void bfs_dequeue(void)
free(curr); free(curr);
} }
void bfs_clear_queue(void) static void bfs_clear_queue(void)
{ {
while (queue_head) while (queue_head)
bfs_dequeue(); bfs_dequeue();
@ -97,7 +93,7 @@ void bfs_clear_queue(void)
* on the shortest path from the source to the target. Intended usage: in * on the shortest path from the source to the target. Intended usage: in
* mobile_activity, give a mob a dir to go if they're tracking another mob or a * mobile_activity, give a mob a dir to go if they're tracking another mob or a
* PC. Or, a 'track' skill for PCs. */ * PC. Or, a 'track' skill for PCs. */
int find_first_step(room_rnum src, room_rnum target) static int find_first_step(room_rnum src, room_rnum target)
{ {
int curr_dir; int curr_dir;
room_rnum curr_room; room_rnum curr_room;

View file

@ -18,23 +18,19 @@
#include "interpreter.h" #include "interpreter.h"
#include "spells.h" #include "spells.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "act.h"
#include "class.h"
#include "fight.h"
#include "quest.h"
/* local vars */ /* local file scope variables */
int extractions_pending = 0; static int extractions_pending = 0;
/* external vars */ /* local file scope functions */
extern struct char_data *combat_list; static int apply_ac(struct char_data *ch, int eq_pos);
static void update_object(struct obj_data *obj, int use);
static void affect_modify(struct char_data *ch, byte loc, sbyte mod, long bitv, bool add);
/* local functions */
int apply_ac(struct char_data *ch, int eq_pos);
void update_object(struct obj_data *obj, int use);
void update_char_objects(struct char_data *ch);
void affect_modify(struct char_data *ch, byte loc, sbyte mod, long bitv, bool add);
/* external functions */
int invalid_class(struct char_data *ch, struct obj_data *obj);
void clearMemory(struct char_data *ch);
ACMD(do_return);
char *fname(const char *namelist) char *fname(const char *namelist)
{ {
@ -207,7 +203,7 @@ void aff_apply_modify(struct char_data *ch, byte loc, sbyte mod, char *msg)
} /* switch */ } /* switch */
} }
void affect_modify(struct char_data * ch, byte loc, sbyte mod, long bitv, bool add) static void affect_modify(struct char_data * ch, byte loc, sbyte mod, long bitv, bool add)
{ {
if (add) { if (add) {
SET_BIT_AR(AFF_FLAGS(ch), bitv); SET_BIT_AR(AFF_FLAGS(ch), bitv);
@ -412,6 +408,9 @@ void char_to_room(struct char_data *ch, room_rnum room)
world[room].people = ch; world[room].people = ch;
IN_ROOM(ch) = room; IN_ROOM(ch) = room;
autoquest_trigger_check(ch, 0, 0, AQ_ROOM_FIND);
autoquest_trigger_check(ch, 0, 0, AQ_MOB_FIND);
if (GET_EQ(ch, WEAR_LIGHT)) if (GET_EQ(ch, WEAR_LIGHT))
if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT)
if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) /* Light ON */ if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) /* Light ON */
@ -435,6 +434,8 @@ void obj_to_char(struct obj_data *object, struct char_data *ch)
IN_ROOM(object) = NOWHERE; IN_ROOM(object) = NOWHERE;
IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object); IS_CARRYING_W(ch) += GET_OBJ_WEIGHT(object);
IS_CARRYING_N(ch)++; IS_CARRYING_N(ch)++;
autoquest_trigger_check(ch, NULL, object, AQ_OBJ_FIND);
/* set flag for crash-save system, but not on mobs! */ /* set flag for crash-save system, but not on mobs! */
if (!IS_NPC(ch)) if (!IS_NPC(ch))
@ -465,7 +466,7 @@ void obj_from_char(struct obj_data *object)
} }
/* Return the effect of a piece of armor in position eq_pos */ /* Return the effect of a piece of armor in position eq_pos */
int apply_ac(struct char_data *ch, int eq_pos) static int apply_ac(struct char_data *ch, int eq_pos)
{ {
int factor; int factor;
@ -820,7 +821,7 @@ void extract_obj(struct obj_data *obj)
free_obj(obj); free_obj(obj);
} }
void update_object(struct obj_data *obj, int use) static void update_object(struct obj_data *obj, int use)
{ {
/* dont update objects with a timer trigger */ /* dont update objects with a timer trigger */
if (!SCRIPT_CHECK(obj, OTRIG_TIMER) && (GET_OBJ_TIMER(obj) > 0)) if (!SCRIPT_CHECK(obj, OTRIG_TIMER) && (GET_OBJ_TIMER(obj) > 0))

View file

@ -1,13 +1,16 @@
/************************************************************************** /**
* File: handler.h Part of tbaMUD * * @file handler.h
* * * Prototypes of handling and utility functions.
* Usage: header file: prototypes of handling and utility functions * *
* * * Part of the core tbaMUD source code distribution, which is a derivative
* All rights reserved. See license for complete information. * * of, and continuation of, CircleMUD.
* * *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * * All rights reserved. See license for complete information.
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University
**************************************************************************/ * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.
*/
#ifndef _HANDLER_H_
#define _HANDLER_H_
/* handling the affected-structures */ /* handling the affected-structures */
void affect_total(struct char_data *ch); void affect_total(struct char_data *ch);
@ -42,6 +45,8 @@ void object_list_new_owner(struct obj_data *list, struct char_data *ch);
void extract_obj(struct obj_data *obj); void extract_obj(struct obj_data *obj);
void update_char_objects(struct char_data *ch);
/* characters*/ /* characters*/
struct char_data *get_char_room(char *name, int *num, room_rnum room); struct char_data *get_char_room(char *name, int *num, room_rnum room);
struct char_data *get_char_num(mob_rnum nr); struct char_data *get_char_num(mob_rnum nr);
@ -85,28 +90,15 @@ int generic_find(char *arg, bitvector_t bitvector, struct char_data *ch,
#define FIND_OBJ_EQUIP (1 << 5) #define FIND_OBJ_EQUIP (1 << 5)
/* prototypes from crash save system */ /* prototypes from mobact.c */
int Crash_delete_file(char *name); void forget(struct char_data *ch, struct char_data *victim);
int Crash_delete_crashfile(struct char_data *ch); void remember(struct char_data *ch, struct char_data *victim);
int Crash_clean_file(char *name); void mobile_activity(void);
void Crash_listrent(struct char_data *ch, char *name); void clearMemory(struct char_data *ch);
int Crash_load(struct char_data *ch);
void Crash_crashsave(struct char_data *ch);
void Crash_idlesave(struct char_data *ch);
void Crash_save_all(void);
/* prototypes from fight.c */
void set_fighting(struct char_data *ch, struct char_data *victim);
void stop_fighting(struct char_data *ch);
void hit(struct char_data *ch, struct char_data *victim, int type);
void forget(struct char_data *ch, struct char_data *victim);
void remember(struct char_data *ch, struct char_data *victim);
int damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype);
int skill_message(int dam, struct char_data *ch, struct char_data *vict,
int attacktype);
/* For new last command: */ /* For new last command: */
#define LAST_FILE LIB_ETC"last" #define LAST_FILE LIB_ETC "last"
#define LAST_CONNECT 0 #define LAST_CONNECT 0
#define LAST_ENTER_GAME 1 #define LAST_ENTER_GAME 1
@ -132,3 +124,5 @@ struct last_entry {
void add_llog_entry(struct char_data *ch, int type); void add_llog_entry(struct char_data *ch, int type);
struct last_entry *find_llog_entry(int punique, long idnum); struct last_entry *find_llog_entry(int punique, long idnum);
#endif /* _HANDLER_H_ */

View file

@ -13,9 +13,9 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "utils.h"
#include "db.h" #include "db.h"
#include "boards.h" #include "boards.h"
#include "oasis.h" #include "oasis.h"
@ -23,26 +23,17 @@
#include "genzon.h" #include "genzon.h"
#include "handler.h" #include "handler.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "act.h"
/* external variables */ #include "hedit.h"
extern int top_of_helpt; #include "modify.h"
extern struct help_index_element *help_table;
/* external functions */
int search_help(char *argument, int level);
void index_boot(int mode);
/* local functions */ /* local functions */
ACMD(do_oasis_hedit); static void hedit_disp_menu(struct descriptor_data *);
void hedit_disp_menu(struct descriptor_data *); static void hedit_setup_new(struct descriptor_data *);
void hedit_parse(struct descriptor_data *, char *); static void hedit_setup_existing(struct descriptor_data *, int);
void hedit_setup_new(struct descriptor_data *); static void hedit_save_to_disk(struct descriptor_data *);
void hedit_setup_existing(struct descriptor_data *, int); static void hedit_save_internally(struct descriptor_data *);
void hedit_save_to_disk(struct descriptor_data *);
void hedit_save_internally(struct descriptor_data *);
void hedit_string_cleanup(struct descriptor_data *, int);
ACMD(do_helpcheck);
ACMD(do_hindex);
ACMD(do_oasis_hedit) ACMD(do_oasis_hedit)
{ {
@ -107,7 +98,7 @@ ACMD(do_oasis_hedit)
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing help files.", GET_NAME(d->character)); mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing help files.", GET_NAME(d->character));
} }
void hedit_setup_new(struct descriptor_data *d) static void hedit_setup_new(struct descriptor_data *d)
{ {
CREATE(OLC_HELP(d), struct help_index_element, 1); CREATE(OLC_HELP(d), struct help_index_element, 1);
@ -120,7 +111,7 @@ void hedit_setup_new(struct descriptor_data *d)
hedit_disp_menu(d); hedit_disp_menu(d);
} }
void hedit_setup_existing(struct descriptor_data *d, int rnum) static void hedit_setup_existing(struct descriptor_data *d, int rnum)
{ {
CREATE(OLC_HELP(d), struct help_index_element, 1); CREATE(OLC_HELP(d), struct help_index_element, 1);
@ -133,7 +124,7 @@ void hedit_setup_existing(struct descriptor_data *d, int rnum)
hedit_disp_menu(d); hedit_disp_menu(d);
} }
void hedit_save_internally(struct descriptor_data *d) static void hedit_save_internally(struct descriptor_data *d)
{ {
struct help_index_element *new_help_table = NULL; struct help_index_element *new_help_table = NULL;
@ -153,7 +144,7 @@ void hedit_save_internally(struct descriptor_data *d)
hedit_save_to_disk(d); hedit_save_to_disk(d);
} }
void hedit_save_to_disk(struct descriptor_data *d) static void hedit_save_to_disk(struct descriptor_data *d)
{ {
FILE *fp; FILE *fp;
char buf1[MAX_STRING_LENGTH], index_name[READ_SIZE]; char buf1[MAX_STRING_LENGTH], index_name[READ_SIZE];
@ -186,7 +177,7 @@ void hedit_save_to_disk(struct descriptor_data *d)
} }
/* The main menu. */ /* The main menu. */
void hedit_disp_menu(struct descriptor_data *d) static void hedit_disp_menu(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
@ -367,7 +358,6 @@ void hedit_string_cleanup(struct descriptor_data *d, int terminator)
ACMD(do_helpcheck) ACMD(do_helpcheck)
{ {
ACMD(do_action);
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
int i, count = 0; int i, count = 0;

View file

@ -11,47 +11,39 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "interpreter.h" #include "interpreter.h"
#include "utils.h"
#include "house.h" #include "house.h"
#include "constants.h" #include "constants.h"
#include "modify.h"
/* external functions */ /* local (file scope only) globals */
obj_save_data *objsave_parse_objects(FILE *fl); static struct house_control_rec house_control[MAX_HOUSES];
int objsave_save_obj_record(struct obj_data *obj, FILE *fl, int location); static int num_of_houses = 0;
/* local globals */
struct house_control_rec house_control[MAX_HOUSES];
int num_of_houses = 0;
/* local functions */ /* local functions */
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen); static int House_get_filename(room_vnum vnum, char *filename, size_t maxlen);
int House_load(room_vnum vnum); static int House_load(room_vnum vnum);
int House_save(struct obj_data *obj, FILE *fp); static void House_restore_weight(struct obj_data *obj);
void House_restore_weight(struct obj_data *obj); static void House_delete_file(room_vnum vnum);
void House_delete_file(room_vnum vnum); static int find_house(room_vnum vnum);
int find_house(room_vnum vnum); static void House_save_control(void);
void House_save_control(void); static void hcontrol_build_house(struct char_data *ch, char *arg);
void hcontrol_list_houses(struct char_data *ch, char *arg); static void hcontrol_destroy_house(struct char_data *ch, char *arg);
void hcontrol_build_house(struct char_data *ch, char *arg); static void hcontrol_pay_house(struct char_data *ch, char *arg);
void hcontrol_destroy_house(struct char_data *ch, char *arg); static void House_listrent(struct char_data *ch, room_vnum vnum);
void hcontrol_pay_house(struct char_data *ch, char *arg);
void House_listrent(struct char_data *ch, room_vnum vnum);
ACMD(do_hcontrol);
ACMD(do_house);
/* CONVERSION code starts here -- see comment below. */ /* CONVERSION code starts here -- see comment below. */
int ascii_convert_house(struct char_data *ch, obj_vnum vnum); static int ascii_convert_house(struct char_data *ch, obj_vnum vnum);
void hcontrol_convert_houses(struct char_data *ch); static void hcontrol_convert_houses(struct char_data *ch);
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location); static struct obj_data *Obj_from_store(struct obj_file_elem object, int *location);
/* CONVERSION code ends here -- see comment below. */ /* CONVERSION code ends here -- see comment below. */
/* First, the basics: finding the filename; loading/saving objects */ /* First, the basics: finding the filename; loading/saving objects */
/* Return a filename given a house vnum */ /* Return a filename given a house vnum */
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen) static int House_get_filename(room_vnum vnum, char *filename, size_t maxlen)
{ {
if (vnum == NOWHERE) if (vnum == NOWHERE)
return (0); return (0);
@ -61,7 +53,7 @@ int House_get_filename(room_vnum vnum, char *filename, size_t maxlen)
} }
/* Load all objects for a house */ /* Load all objects for a house */
int House_load(room_vnum vnum) static int House_load(room_vnum vnum)
{ {
FILE *fl; FILE *fl;
char filename[MAX_STRING_LENGTH]; char filename[MAX_STRING_LENGTH];
@ -115,7 +107,7 @@ int House_save(struct obj_data *obj, FILE *fp)
} }
/* restore weight of containers after House_save has changed them for saving */ /* restore weight of containers after House_save has changed them for saving */
void House_restore_weight(struct obj_data *obj) static void House_restore_weight(struct obj_data *obj)
{ {
if (obj) { if (obj) {
House_restore_weight(obj->contains); House_restore_weight(obj->contains);
@ -150,7 +142,7 @@ void House_crashsave(room_vnum vnum)
} }
/* Delete a house save file */ /* Delete a house save file */
void House_delete_file(room_vnum vnum) static void House_delete_file(room_vnum vnum)
{ {
char filename[MAX_INPUT_LENGTH]; char filename[MAX_INPUT_LENGTH];
FILE *fl; FILE *fl;
@ -168,7 +160,7 @@ void House_delete_file(room_vnum vnum)
} }
/* List all objects in a house file */ /* List all objects in a house file */
void House_listrent(struct char_data *ch, room_vnum vnum) static void House_listrent(struct char_data *ch, room_vnum vnum)
{ {
FILE *fl; FILE *fl;
char filename[MAX_STRING_LENGTH]; char filename[MAX_STRING_LENGTH];
@ -206,7 +198,7 @@ void House_listrent(struct char_data *ch, room_vnum vnum)
} }
/* Functions for house administration (creation, deletion, etc. */ /* Functions for house administration (creation, deletion, etc. */
int find_house(room_vnum vnum) static int find_house(room_vnum vnum)
{ {
int i; int i;
@ -218,7 +210,7 @@ int find_house(room_vnum vnum)
} }
/* Save the house control information */ /* Save the house control information */
void House_save_control(void) static void House_save_control(void)
{ {
FILE *fl; FILE *fl;
@ -351,7 +343,7 @@ void hcontrol_list_houses(struct char_data *ch, char *arg)
} }
} }
void hcontrol_build_house(struct char_data *ch, char *arg) static void hcontrol_build_house(struct char_data *ch, char *arg)
{ {
char arg1[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH];
struct house_control_rec temp_house; struct house_control_rec temp_house;
@ -435,7 +427,7 @@ void hcontrol_build_house(struct char_data *ch, char *arg)
House_save_control(); House_save_control();
} }
void hcontrol_destroy_house(struct char_data *ch, char *arg) static void hcontrol_destroy_house(struct char_data *ch, char *arg)
{ {
int i, j; int i, j;
room_rnum real_atrium, real_house; room_rnum real_atrium, real_house;
@ -477,7 +469,7 @@ void hcontrol_destroy_house(struct char_data *ch, char *arg)
SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
} }
void hcontrol_pay_house(struct char_data *ch, char *arg) static void hcontrol_pay_house(struct char_data *ch, char *arg)
{ {
int i; int i;
@ -630,7 +622,7 @@ void House_list_guests(struct char_data *ch, int i, int quiet)
* will let your house files load on the next bootup. -Welcor * * will let your house files load on the next bootup. -Welcor *
************************************************************************/ ************************************************************************/
/* Code for conversion to ascii house rent files. */ /* Code for conversion to ascii house rent files. */
void hcontrol_convert_houses(struct char_data *ch) static void hcontrol_convert_houses(struct char_data *ch)
{ {
int i; int i;
@ -664,7 +656,7 @@ void hcontrol_convert_houses(struct char_data *ch)
send_to_char(ch, "All done.\r\n"); send_to_char(ch, "All done.\r\n");
} }
int ascii_convert_house(struct char_data *ch, obj_vnum vnum) static int ascii_convert_house(struct char_data *ch, obj_vnum vnum)
{ {
FILE *in, *out; FILE *in, *out;
char infile[MAX_INPUT_LENGTH], *outfile; char infile[MAX_INPUT_LENGTH], *outfile;
@ -729,7 +721,7 @@ int ascii_convert_house(struct char_data *ch, obj_vnum vnum)
} }
/* The circle 3.1 function for reading rent files. No longer used by the rent system. */ /* The circle 3.1 function for reading rent files. No longer used by the rent system. */
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location) static struct obj_data *Obj_from_store(struct obj_file_elem object, int *location)
{ {
struct obj_data *obj; struct obj_data *obj;
obj_rnum itemnum; obj_rnum itemnum;

View file

@ -1,3 +1,17 @@
/**
* @file house.h
* Player house structures, prototypes and defines.
*
* Part of the core tbaMUD source code distribution, which is a derivative
* of, and continuation of, CircleMUD.
*
* All rights reserved. See license 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 _HOUSE_H_
#define _HOUSE_H_
#define MAX_HOUSES 100 #define MAX_HOUSES 100
#define MAX_GUESTS 10 #define MAX_GUESTS 10
@ -26,8 +40,18 @@ struct house_control_rec {
#define TOROOM(room, dir) (world[room].dir_option[dir] ? \ #define TOROOM(room, dir) (world[room].dir_option[dir] ? \
world[room].dir_option[dir]->to_room : NOWHERE) world[room].dir_option[dir]->to_room : NOWHERE)
/* Functions in house.c made externally available */
/* Utility Functions */
void House_boot(void); void House_boot(void);
void House_save_all(void); void House_save_all(void);
int House_can_enter(struct char_data *ch, room_vnum house); int House_can_enter(struct char_data *ch, room_vnum house);
void House_crashsave(room_vnum vnum); void House_crashsave(room_vnum vnum);
void House_list_guests(struct char_data *ch, int i, int quiet); void House_list_guests(struct char_data *ch, int i, int quiet);
int House_save(struct obj_data *obj, FILE *fp);
void hcontrol_list_houses(struct char_data *ch, char *arg);
/* In game Commands */
ACMD(do_hcontrol);
ACMD(do_house);
#endif /* _HOUSE_H_ */

View file

@ -11,8 +11,9 @@
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_scripts.h"
#include "modify.h"
int format_script(struct descriptor_data *d);
void send_editor_help(struct descriptor_data *d) void send_editor_help(struct descriptor_data *d)
{ {

View file

@ -1,8 +1,14 @@
/************************************************************************** /**
* File: improved-edit.h Part of tbaMUD * * @file improved-edit.h
* * * The basic and improved editor.
* Usage: The basic and improved editor. * *
**************************************************************************/ * Part of the core tbaMUD source code distribution, which is a derivative
* of, and continuation of, CircleMUD.
*
* This set of code was not originally part of the circlemud distribution.
*/
#ifndef _IMPROVED_EDIT_H_
#define _IMPROVED_EDIT_H_
/* This is here to allow different code for the basic and improved editor. If /* This is here to allow different code for the basic and improved editor. If
* you do not wish to use the improved editor, put #if 0 below, otherwise you * you do not wish to use the improved editor, put #if 0 below, otherwise you
@ -35,3 +41,5 @@ void send_editor_help(struct descriptor_data *d);
/* Settings for formatter. */ /* Settings for formatter. */
#define FORMAT_INDENT (1 << 0) #define FORMAT_INDENT (1 << 0)
#endif /* _IMPROVED_EDIT_H_ */

View file

@ -13,10 +13,10 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "db.h" #include "db.h"
#include "utils.h"
#include "spells.h" #include "spells.h"
#include "handler.h" #include "handler.h"
#include "mail.h" #include "mail.h"
@ -26,204 +26,28 @@
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "constants.h" #include "constants.h"
#include "act.h" /* ACMDs located within the act*.c files */
#include "ban.h"
#include "class.h"
#include "graph.h"
#include "hedit.h"
#include "house.h"
#include "config.h"
#include "modify.h" /* for do_skillset... */
#include "quest.h"
#include "asciimap.h"
/* external variables */ /* local (file scope) functions */
extern room_rnum r_mortal_start_room; static int perform_dupe_check(struct descriptor_data *d);
extern room_rnum r_immort_start_room; static struct alias_data *find_alias(struct alias_data *alias_list, char *str);
extern room_rnum r_frozen_start_room; static void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a);
extern const char *class_menu; static int reserved_word(char *argument);
extern char *motd; static int _parse_name(char *arg, char *name);
extern char *imotd; /* sort_commands utility */
extern char *background; static int sort_commands_helper(const void *a, const void *b);
extern struct player_index_element *player_table;
extern int top_of_p_table;
extern int circle_restrict;
extern int no_specials;
extern int selfdelete_fastwipe;
/* external functions */ /* globals defined here, used here and elsewhere */
void echo_on(struct descriptor_data *d); int *cmd_sort_info = NULL;
void echo_off(struct descriptor_data *d);
void do_start(struct char_data *ch);
int parse_class(char arg);
int special(struct char_data *ch, int cmd, char *arg);
int isbanned(char *hostname);
int valid_name(char *newname);
void remove_player(int pfilepos);
/* local functions */
int perform_dupe_check(struct descriptor_data *d);
struct alias_data *find_alias(struct alias_data *alias_list, char *str);
void free_alias(struct alias_data *a);
void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a);
int perform_alias(struct descriptor_data *d, char *orig, size_t maxlen);
int reserved_word(char *argument);
int _parse_name(char *arg, char *name);
int enter_player_game (struct descriptor_data *d);
/* prototypes for all do_x functions. */
ACMD(do_action);
ACMD(do_advance);
ACMD(do_aedit);
ACMD(do_alias);
ACMD(do_assist);
ACMD(do_astat);
ACMD(do_at);
ACMD(do_attach);
ACMD(do_backstab);
ACMD(do_ban);
ACMD(do_bash);
ACMD(do_cast);
ACMD(do_changelog);
ACMD(do_checkloadstatus);
ACMD(do_commands);
ACMD(do_consider);
ACMD(do_copyover);
ACMD(do_credits);
ACMD(do_date);
ACMD(do_dc);
ACMD(do_detach);
ACMD(do_diagnose);
ACMD(do_dig);
ACMD(do_display);
ACMD(do_drink);
ACMD(do_drop);
ACMD(do_eat);
ACMD(do_echo);
ACMD(do_enter);
ACMD(do_equipment);
ACMD(do_examine);
ACMD(do_exit);
ACMD(do_exits);
ACMD(do_export_zone);
ACMD(do_file);
ACMD(do_flee);
ACMD(do_follow);
ACMD(do_force);
ACMD(do_gecho);
ACMD(do_gen_comm);
ACMD(do_gen_door);
ACMD(do_gen_ps);
ACMD(do_gen_tog);
ACMD(do_gen_write);
ACMD(do_get);
ACMD(do_give);
ACMD(do_gold);
ACMD(do_goto);
ACMD(do_grab);
ACMD(do_group);
ACMD(do_gsay);
ACMD(do_hcontrol);
ACMD(do_help);
ACMD(do_hindex);
ACMD(do_history);
ACMD(do_helpcheck);
ACMD(do_hide);
ACMD(do_hit);
ACMD(do_house);
ACMD(do_inventory);
ACMD(do_invis);
ACMD(do_kick);
ACMD(do_kill);
ACMD(do_last);
ACMD(do_leave);
ACMD(do_levels);
ACMD(do_links);
ACMD(do_load);
ACMD(do_look);
ACMD(do_masound);
ACMD(do_mat);
ACMD(do_mdamage);
ACMD(do_mdoor);
ACMD(do_mecho);
ACMD(do_mechoaround);
ACMD(do_mfollow);
ACMD(do_mforce);
ACMD(do_mgoto);
ACMD(do_mhunt);
ACMD(do_mjunk);
ACMD(do_mkill);
ACMD(do_mload);
/* ACMD(do_move); -- interpreter.h */
ACMD(do_mpurge);
ACMD(do_msend);
ACMD(do_mteleport);
ACMD(do_mremember);
ACMD(do_mforget);
ACMD(do_mtransform);
ACMD(do_mzoneecho);
ACMD(do_mrecho);
ACMD(do_not_here);
ACMD(do_oasis_copy);
ACMD(do_order);
ACMD(do_page);
ACMD(do_peace);
ACMD(do_plist);
ACMD(do_pour);
ACMD(do_practice);
ACMD(do_purge);
ACMD(do_put);
ACMD(do_qcomm);
ACMD(do_quit);
ACMD(do_reboot);
ACMD(do_remove);
ACMD(do_reply);
ACMD(do_report);
ACMD(do_rescue);
ACMD(do_rest);
ACMD(do_restore);
ACMD(do_return);
ACMD(do_save);
ACMD(do_saveall);
ACMD(do_say);
ACMD(do_score);
ACMD(do_send);
ACMD(do_set);
ACMD(do_show);
ACMD(do_show_save_list);
ACMD(do_shutdown);
ACMD(do_sit);
ACMD(do_skillset);
ACMD(do_sleep);
ACMD(do_sneak);
ACMD(do_snoop);
ACMD(do_spec_comm);
ACMD(do_split);
ACMD(do_stand);
ACMD(do_stat);
ACMD(do_steal);
ACMD(do_switch);
ACMD(do_teleport);
ACMD(do_tell);
ACMD(do_time);
ACMD(do_title);
ACMD(do_tlist);
ACMD(do_toggle);
ACMD(do_track);
ACMD(do_trans);
ACMD(do_tstat);
ACMD(do_unban);
ACMD(do_ungroup);
ACMD(do_use);
ACMD(do_users);
ACMD(do_vdelete);
ACMD(do_visible);
ACMD(do_vnum);
ACMD(do_vstat);
ACMD(do_wake);
ACMD(do_wear);
ACMD(do_weather);
ACMD(do_where);
ACMD(do_who);
ACMD(do_wield);
ACMD(do_wizlock);
ACMD(do_wiznet);
ACMD(do_wizupdate);
ACMD(do_wizutil);
ACMD(do_write);
ACMD(do_zcheck);
ACMD(do_zreset);
ACMD(do_zpurge);
struct command_info *complete_cmd_info; struct command_info *complete_cmd_info;
@ -257,14 +81,14 @@ cpp_extern const struct command_info cmd_info[] = {
{ "astat" , "ast" , POS_DEAD , do_astat , 0, 0 }, { "astat" , "ast" , POS_DEAD , do_astat , 0, 0 },
{ "attach" , "attach" , POS_DEAD , do_attach , LVL_BUILDER, 0 }, { "attach" , "attach" , POS_DEAD , do_attach , LVL_BUILDER, 0 },
{ "auction" , "auc" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION }, { "auction" , "auc" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION },
{ "autoexits" , "autoex" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOEXIT }, { "autoexits" , "autoex" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOEXIT },
{ "backstab" , "ba" , POS_STANDING, do_backstab , 1, 0 }, { "backstab" , "ba" , POS_STANDING, do_backstab , 1, 0 },
{ "ban" , "ban" , POS_DEAD , do_ban , LVL_GRGOD, 0 }, { "ban" , "ban" , POS_DEAD , do_ban , LVL_GRGOD, 0 },
{ "balance" , "bal" , POS_STANDING, do_not_here , 1, 0 }, { "balance" , "bal" , POS_STANDING, do_not_here , 1, 0 },
{ "bash" , "bas" , POS_FIGHTING, do_bash , 1, 0 }, { "bash" , "bas" , POS_FIGHTING, do_bash , 1, 0 },
{ "brief" , "br" , POS_DEAD , do_gen_tog , 0, SCMD_BRIEF }, { "brief" , "br" , POS_DEAD , do_gen_tog , 0, SCMD_BRIEF },
{ "buildwalk", "buildwalk", POS_STANDING, do_gen_tog, LVL_BUILDER, SCMD_BUILDWALK }, { "buildwalk", "buildwalk", POS_STANDING, do_gen_tog , LVL_BUILDER, SCMD_BUILDWALK },
{ "buy" , "bu" , POS_STANDING, do_not_here , 0, 0 }, { "buy" , "bu" , POS_STANDING, do_not_here , 0, 0 },
{ "bug" , "bug" , POS_DEAD , do_gen_write, 0, SCMD_BUG }, { "bug" , "bug" , POS_DEAD , do_gen_write, 0, SCMD_BUG },
@ -360,8 +184,9 @@ cpp_extern const struct command_info cmd_info[] = {
{ "motd" , "motd" , POS_DEAD , do_gen_ps , 0, SCMD_MOTD }, { "motd" , "motd" , POS_DEAD , do_gen_ps , 0, SCMD_MOTD },
{ "mail" , "mail" , POS_STANDING, do_not_here , 1, 0 }, { "mail" , "mail" , POS_STANDING, do_not_here , 1, 0 },
{ "map" , "map" , POS_STANDING, do_map , 1, 0 },
{ "medit" , "med" , POS_DEAD , do_oasis_medit, LVL_BUILDER, 0 }, { "medit" , "med" , POS_DEAD , do_oasis_medit, LVL_BUILDER, 0 },
{ "mlist" , "mlist" , POS_DEAD , do_oasis_list , LVL_BUILDER, SCMD_OASIS_MLIST }, { "mlist" , "mlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_MLIST },
{ "mcopy" , "mcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_MEDIT }, { "mcopy" , "mcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_MEDIT },
{ "mute" , "mute" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_MUTE }, { "mute" , "mute" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_MUTE },
@ -388,7 +213,7 @@ cpp_extern const struct command_info cmd_info[] = {
{ "put" , "p" , POS_RESTING , do_put , 0, 0 }, { "put" , "p" , POS_RESTING , do_put , 0, 0 },
{ "peace" , "pe" , POS_DEAD , do_peace , LVL_BUILDER, 0 }, { "peace" , "pe" , POS_DEAD , do_peace , LVL_BUILDER, 0 },
{ "pick" , "pi" , POS_STANDING, do_gen_door , 1, SCMD_PICK }, { "pick" , "pi" , POS_STANDING, do_gen_door , 1, SCMD_PICK },
{ "practice" , "pr" , POS_RESTING , do_practice , 1, 0 }, { "practice" , "pr" , POS_RESTING , do_practice , 1, 0 },
{ "page" , "pag" , POS_DEAD , do_page , 1, 0 }, { "page" , "pag" , POS_DEAD , do_page , 1, 0 },
{ "pardon" , "pardon" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_PARDON }, { "pardon" , "pardon" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_PARDON },
{ "plist" , "plist" , POS_DEAD , do_plist , LVL_GOD, 0 }, { "plist" , "plist" , POS_DEAD , do_plist , LVL_GOD, 0 },
@ -397,9 +222,11 @@ cpp_extern const struct command_info cmd_info[] = {
{ "prompt" , "pro" , POS_DEAD , do_display , 0, 0 }, { "prompt" , "pro" , POS_DEAD , do_display , 0, 0 },
{ "purge" , "purge" , POS_DEAD , do_purge , LVL_BUILDER, 0 }, { "purge" , "purge" , POS_DEAD , do_purge , LVL_BUILDER, 0 },
{ "qedit" , "qedit" , POS_DEAD , do_oasis_qedit, LVL_BUILDER, 0 },
{ "qlist" , "qlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_QLIST },
{ "quaff" , "qua" , POS_RESTING , do_use , 0, SCMD_QUAFF }, { "quaff" , "qua" , POS_RESTING , do_use , 0, SCMD_QUAFF },
{ "qecho" , "qec" , POS_DEAD , do_qcomm , LVL_GOD, SCMD_QECHO }, { "qecho" , "qec" , POS_DEAD , do_qcomm , LVL_GOD, SCMD_QECHO },
{ "quest" , "que" , POS_DEAD , do_gen_tog , 0, SCMD_QUEST }, { "quest" , "que" , POS_DEAD , do_quest , 0, 0 },
{ "qui" , "qui" , POS_DEAD , do_quit , 0, 0 }, { "qui" , "qui" , POS_DEAD , do_quit , 0, 0 },
{ "quit" , "quit" , POS_DEAD , do_quit , 0, SCMD_QUIT }, { "quit" , "quit" , POS_DEAD , do_quit , 0, SCMD_QUIT },
{ "qsay" , "qsay" , POS_RESTING , do_qcomm , 0, SCMD_QSAY }, { "qsay" , "qsay" , POS_RESTING , do_qcomm , 0, SCMD_QSAY },
@ -505,7 +332,7 @@ cpp_extern const struct command_info cmd_info[] = {
{ "zcheck" , "zcheck" , POS_DEAD , do_zcheck , LVL_GOD, 0 }, { "zcheck" , "zcheck" , POS_DEAD , do_zcheck , LVL_GOD, 0 },
{ "zpurge" , "zpurge" , POS_DEAD , do_zpurge , LVL_BUILDER, 0 }, { "zpurge" , "zpurge" , POS_DEAD , do_zpurge , LVL_BUILDER, 0 },
/* DG trigger commands */ /* DG trigger commands. minimum_level should be set to -1. */
{ "masound" , "masound" , POS_DEAD , do_masound , -1, 0 }, { "masound" , "masound" , POS_DEAD , do_masound , -1, 0 },
{ "mkill" , "mkill" , POS_STANDING, do_mkill , -1, 0 }, { "mkill" , "mkill" , POS_STANDING, do_mkill , -1, 0 },
{ "mjunk" , "mjunk" , POS_SITTING , do_mjunk , -1, 0 }, { "mjunk" , "mjunk" , POS_SITTING , do_mjunk , -1, 0 },
@ -555,6 +382,30 @@ const char *reserved[] =
"\n" "\n"
}; };
static int sort_commands_helper(const void *a, const void *b)
{
return strcmp(complete_cmd_info[*(const int *)a].sort_as,
complete_cmd_info[*(const int *)b].sort_as);
}
void sort_commands(void)
{
int a, num_of_cmds = 0;
while (complete_cmd_info[num_of_cmds].command[0] != '\n')
num_of_cmds++;
num_of_cmds++; /* \n */
CREATE(cmd_sort_info, int, num_of_cmds);
for (a = 0; a < num_of_cmds; a++)
cmd_sort_info[a] = a;
/* Don't sort the RESERVED or \n entries. */
qsort(cmd_sort_info + 1, num_of_cmds - 2, sizeof(int), sort_commands_helper);
}
/* This is the actual command interpreter called from game_loop() in comm.c /* This is the actual command interpreter called from game_loop() in comm.c
* It makes sure you are the proper level and position to execute the command, * It makes sure you are the proper level and position to execute the command,
* then calls the appropriate function. */ * then calls the appropriate function. */
@ -610,12 +461,17 @@ void command_interpreter(struct char_data *ch, char *argument)
int found = 0; int found = 0;
send_to_char(ch, "Huh!?!\r\n"); send_to_char(ch, "Huh!?!\r\n");
for (cmd = 0; *cmd_info[cmd].command != '\n'; cmd++) { for (cmd = 0; *cmd_info[cmd].command != '\n'; cmd++)
{
if (*arg != *cmd_info[cmd].command || cmd_info[cmd].minimum_level > GET_LEVEL(ch)) if (*arg != *cmd_info[cmd].command || cmd_info[cmd].minimum_level > GET_LEVEL(ch))
continue; continue;
if (levenshtein_distance(arg, (char *) cmd_info[cmd].command) <= 2) { /* Only apply levenshtein counts if the command is not a trigger command. */
if (!found) { if ( (levenshtein_distance(arg, (char *) cmd_info[cmd].command) <= 2) &&
(cmd_info[cmd].minimum_level >= 0) )
{
if (!found)
{
send_to_char(ch, "\r\nDid you mean:\r\n"); send_to_char(ch, "\r\nDid you mean:\r\n");
found = 1; found = 1;
} }
@ -658,7 +514,7 @@ void command_interpreter(struct char_data *ch, char *argument)
} }
/* Routines to handle aliasing. */ /* Routines to handle aliasing. */
struct alias_data *find_alias(struct alias_data *alias_list, char *str) static struct alias_data *find_alias(struct alias_data *alias_list, char *str)
{ {
while (alias_list != NULL) { while (alias_list != NULL) {
if (*str == *alias_list->alias) /* hey, every little bit counts :-) */ if (*str == *alias_list->alias) /* hey, every little bit counts :-) */
@ -741,7 +597,7 @@ ACMD(do_alias)
* commands. */ * commands. */
#define NUM_TOKENS 9 #define NUM_TOKENS 9
void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a) static void perform_complex_alias(struct txt_q *input_q, char *orig, struct alias_data *a)
{ {
struct txt_q temp_queue; struct txt_q temp_queue;
char *tokens[NUM_TOKENS], *temp, *write_point; char *tokens[NUM_TOKENS], *temp, *write_point;
@ -924,7 +780,7 @@ int fill_word(char *argument)
return (search_block(argument, fill, TRUE) >= 0); return (search_block(argument, fill, TRUE) >= 0);
} }
int reserved_word(char *argument) static int reserved_word(char *argument)
{ {
return (search_block(argument, reserved, TRUE) >= 0); return (search_block(argument, reserved, TRUE) >= 0);
} }
@ -1082,7 +938,7 @@ int special(struct char_data *ch, int cmd, char *arg)
/* Stuff for controlling the non-playing sockets (get name, pwd etc). /* Stuff for controlling the non-playing sockets (get name, pwd etc).
* This function needs to die. */ * This function needs to die. */
int _parse_name(char *arg, char *name) static int _parse_name(char *arg, char *name)
{ {
int i; int i;
@ -1102,7 +958,7 @@ int _parse_name(char *arg, char *name)
#define UNSWITCH 3 #define UNSWITCH 3
/* This function seems a bit over-extended. */ /* This function seems a bit over-extended. */
int perform_dupe_check(struct descriptor_data *d) static int perform_dupe_check(struct descriptor_data *d)
{ {
struct descriptor_data *k, *next_k; struct descriptor_data *k, *next_k;
struct char_data *target = NULL, *ch, *next_ch; struct char_data *target = NULL, *ch, *next_ch;
@ -1308,7 +1164,8 @@ void nanny(struct descriptor_data *d, char *arg)
{ CON_CEDIT, cedit_parse }, { CON_CEDIT, cedit_parse },
{ CON_TRIGEDIT, trigedit_parse }, { CON_TRIGEDIT, trigedit_parse },
{ CON_AEDIT, aedit_parse }, { CON_AEDIT, aedit_parse },
{ CON_HEDIT, hedit_parse }, { CON_HEDIT, hedit_parse },
{ CON_QEDIT, qedit_parse },
{ -1, NULL } { -1, NULL }
}; };

View file

@ -1,25 +1,28 @@
/************************************************************************** /**
* File: interpreter.h Part of tbaMUD * * @file interpreter.h
* Usage: header file: public procs, macro defs, subcommand defines * * Public procs, macro defs, subcommand defines for the command intepreter.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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 _INTERPRETER_H_
#define _INTERPRETER_H_
#define ACMD(name) \
void name(struct char_data *ch, char *argument, int cmd, int subcmd)
ACMD(do_move); /* List of external function prototypes.
* @todo Organize the functions into modules. */
#define CMD_NAME (complete_cmd_info[cmd].command) #define CMD_NAME (complete_cmd_info[cmd].command)
#define CMD_IS(cmd_name) (!strcmp(cmd_name, complete_cmd_info[cmd].command)) #define CMD_IS(cmd_name) (!strcmp(cmd_name, complete_cmd_info[cmd].command))
#define IS_MOVE(cmdnum) (complete_cmd_info[cmdnum].command_pointer == do_move) #define IS_MOVE(cmdnum) (complete_cmd_info[cmdnum].command_pointer == do_move)
void sort_commands(void);
void command_interpreter(struct char_data *ch, char *argument); void command_interpreter(struct char_data *ch, char *argument);
int search_block(char *arg, const char **list, int exact); int search_block(char *arg, const char **list, int exact);
char lower( char c );
char *one_argument(char *argument, char *first_arg); char *one_argument(char *argument, char *first_arg);
char *one_word(char *argument, char *first_arg); char *one_word(char *argument, char *first_arg);
char *any_one_arg(char *argument, char *first_arg); char *any_one_arg(char *argument, char *first_arg);
@ -32,6 +35,13 @@ int is_number(const char *str);
int find_command(const char *command); int find_command(const char *command);
void skip_spaces(char **string); void skip_spaces(char **string);
char *delete_doubledollar(char *string); char *delete_doubledollar(char *string);
int special(struct char_data *ch, int cmd, char *arg);
void free_alias(struct alias_data *a);
int perform_alias(struct descriptor_data *d, char *orig, size_t maxlen);
int enter_player_game (struct descriptor_data *d);
/* ACMDs available through interpreter.c */
ACMD(do_alias);
/* for compatibility with 2.20: */ /* for compatibility with 2.20: */
#define argument_interpreter(a, b, c) two_arguments(a, b, c) #define argument_interpreter(a, b, c) two_arguments(a, b, c)
@ -52,12 +62,6 @@ struct command_info {
int subcmd; int subcmd;
}; };
/* Necessary for CMD_IS macro. Borland needs the structure defined first
* so it has been moved down here. */
#ifndef __INTERPRETER_C__
extern struct command_info *complete_cmd_info;
#endif
struct alias_data { struct alias_data {
char *alias; char *alias;
char *replacement; char *replacement;
@ -75,142 +79,23 @@ struct alias_data {
/* SUBCOMMANDS: You can define these however you want to, and the definitions /* SUBCOMMANDS: You can define these however you want to, and the definitions
* of the subcommands are independent from function to function.*/ * of the subcommands are independent from function to function.*/
/* directions */ /* directions */
#define SCMD_NORTH 1
#define SCMD_EAST 2
#define SCMD_SOUTH 3
#define SCMD_WEST 4
#define SCMD_UP 5
#define SCMD_DOWN 6
/* do_gen_ps */ /* do_move
#define SCMD_INFO 0 *
#define SCMD_HANDBOOK 1 * Make sure the SCMD_XX directions are mapped
#define SCMD_CREDITS 2 * to the cardinal directions.
#define SCMD_NEWS 3 */
#define SCMD_WIZLIST 4 #define SCMD_NORTH NORTH
#define SCMD_POLICIES 5 #define SCMD_EAST EAST
#define SCMD_VERSION 6 #define SCMD_SOUTH SOUTH
#define SCMD_IMMLIST 7 #define SCMD_WEST WEST
#define SCMD_MOTD 8 #define SCMD_UP UP
#define SCMD_IMOTD 9 #define SCMD_DOWN DOWN
#define SCMD_CLEAR 10
#define SCMD_WHOAMI 11
/* do_gen_tog */ /** @deprecated all old do_poof stuff is deprecated and unused. */
#define SCMD_NOSUMMON 0 #define SCMD_POOFIN 0
#define SCMD_NOHASSLE 1 /** @deprecated all old do_poof stuff is deprecated and unused. */
#define SCMD_BRIEF 2 #define SCMD_POOFOUT 1
#define SCMD_COMPACT 3
#define SCMD_NOTELL 4
#define SCMD_NOAUCTION 5
#define SCMD_NOSHOUT 6
#define SCMD_NOGOSSIP 7
#define SCMD_NOGRATZ 8
#define SCMD_NOWIZ 9
#define SCMD_QUEST 10
#define SCMD_SHOWVNUMS 11
#define SCMD_NOREPEAT 12
#define SCMD_HOLYLIGHT 13
#define SCMD_SLOWNS 14
#define SCMD_AUTOEXIT 15
#define SCMD_TRACK 16
#define SCMD_CLS 17
#define SCMD_BUILDWALK 18
#define SCMD_AFK 19
#define SCMD_COLOR 20
#define SCMD_SYSLOG 21
#define SCMD_WIMPY 22
#define SCMD_PAGELENGTH 23
/* do_wizutil */
#define SCMD_REROLL 0
#define SCMD_PARDON 1
#define SCMD_NOTITLE 2
#define SCMD_MUTE 3
#define SCMD_FREEZE 4
#define SCMD_THAW 5
#define SCMD_UNAFFECT 6
/* do_spec_com */
#define SCMD_WHISPER 0
#define SCMD_ASK 1
/* do_gen_com */
#define SCMD_HOLLER 0
#define SCMD_SHOUT 1
#define SCMD_GOSSIP 2
#define SCMD_AUCTION 3
#define SCMD_GRATZ 4
#define SCMD_GEMOTE 5
/* do_shutdown */
#define SCMD_SHUTDOW 0
#define SCMD_SHUTDOWN 1
/* do_quit */
#define SCMD_QUI 0
#define SCMD_QUIT 1
/* do_date */
#define SCMD_DATE 0
#define SCMD_UPTIME 1
/* do_commands */
#define SCMD_COMMANDS 0
#define SCMD_SOCIALS 1
#define SCMD_WIZHELP 2
/* do_drop */
#define SCMD_DROP 0
#define SCMD_JUNK 1
#define SCMD_DONATE 2
/* do_gen_write */
#define SCMD_BUG 0
#define SCMD_TYPO 1
#define SCMD_IDEA 2
/* do_look */
#define SCMD_LOOK 0
#define SCMD_READ 1
/* do_qcomm */
#define SCMD_QSAY 0
#define SCMD_QECHO 1
/* do_pour */
#define SCMD_POUR 0
#define SCMD_FILL 1
/* do_poof */
#define SCMD_POOFIN 0
#define SCMD_POOFOUT 1
/* do_hit */
#define SCMD_HIT 0
#define SCMD_MURDER 1
/* do_eat */
#define SCMD_EAT 0
#define SCMD_TASTE 1
#define SCMD_DRINK 2
#define SCMD_SIP 3
/* do_use */
#define SCMD_USE 0
#define SCMD_QUAFF 1
#define SCMD_RECITE 2
/* do_echo */
#define SCMD_ECHO 0
#define SCMD_EMOTE 1
/* do_gen_door */
#define SCMD_OPEN 0
#define SCMD_CLOSE 1
#define SCMD_UNLOCK 2
#define SCMD_LOCK 3
#define SCMD_PICK 4
/* do_oasis_Xlist */ /* do_oasis_Xlist */
#define SCMD_OASIS_RLIST 0 #define SCMD_OASIS_RLIST 0
@ -219,6 +104,17 @@ struct alias_data {
#define SCMD_OASIS_SLIST 3 #define SCMD_OASIS_SLIST 3
#define SCMD_OASIS_ZLIST 4 #define SCMD_OASIS_ZLIST 4
#define SCMD_OASIS_TLIST 5 #define SCMD_OASIS_TLIST 5
#define SCMD_OASIS_QLIST 6
/* do_last */ /* Necessary for CMD_IS macro. Borland needs the structure defined first
#define SCMD_LIST_ALL 1 * so it has been moved down here. */
/* Global buffering system */
#ifndef __INTERPRETER_C__
extern int *cmd_sort_info;
extern struct command_info *complete_cmd_info;
extern const struct command_info cmd_info[];
#endif /* __INTERPRETER_C__ */
#endif /* _INTERPRETER_H_ */

View file

@ -18,17 +18,13 @@
#include "handler.h" #include "handler.h"
#include "interpreter.h" #include "interpreter.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "class.h"
#include "fight.h"
/* local file scope function prototypes */
static int graf(int grafage, int p0, int p1, int p2, int p3, int p4, int p5, int p6);
static void check_idling(struct char_data *ch);
/* local functions */
int graf(int grafage, int p0, int p1, int p2, int p3, int p4, int p5, int p6);
void run_autowiz(void);
void Crash_rentsave(struct char_data *ch, int cost);
int level_exp(int chclass, int level);
char *title_male(int chclass, int level);
char *title_female(int chclass, int level);
void update_char_objects(struct char_data *ch); /* handler.c */
void reboot_wizlists(void);
void check_idling(struct char_data *ch);
/* When age < 15 return the value p0 /* When age < 15 return the value p0
When age is 15..29 calculate the line between p1 & p2 When age is 15..29 calculate the line between p1 & p2
@ -36,7 +32,7 @@ void check_idling(struct char_data *ch);
When age is 45..59 calculate the line between p3 & p4 When age is 45..59 calculate the line between p3 & p4
When age is 60..79 calculate the line between p4 & p5 When age is 60..79 calculate the line between p4 & p5
When age >= 80 return the value p6 */ When age >= 80 return the value p6 */
int graf(int grafage, int p0, int p1, int p2, int p3, int p4, int p5, int p6) static int graf(int grafage, int p0, int p1, int p2, int p3, int p4, int p5, int p6)
{ {
if (grafage < 15) if (grafage < 15)
@ -179,20 +175,19 @@ int move_gain(struct char_data *ch)
void set_title(struct char_data *ch, char *title) void set_title(struct char_data *ch, char *title)
{ {
if (title == NULL) {
if (GET_SEX(ch) == SEX_FEMALE)
title = title_female(GET_CLASS(ch), GET_LEVEL(ch));
else
title = title_male(GET_CLASS(ch), GET_LEVEL(ch));
}
if (strlen(title) > MAX_TITLE_LENGTH)
title[MAX_TITLE_LENGTH] = '\0';
if (GET_TITLE(ch) != NULL) if (GET_TITLE(ch) != NULL)
free(GET_TITLE(ch)); free(GET_TITLE(ch));
GET_TITLE(ch) = strdup(title); if (title == NULL) {
GET_TITLE(ch) = strdup(GET_SEX(ch) == SEX_FEMALE ?
title_female(GET_CLASS(ch), GET_LEVEL(ch)) :
title_male(GET_CLASS(ch), GET_LEVEL(ch)));
} else {
if (strlen(title) > MAX_TITLE_LENGTH)
title[MAX_TITLE_LENGTH] = '\0';
GET_TITLE(ch) = strdup(title);
}
} }
void run_autowiz(void) void run_autowiz(void)
@ -263,7 +258,7 @@ void gain_exp(struct char_data *ch, int gain)
} }
if (GET_LEVEL(ch) >= LVL_IMMORT && !PLR_FLAGGED(ch, PLR_NOWIZLIST)) if (GET_LEVEL(ch) >= LVL_IMMORT && !PLR_FLAGGED(ch, PLR_NOWIZLIST))
run_autowiz(); run_autowiz();
} }
void gain_exp_regardless(struct char_data *ch, int gain) void gain_exp_regardless(struct char_data *ch, int gain)
{ {
@ -331,7 +326,7 @@ void gain_condition(struct char_data *ch, int condition, int value)
} }
void check_idling(struct char_data *ch) static void check_idling(struct char_data *ch)
{ {
if (++(ch->char_specials.timer) > CONFIG_IDLE_VOID) { if (++(ch->char_specials.timer) > CONFIG_IDLE_VOID) {
if (GET_WAS_IN(ch) == NOWHERE && IN_ROOM(ch) != NOWHERE) { if (GET_WAS_IN(ch) == NOWHERE && IN_ROOM(ch) != NOWHERE) {

View file

@ -19,20 +19,14 @@
#include "interpreter.h" #include "interpreter.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "class.h"
#include "fight.h"
/* external variables */
extern int mini_mud;
extern struct spell_info_type spell_info[];
/* external functions */ /* local file scope function prototypes */
byte saving_throws(int class_num, int type, int level); /* class.c */ static int mag_materials(struct char_data *ch, IDXTYPE item0, IDXTYPE item1, IDXTYPE item2, int extract, int verbose);
void clearMemory(struct char_data *ch); static void perform_mag_groups(int level, struct char_data *ch, struct char_data *tch, int spellnum, int savetype);
/* local functions */
int mag_materials(struct char_data *ch, int item0, int item1, int item2, int extract, int verbose);
void perform_mag_groups(int level, struct char_data *ch, struct char_data *tch, int spellnum, int savetype);
int mag_savingthrow(struct char_data *ch, int type, int modifier);
void affect_update(void);
/* Negative apply_saving_throw[] values make saving throws better! So do /* Negative apply_saving_throw[] values make saving throws better! So do
* negative modifiers. Though people may be used to the reverse of that. * negative modifiers. Though people may be used to the reverse of that.
@ -83,56 +77,113 @@ void affect_update(void)
} }
} }
/* mag_materials: Checks for up to 3 vnums (spell reagents) in the player's /* Checks for up to 3 vnums (spell reagents) in the player's inventory. If
* inventory. No spells currently use mag_materials, but you can use it to * multiple vnums are passed in, the function ANDs the items together as
* implement your own spells which require ingredients (i.e. heal spells which * requirements (ie. if one or more are missing, the spell will not fail).
* requires a rare herb or some such.) */ * @param ch The caster of the spell.
int mag_materials(struct char_data *ch, int item0, int item1, int item2, * @param item0 The first required item of the spell, NOTHING if not required.
int extract, int verbose) * @param item1 The second required item of the spell, NOTHING if not required.
* @param item2 The third required item of the spell, NOTHING if not required.
* @param extract TRUE if mag_materials should consume (destroy) the items in
* the players inventory, FALSE if not. Items will only be removed on a
* successful cast.
* @param verbose TRUE to provide some generic failure or success messages,
* FALSE to send no in game messages from this function.
* @retval int TRUE if ch has all materials to cast the spell, FALSE if not.
*/
static int mag_materials(struct char_data *ch, IDXTYPE item0,
IDXTYPE item1, IDXTYPE item2, int extract, int verbose)
{ {
struct obj_data *tobj; /* Begin Local variable definitions. */
/*------------------------------------------------------------------------*/
/* Used for object searches. */
struct obj_data *tobj = NULL;
/* Points to found reagents. */
struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL; struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;
/*------------------------------------------------------------------------*/
/* End Local variable definitions. */
for (tobj = ch->carrying; tobj; tobj = tobj->next_content) { /* Begin success checks. Checks must pass to signal a success. */
if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) { /*------------------------------------------------------------------------*/
/* Check for the objects in the players inventory. */
for (tobj = ch->carrying; tobj; tobj = tobj->next_content)
{
if ((item0 != NOTHING) && (GET_OBJ_VNUM(tobj) == item0))
{
obj0 = tobj; obj0 = tobj;
item0 = -1; item0 = NOTHING;
} else if ((item1 > 0) && (GET_OBJ_VNUM(tobj) == item1)) { }
else if ((item1 != NOTHING) && (GET_OBJ_VNUM(tobj) == item1))
{
obj1 = tobj; obj1 = tobj;
item1 = -1; item1 = NOTHING;
} else if ((item2 > 0) && (GET_OBJ_VNUM(tobj) == item2)) { }
else if ((item2 != NOTHING) && (GET_OBJ_VNUM(tobj) == item2))
{
obj2 = tobj; obj2 = tobj;
item2 = -1; item2 = NOTHING;
} }
} }
if ((item0 > 0) || (item1 > 0) || (item2 > 0)) {
if (verbose) { /* If we needed items, but didn't find all of them, then the spell is a
switch (rand_number(0, 2)) { * failure. */
if ((item0 != NOTHING) || (item1 != NOTHING) || (item2 != NOTHING))
{
/* Generic spell failure messages. */
if (verbose)
{
switch (rand_number(0, 2))
{
case 0: case 0:
send_to_char(ch, "A wart sprouts on your nose.\r\n"); send_to_char(ch, "A wart sprouts on your nose.\r\n");
break; break;
case 1: case 1:
send_to_char(ch, "Your hair falls out in clumps.\r\n"); send_to_char(ch, "Your hair falls out in clumps.\r\n");
break; break;
case 2: case 2:
send_to_char(ch, "A huge corn develops on your big toe.\r\n"); send_to_char(ch, "A huge corn develops on your big toe.\r\n");
break; break;
} }
} }
/* Return fales, the material check has failed. */
return (FALSE); return (FALSE);
} }
if (extract) { /*------------------------------------------------------------------------*/
if (item0 < 0) /* End success checks. */
/* From here on, ch has all required materials in their inventory and the
* material check will return a success. */
/* Begin Material Processing. */
/*------------------------------------------------------------------------*/
/* Extract (destroy) the materials, if so called for. */
if (extract)
{
if (obj0 != NULL)
extract_obj(obj0); extract_obj(obj0);
if (item1 < 0) if (obj1 != NULL)
extract_obj(obj1); extract_obj(obj1);
if (item2 < 0) if (obj2 != NULL)
extract_obj(obj2); extract_obj(obj2);
/* Generic success messages that signals extracted objects. */
if (verbose)
{
send_to_char(ch, "A puff of smoke rises from your pack.\r\n");
act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM);
}
} }
if (verbose) {
send_to_char(ch, "A puff of smoke rises from your pack.\r\n"); /* Don't extract the objects, but signal materials successfully found. */
act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM); if(!extract && verbose)
{
send_to_char(ch, "Your pack rumbles.\r\n");
act("Something rumbles in $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM);
} }
/*------------------------------------------------------------------------*/
/* End Material Processing. */
/* Signal to calling function that the materials were successfully found
* and processed. */
return (TRUE); return (TRUE);
} }
@ -489,7 +540,7 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim,
/* This function is used to provide services to mag_groups. This function is /* This function is used to provide services to mag_groups. This function is
* the one you should change to add new group spells. */ * the one you should change to add new group spells. */
void perform_mag_groups(int level, struct char_data *ch, static void perform_mag_groups(int level, struct char_data *ch,
struct char_data *tch, int spellnum, int savetype) struct char_data *tch, int spellnum, int savetype)
{ {
switch (spellnum) { switch (spellnum) {
@ -605,9 +656,13 @@ void mag_areas(int level, struct char_data *ch, int spellnum, int savetype)
} }
} }
/*----------------------------------------------------------------------------*/
/* Begin Magic Summoning - Generic Routines and Local Globals */
/*----------------------------------------------------------------------------*/
/* Every spell which summons/gates/conjours a mob comes through here. */ /* Every spell which summons/gates/conjours a mob comes through here. */
/* These use act(), don't put the \r\n. */ /* These use act(), don't put the \r\n. */
const char *mag_summon_msgs[] = { static const char *mag_summon_msgs[] = {
"\r\n", "\r\n",
"$n makes a strange magical gesture; you feel a strong breeze!", "$n makes a strange magical gesture; you feel a strong breeze!",
"$n animates a corpse!", "$n animates a corpse!",
@ -624,7 +679,7 @@ const char *mag_summon_msgs[] = {
}; };
/* Keep the \r\n because these use send_to_char. */ /* Keep the \r\n because these use send_to_char. */
const char *mag_summon_fail_msgs[] = { static const char *mag_summon_fail_msgs[] = {
"\r\n", "\r\n",
"There are no such creatures.\r\n", "There are no such creatures.\r\n",
"Uh oh...\r\n", "Uh oh...\r\n",
@ -635,11 +690,10 @@ const char *mag_summon_fail_msgs[] = {
"There is no corpse!\r\n" "There is no corpse!\r\n"
}; };
/* Defined mobiles. */ /* Defines for Mag_Summons */
#define MOB_ELEMENTAL_BASE 20 #define MOB_CLONE 10 /**< vnum for the clone mob. */
#define MOB_CLONE 10 #define OBJ_CLONE 161 /**< vnum for clone material. */
#define MOB_ZOMBIE 11 #define MOB_ZOMBIE 11 /**< vnum for the zombie mob. */
#define MOB_AERIALSERVANT 19
void mag_summons(int level, struct char_data *ch, struct obj_data *obj, void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int savetype) int spellnum, int savetype)
@ -657,7 +711,19 @@ void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
msg = 10; msg = 10;
fmsg = rand_number(2, 6); /* Random fail message. */ fmsg = rand_number(2, 6); /* Random fail message. */
mob_num = MOB_CLONE; mob_num = MOB_CLONE;
pfail = 50; /* 50% failure, should be based on something later. */ /*
* We have designated the clone spell as the example for how to use the
* mag_materials function.
* In stock tbaMUD it checks to see if the character has item with
* vnum 161 which is a set of sacrificial entrails. If we have the entrails
* the spell will succeed, and if not, the spell will fail 102% of the time
* (prevents random success... see below).
* The object is extracted and the generic cast messages are displayed.
*/
if( !mag_materials(ch, OBJ_CLONE, NOTHING, NOTHING, TRUE, TRUE) )
pfail = 102; /* No materials, spell fails. */
else
pfail = 0; /* We have the entrails, spell is successfully cast. */
break; break;
case SPELL_ANIMATE_DEAD: case SPELL_ANIMATE_DEAD:
@ -712,6 +778,16 @@ void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
} }
} }
/* Clean up the defines used for mag_summons. */
#undef MOB_CLONE
#undef OBJ_CLONE
#undef MOB_ZOMBIE
/*----------------------------------------------------------------------------*/
/* End Magic Summoning - Generic Routines and Local Globals */
/*----------------------------------------------------------------------------*/
void mag_points(int level, struct char_data *ch, struct char_data *victim, void mag_points(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype) int spellnum, int savetype)
{ {
@ -811,7 +887,7 @@ void mag_alter_objs(int level, struct char_data *ch, struct obj_data *obj,
} }
break; break;
case SPELL_INVISIBLE: case SPELL_INVISIBLE:
if (!OBJ_FLAGGED(obj, ITEM_NOINVIS | ITEM_INVISIBLE)) { if (!OBJ_FLAGGED(obj, ITEM_NOINVIS) || !OBJ_FLAGGED(obj, ITEM_INVISIBLE)) {
SET_BIT_AR(GET_OBJ_EXTRA(obj), ITEM_INVISIBLE); SET_BIT_AR(GET_OBJ_EXTRA(obj), ITEM_INVISIBLE);
to_char = "$p vanishes."; to_char = "$p vanishes.";
} }

View file

@ -18,61 +18,18 @@
#include "interpreter.h" #include "interpreter.h"
#include "handler.h" #include "handler.h"
#include "mail.h" #include "mail.h"
#include "modify.h"
/* external variables */ /* local (file scope) function prototypes */
extern int no_mail; static void postmaster_send_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
extern struct player_index_element *player_table; static void postmaster_check_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
static void postmaster_receive_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
static int mail_recip_ok(const char *name);
static void write_mail_record(FILE *mail_file, struct mail_t *record);
static void free_mail_record(struct mail_t *record);
static struct mail_t *read_mail_record(FILE *mail_file);
/* external functions */ static int mail_recip_ok(const char *name)
SPECIAL(postmaster);
/* local functions */
void postmaster_send_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
void postmaster_check_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
void postmaster_receive_mail(struct char_data *ch, struct char_data *mailman, int cmd, char *arg);
int mail_recip_ok(const char *name);
void write_mail_record(FILE *mail_file, struct mail_t *record);
char *decrypt_hex(char *string, size_t len)
{
static char output[MAX_STRING_LENGTH];
char *p;
char *src = string;
int i;
p = output;
for (i = 0;i<len/2;++i) {
unsigned char hi = *src++;
unsigned char lo = *src++;
hi -= (hi<'A' ? '0' : 'A'-10);
lo -= (lo<'A' ? '0' : 'A'-10);
*p++ = (hi<<4) | (lo & 0x0F);
}
return output;
}
char *encrypt_hex(char *string, size_t len)
{
static char output[MAX_STRING_LENGTH];
char *p;
char *src = string;
int i;
if (len == 0)
return "";
p = output;
for (i=0 ; i<len; i++) {
unsigned char lo=*src++;
unsigned char hi=lo>>4;
lo&=0x0F;
*p++ = hi+(hi>9 ? 'A'-10 : '0');
*p++ = lo+(lo>9 ? 'A'-10 : '0');
}
return output;
}
int mail_recip_ok(const char *name)
{ {
int player_i, ret = FALSE; int player_i, ret = FALSE;
@ -83,14 +40,14 @@ int mail_recip_ok(const char *name)
return ret; return ret;
} }
void free_mail_record(struct mail_t *record) static void free_mail_record(struct mail_t *record)
{ {
if (record->body) if (record->body)
free(record->body); free(record->body);
free(record); free(record);
} }
struct mail_t *read_mail_record(FILE *mail_file) static struct mail_t *read_mail_record(FILE *mail_file)
{ {
char line[READ_SIZE]; char line[READ_SIZE];
long sender, recipient; long sender, recipient;
@ -100,7 +57,7 @@ struct mail_t *read_mail_record(FILE *mail_file)
if (!get_line(mail_file, line)) if (!get_line(mail_file, line))
return NULL; return NULL;
if (sscanf(line, "### %ld %ld %ld", &recipient, &sender, &sent_time) != 3) { if (sscanf(line, "### %ld %ld %ld", &recipient, &sender, (long *)&sent_time) != 3) {
log("Mail system - fatal error - malformed mail header"); log("Mail system - fatal error - malformed mail header");
log("Line was: %s", line); log("Line was: %s", line);
return NULL; return NULL;
@ -116,13 +73,13 @@ struct mail_t *read_mail_record(FILE *mail_file)
return record; return record;
} }
void write_mail_record(FILE *mail_file, struct mail_t *record) static void write_mail_record(FILE *mail_file, struct mail_t *record)
{ {
fprintf(mail_file, "### %ld %ld %ld\n" fprintf(mail_file, "### %ld %ld %ld\n"
"%s~\n", "%s~\n",
record->recipient, record->recipient,
record->sender, record->sender,
record->sent_time, (long)record->sent_time,
record->body ); record->body );
} }
@ -313,7 +270,7 @@ SPECIAL(postmaster)
return (0); return (0);
} }
void postmaster_send_mail(struct char_data *ch, struct char_data *mailman, static void postmaster_send_mail(struct char_data *ch, struct char_data *mailman,
int cmd, char *arg) int cmd, char *arg)
{ {
long recipient; long recipient;
@ -360,7 +317,7 @@ void postmaster_send_mail(struct char_data *ch, struct char_data *mailman,
string_write(ch->desc, mailwrite, MAX_MAIL_SIZE, recipient, NULL); string_write(ch->desc, mailwrite, MAX_MAIL_SIZE, recipient, NULL);
} }
void postmaster_check_mail(struct char_data *ch, struct char_data *mailman, static void postmaster_check_mail(struct char_data *ch, struct char_data *mailman,
int cmd, char *arg) int cmd, char *arg)
{ {
if (has_mail(GET_IDNUM(ch))) if (has_mail(GET_IDNUM(ch)))
@ -369,7 +326,7 @@ void postmaster_check_mail(struct char_data *ch, struct char_data *mailman,
act("$n tells you, 'Sorry, you don't have any mail waiting.'", FALSE, mailman, 0, ch, TO_VICT); act("$n tells you, 'Sorry, you don't have any mail waiting.'", FALSE, mailman, 0, ch, TO_VICT);
} }
void postmaster_receive_mail(struct char_data *ch, struct char_data *mailman, static void postmaster_receive_mail(struct char_data *ch, struct char_data *mailman,
int cmd, char *arg) int cmd, char *arg)
{ {
char buf[256]; char buf[256];

View file

@ -1,13 +1,17 @@
/************************************************************************** /**
* File: mail.h Part of tbaMUD * * @file mail.h
* Usage: header file for mudmail system * * Public procs, macro defs, subcommand defines mudmail system.
* * *
* All rights reserved. See license for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license for complete information.
* By Jeremy Elson. * * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University
**************************************************************************/ * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.
* By Jeremy Elson.
*/
#ifndef _MAIL_H_
#define _MAIL_H_
/* You can modify the following constants to fit your own MUD. */ /* You can modify the following constants to fit your own MUD. */
@ -23,6 +27,9 @@
/* size of mail file allocation blocks */ /* size of mail file allocation blocks */
#define BLOCK_SIZE 100 #define BLOCK_SIZE 100
/* General, publicly available functions */
SPECIAL(postmaster);
/* NOTE: Make sure that your block size is big enough. If not, HEADER_BLOCK_ /* NOTE: Make sure that your block size is big enough. If not, HEADER_BLOCK_
* DATASIZE will end up negative. This is a bad thing. Check the define below * DATASIZE will end up negative. This is a bad thing. Check the define below
* to make sure it is >0 when choosing values for NAME_SIZE and BLOCK_SIZE. * to make sure it is >0 when choosing values for NAME_SIZE and BLOCK_SIZE.
@ -97,3 +104,5 @@ struct mail_index_type_d {
}; };
typedef struct mail_index_type_d mail_index_type; typedef struct mail_index_type_d mail_index_type;
#endif /* _MAIL_H_ */

View file

@ -8,10 +8,10 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "interpreter.h" #include "interpreter.h"
#include "comm.h" #include "comm.h"
#include "spells.h" #include "spells.h"
#include "utils.h"
#include "db.h" #include "db.h"
#include "shop.h" #include "shop.h"
#include "genolc.h" #include "genolc.h"
@ -24,22 +24,19 @@
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "screen.h" #include "screen.h"
#include "fight.h"
/* external variables */ #include "modify.h" /* for smash_tilde */
extern struct attack_hit_type attack_hit_text[];
/* local functions */ /* local functions */
void medit_setup_new(struct descriptor_data *d); static void medit_setup_new(struct descriptor_data *d);
void medit_setup_existing(struct descriptor_data *d, int rmob_num); static void init_mobile(struct char_data *mob);
void init_mobile(struct char_data *mob); static void medit_save_to_disk(zone_vnum zone_num);
void medit_save_internally(struct descriptor_data *d); static void medit_disp_positions(struct descriptor_data *d);
void medit_save_to_disk(zone_vnum zone_num); static void medit_disp_sex(struct descriptor_data *d);
void medit_disp_positions(struct descriptor_data *d); static void medit_disp_attack_types(struct descriptor_data *d);
void medit_disp_sex(struct descriptor_data *d); static void medit_disp_mob_flags(struct descriptor_data *d);
void medit_disp_attack_types(struct descriptor_data *d); static void medit_disp_aff_flags(struct descriptor_data *d);
void medit_disp_mob_flags(struct descriptor_data *d); static void medit_disp_menu(struct descriptor_data *d);
void medit_disp_aff_flags(struct descriptor_data *d);
void medit_disp_menu(struct descriptor_data *d);
/* utility functions */ /* utility functions */
ACMD(do_oasis_medit) ACMD(do_oasis_medit)
@ -167,12 +164,12 @@ ACMD(do_oasis_medit)
GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch)); GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch));
} }
void medit_save_to_disk(zone_vnum foo) static void medit_save_to_disk(zone_vnum foo)
{ {
save_mobiles(real_zone(foo)); save_mobiles(real_zone(foo));
} }
void medit_setup_new(struct descriptor_data *d) static void medit_setup_new(struct descriptor_data *d)
{ {
struct char_data *mob; struct char_data *mob;
@ -217,7 +214,7 @@ void medit_setup_existing(struct descriptor_data *d, int rmob_num)
} }
/* Ideally, this function should be in db.c, but I'll put it here for portability. */ /* Ideally, this function should be in db.c, but I'll put it here for portability. */
void init_mobile(struct char_data *mob) static void init_mobile(struct char_data *mob)
{ {
clear_char(mob); clear_char(mob);
@ -294,7 +291,7 @@ void medit_save_internally(struct descriptor_data *d)
/* Menu functions /* Menu functions
Display positions. (sitting, standing, etc) */ Display positions. (sitting, standing, etc) */
void medit_disp_positions(struct descriptor_data *d) static void medit_disp_positions(struct descriptor_data *d)
{ {
int i; int i;
@ -308,7 +305,7 @@ void medit_disp_positions(struct descriptor_data *d)
} }
/* Display the gender of the mobile. */ /* Display the gender of the mobile. */
void medit_disp_sex(struct descriptor_data *d) static void medit_disp_sex(struct descriptor_data *d)
{ {
int i; int i;
@ -322,7 +319,7 @@ void medit_disp_sex(struct descriptor_data *d)
} }
/* Display attack types menu. */ /* Display attack types menu. */
void medit_disp_attack_types(struct descriptor_data *d) static void medit_disp_attack_types(struct descriptor_data *d)
{ {
int i; int i;
@ -336,41 +333,43 @@ void medit_disp_attack_types(struct descriptor_data *d)
} }
/* Display mob-flags menu. */ /* Display mob-flags menu. */
void medit_disp_mob_flags(struct descriptor_data *d) static void medit_disp_mob_flags(struct descriptor_data *d)
{ {
int i, columns = 0; char buf[MAX_STRING_LENGTH];
char flags[MAX_STRING_LENGTH];
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
for (i = 0; i < NUM_MOB_FLAGS; i++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, i + 1, nrm, action_bits[i], column_list(buf, sizeof(buf), 0, 0,
!(++columns % 2) ? "\r\n" : ""); 2, action_bits, NUM_MOB_FLAGS, 0,
} "%s$2i%s) $20l", grn, nrm);
sprintbitarray(MOB_FLAGS(OLC_MOB(d)), action_bits, AF_ARRAY_MAX, flags); write_to_output(d, buf);
sprintbitarray(MOB_FLAGS(OLC_MOB(d)), action_bits, AF_ARRAY_MAX, buf);
write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter mob flags (0 to quit) : ", write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter mob flags (0 to quit) : ",
cyn, flags, nrm); cyn, buf, nrm);
} }
/* Display affection flags menu. */ /* Display affection flags menu. */
void medit_disp_aff_flags(struct descriptor_data *d) static void medit_disp_aff_flags(struct descriptor_data *d)
{ {
int i, columns = 0; char buf[MAX_STRING_LENGTH];
char flags[MAX_STRING_LENGTH];
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
for (i = 0; i < NUM_AFF_FLAGS; i++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, i + 1, nrm, affected_bits[i+1], column_list(buf, sizeof(buf), 0, 0,
!(++columns % 2) ? "\r\n" : ""); 2, affected_bits, NUM_AFF_FLAGS, 1,
} "%s$2i%s) $20l", grn, nrm);
sprintbitarray(AFF_FLAGS(OLC_MOB(d)), affected_bits, AF_ARRAY_MAX, flags); write_to_output(d, buf);
sprintbitarray(AFF_FLAGS(OLC_MOB(d)), affected_bits, AF_ARRAY_MAX, buf);
write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter aff flags (0 to quit) : ", write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter aff flags (0 to quit) : ",
cyn, flags, nrm); cyn, buf, nrm);
} }
/* Display main menu. */ /* Display main menu. */
void medit_disp_menu(struct descriptor_data *d) static void medit_disp_menu(struct descriptor_data *d)
{ {
struct char_data *mob; struct char_data *mob;
char flags[MAX_STRING_LENGTH], flag2[MAX_STRING_LENGTH]; char flags[MAX_STRING_LENGTH], flag2[MAX_STRING_LENGTH];

View file

@ -18,19 +18,13 @@
#include "handler.h" #include "handler.h"
#include "spells.h" #include "spells.h"
#include "constants.h" #include "constants.h"
#include "act.h"
#include "graph.h"
#include "fight.h"
/* external globals */
extern int no_specials;
/* external functions */ /* local file scope only function prototypes */
ACMD(do_get); static bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack);
ACMD(do_action);
void hunt_victim(struct char_data *ch);
/* local functions */
void mobile_activity(void);
void clearMemory(struct char_data *ch);
bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack);
void mobile_activity(void) void mobile_activity(void)
{ {
@ -84,12 +78,15 @@ void mobile_activity(void)
/* Mob Movement */ /* Mob Movement */
if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) &&
((door = rand_number(0, 18)) < NUM_OF_DIRS) && CAN_GO(ch, door) && ((door = rand_number(0, 18)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
!ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB) &&
!ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_DEATH) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_DEATH) &&
(!MOB_FLAGGED(ch, MOB_STAY_ZONE) || (!MOB_FLAGGED(ch, MOB_STAY_ZONE) ||
(world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) { (world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone)))
perform_move(ch, door, 1); {
/* If the mob is charmed, do not move the mob. */
if (ch->master != NULL)
perform_move(ch, door, 1);
} }
/* Aggressive Mobs */ /* Aggressive Mobs */
@ -152,17 +149,19 @@ void mobile_activity(void)
} }
/* Helper Mobs */ /* Helper Mobs */
if (MOB_FLAGGED(ch, MOB_HELPER) && !AFF_FLAGGED(ch, AFF_BLIND | AFF_CHARM)) { if (MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM)))
{
found = FALSE; found = FALSE;
for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room)
if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict)) {
continue; if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict))
if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict)) continue;
continue; if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict))
continue;
act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM); act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM);
hit(ch, FIGHTING(vict), TYPE_UNDEFINED); hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
found = TRUE; found = TRUE;
} }
} }
@ -236,7 +235,7 @@ void clearMemory(struct char_data *ch)
/* An aggressive mobile wants to attack something. If they're under the /* An aggressive mobile wants to attack something. If they're under the
* influence of mind altering PC, then see if their master can talk them out * influence of mind altering PC, then see if their master can talk them out
* of it, eye them down, or otherwise intimidate the slave. */ * of it, eye them down, or otherwise intimidate the slave. */
bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack) static bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack)
{ {
static int snarl_cmd; static int snarl_cmd;
int dieroll; int dieroll;

View file

@ -21,23 +21,20 @@
#include "boards.h" #include "boards.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "oasis.h" #include "oasis.h"
#include "dg_scripts.h" /* for trigedit_string_cleanup */
#include "modify.h"
#include "quest.h"
void show_string(struct descriptor_data *d, char *input); /* local (file scope) function prototpyes */
static char *next_page(char *str, struct char_data *ch);
static int count_pages(char *str, struct char_data *ch);
static void playing_string_cleanup(struct descriptor_data *d, int action);
static void exdesc_string_cleanup(struct descriptor_data *d, int action);
extern struct spell_info_type spell_info[]; /* Local (file scope) global variables */
extern const char *unused_spellname; /* spell_parser.c */ /* @deprecated string_fields appears to be no longer be used.
* Left in but commented out.
/* local functions */ static const char *string_fields[] =
void smash_tilde(char *str);
ACMD(do_skillset);
char *next_page(char *str, struct char_data *ch);
int count_pages(char *str, struct char_data *ch);
void paginate_string(char *str, struct descriptor_data *d);
void playing_string_cleanup(struct descriptor_data *d, int action);
void exdesc_string_cleanup(struct descriptor_data *d, int action);
void trigedit_string_cleanup(struct descriptor_data *d, int terminator);
const char *string_fields[] =
{ {
"name", "name",
"short", "short",
@ -47,9 +44,11 @@ const char *string_fields[] =
"delete-description", "delete-description",
"\n" "\n"
}; };
*/
/* maximum length for text field x+1 */ /** maximum length for text field x+1
int length[] = * @deprecated length appears to no longer be used. Left in but commented out.
static int length[] =
{ {
15, 15,
60, 60,
@ -57,6 +56,7 @@ int length[] =
240, 240,
60 60
}; };
*/
/* modification of malloc'ed strings */ /* modification of malloc'ed strings */
/* Put '#if 1' here to erase ~, or roll your own method. A common idea is /* Put '#if 1' here to erase ~, or roll your own method. A common idea is
@ -151,6 +151,7 @@ void string_add(struct descriptor_data *d, char *str)
case CON_PLR_DESC: case CON_PLR_DESC:
case CON_TRIGEDIT: case CON_TRIGEDIT:
case CON_HEDIT: case CON_HEDIT:
case CON_QEDIT:
free(*d->str); free(*d->str);
*d->str = d->backstr; *d->str = d->backstr;
d->backstr = NULL; d->backstr = NULL;
@ -190,6 +191,7 @@ void string_add(struct descriptor_data *d, char *str)
{ CON_PLR_DESC , exdesc_string_cleanup }, { CON_PLR_DESC , exdesc_string_cleanup },
{ CON_PLAYING, playing_string_cleanup }, { CON_PLAYING, playing_string_cleanup },
{ CON_HEDIT, hedit_string_cleanup }, { CON_HEDIT, hedit_string_cleanup },
{ CON_QEDIT , qedit_string_cleanup },
{ -1, NULL } { -1, NULL }
}; };
@ -209,7 +211,7 @@ void string_add(struct descriptor_data *d, char *str)
strcat(*d->str, "\r\n"); strcat(*d->str, "\r\n");
} }
void playing_string_cleanup(struct descriptor_data *d, int action) static void playing_string_cleanup(struct descriptor_data *d, int action)
{ {
if (PLR_FLAGGED(d->character, PLR_MAILING)) { if (PLR_FLAGGED(d->character, PLR_MAILING)) {
if (action == STRINGADD_SAVE && *d->str) { if (action == STRINGADD_SAVE && *d->str) {
@ -231,7 +233,7 @@ void playing_string_cleanup(struct descriptor_data *d, int action)
} }
} }
void exdesc_string_cleanup(struct descriptor_data *d, int action) static void exdesc_string_cleanup(struct descriptor_data *d, int action)
{ {
if (action == STRINGADD_ABORT) if (action == STRINGADD_ABORT)
write_to_output(d, "Description aborted.\r\n"); write_to_output(d, "Description aborted.\r\n");
@ -325,7 +327,7 @@ ACMD(do_skillset)
/* By Michael Buselli. Traverse down the string until the begining of the next /* By Michael Buselli. Traverse down the string until the begining of the next
* page has been reached. Return NULL if this is the last page of the string. */ * page has been reached. Return NULL if this is the last page of the string. */
char *next_page(char *str, struct char_data *ch) static char *next_page(char *str, struct char_data *ch)
{ {
int col = 1, line = 1; int col = 1, line = 1;
@ -367,7 +369,7 @@ char *next_page(char *str, struct char_data *ch)
} }
/* Function that returns the number of pages in the string. */ /* Function that returns the number of pages in the string. */
int count_pages(char *str, struct char_data *ch) static int count_pages(char *str, struct char_data *ch)
{ {
int pages; int pages;

View file

@ -22,12 +22,14 @@
#include "oasis.h" #include "oasis.h"
#include "screen.h" #include "screen.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "act.h"
#include "handler.h" /* for is_name */
#include "quest.h"
/* External Functions */
int is_name(const char *str, const char *namelist);
/* Internal Data Structures */ /* Internal Data Structures */
struct olc_scmd_info_t { /** @deprecated olc_scmd_info appears to be deprecated. Commented out for now.
static struct olc_scmd_info_t {
const char *text; const char *text;
int con_type; int con_type;
} olc_scmd_info[] = { } olc_scmd_info[] = {
@ -40,13 +42,16 @@ struct olc_scmd_info_t {
{ "trigger", CON_TRIGEDIT }, { "trigger", CON_TRIGEDIT },
{ "action", CON_AEDIT }, { "action", CON_AEDIT },
{ "help", CON_HEDIT }, { "help", CON_HEDIT },
{ "quest", CON_QEDIT },
{ "\n", -1 } { "\n", -1 }
}; };
*/
/* Global variables defined here, used elsewhere */
const char *nrm, *grn, *cyn, *yel; const char *nrm, *grn, *cyn, *yel;
/* Internal Functions */ /* Internal Function prototypes */
void free_config(struct config_data *data); static void free_config(struct config_data *data);
/* Only player characters should be using OLC anyway. */ /* Only player characters should be using OLC anyway. */
void clear_screen(struct descriptor_data *d) void clear_screen(struct descriptor_data *d)
@ -125,6 +130,20 @@ void cleanup_olc(struct descriptor_data *d, byte cleanup_type)
if (OLC_SHOP(d)) if (OLC_SHOP(d))
free_shop(OLC_SHOP(d)); free_shop(OLC_SHOP(d));
/* Check for a quest. */
if (OLC_QUEST(d)) {
switch (cleanup_type) {
case CLEANUP_ALL:
free_quest(OLC_QUEST(d));
break;
case CLEANUP_STRUCTS:
free(OLC_QUEST(d));
break;
default:
break;
}
}
/*. Check for aedit stuff -- M. Scott */ /*. Check for aedit stuff -- M. Scott */
if (OLC_ACTION(d)) { if (OLC_ACTION(d)) {
switch(cleanup_type) { switch(cleanup_type) {
@ -214,7 +233,7 @@ void split_argument(char *argument, char *tag)
*wrt = '\0'; *wrt = '\0';
} }
void free_config(struct config_data *data) static void free_config(struct config_data *data)
{ {
/* Free strings. */ /* Free strings. */
free_strings(data, OASIS_CFG); free_strings(data, OASIS_CFG);

View file

@ -1,9 +1,18 @@
/************************************************************************** /**
* File: oasis.c Part of tbaMUD * * @file oasis.h
* Usage: Oasis - General. * * Oasis online creation general defines.
* * *
* By Levork. Copyright 1996 Harvey Gilpin. 1997-2001 George Greer. * * Part of the core tbaMUD source code distribution, which is a derivative
**************************************************************************/ * of, and continuation of, CircleMUD.
*
* This source code, which was not part of the CircleMUD legacy code,
* is attributed to:
* By Levork. Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer.
*/
#ifndef _OASIS_H_
#define _OASIS_H_
#include "utils.h" /* for ACMD macro */
#define _OASISOLC 0x206 /* 2.0.6 */ #define _OASISOLC 0x206 /* 2.0.6 */
@ -16,25 +25,8 @@
#define ALL_PERMISSION 666 /* arbitrary number higher then max zone vnum*/ #define ALL_PERMISSION 666 /* arbitrary number higher then max zone vnum*/
/* Macros, defines, structs and globals for the OLC suite. You will need /* Macros, defines, structs and globals for the OLC suite. You will need
to adjust these numbers if you ever add more. */ to adjust these numbers if you ever add more. Note: Most of the NUM_ and
#define NUM_ROOM_FLAGS 16 MAX_ limits have been moved to more appropriate locations. */
#define NUM_ROOM_SECTORS 10
#define NUM_MOB_FLAGS 18
#define NUM_AFF_FLAGS 22
#define NUM_ATTACK_TYPES 15
#define NUM_ITEM_TYPES 24
#define NUM_ITEM_FLAGS 17
#define NUM_ITEM_WEARS 15
#define NUM_APPLIES 25
#define NUM_LIQ_TYPES 16
#define NUM_POSITIONS 15
#define NUM_SPELLS 51
#define NUM_GENDERS 3
#define NUM_SHOP_FLAGS 3
#define NUM_TRADERS 7
#define MAX_PEOPLE 10 /* Max # of people you want to sit in furniture. */ #define MAX_PEOPLE 10 /* Max # of people you want to sit in furniture. */
@ -85,9 +77,7 @@ void split_argument(char *argument, char *tag);
void send_cannot_edit(struct char_data *ch, zone_vnum zone); void send_cannot_edit(struct char_data *ch, zone_vnum zone);
/* OLC structures. */ /* OLC structures. */
/* The following defines used to be in config.c. */ /* NO and YES are defined in utils.h. Removed from here. */
#define NO 0
#define YES 1
struct oasis_olc_data { struct oasis_olc_data {
int mode; /* how to parse input */ int mode; /* how to parse input */
@ -101,6 +91,7 @@ struct oasis_olc_data {
struct zone_data *zone; /* used for 'zedit' */ struct zone_data *zone; /* used for 'zedit' */
struct shop_data *shop; /* used for 'sedit' */ struct shop_data *shop; /* used for 'sedit' */
struct config_data *config; /* used for 'cedit' */ struct config_data *config; /* used for 'cedit' */
struct aq_data *quest; /* used for 'qedit' */
struct extra_descr_data *desc; /* used in '[r|o|m]edit' */ struct extra_descr_data *desc; /* used in '[r|o|m]edit' */
struct social_messg *action; /* Aedit uses this one */ struct social_messg *action; /* Aedit uses this one */
struct trig_data *trig; struct trig_data *trig;
@ -115,24 +106,25 @@ struct oasis_olc_data {
extern const char *nrm, *grn, *cyn, *yel; extern const char *nrm, *grn, *cyn, *yel;
/* Descriptor access macros. */ /* Descriptor access macros. */
#define OLC(d) ((d)->olc) #define OLC(d) ((d)->olc)
#define OLC_MODE(d) (OLC(d)->mode) /* Parse input mode. */ #define OLC_MODE(d) (OLC(d)->mode) /**< Parse input mode. */
#define OLC_NUM(d) (OLC(d)->number) /* Room/Obj VNUM. */ #define OLC_NUM(d) (OLC(d)->number) /**< Room/Obj VNUM. */
#define OLC_VAL(d) (OLC(d)->value) /* Scratch variable. */ #define OLC_VAL(d) (OLC(d)->value) /**< Scratch variable. */
#define OLC_ZNUM(d) (OLC(d)->zone_num) /* Real zone number. */ #define OLC_ZNUM(d) (OLC(d)->zone_num) /**< Real zone number. */
#define OLC_STORAGE(d) (OLC(d)->storage) /* char pointer. */ #define OLC_STORAGE(d) (OLC(d)->storage) /**< char pointer. */
#define OLC_ROOM(d) (OLC(d)->room) /* Room structure. */ #define OLC_ROOM(d) (OLC(d)->room) /**< Room structure. */
#define OLC_OBJ(d) (OLC(d)->obj) /* Object structure. */ #define OLC_OBJ(d) (OLC(d)->obj) /**< Object structure. */
#define OLC_ZONE(d) (OLC(d)->zone) /* Zone structure. */ #define OLC_ZONE(d) (OLC(d)->zone) /**< Zone structure. */
#define OLC_MOB(d) (OLC(d)->mob) /* Mob structure. */ #define OLC_MOB(d) (OLC(d)->mob) /**< Mob structure. */
#define OLC_SHOP(d) (OLC(d)->shop) /* Shop structure. */ #define OLC_SHOP(d) (OLC(d)->shop) /**< Shop structure. */
#define OLC_DESC(d) (OLC(d)->desc) /* Extra description. */ #define OLC_DESC(d) (OLC(d)->desc) /**< Extra description. */
#define OLC_CONFIG(d) (OLC(d)->config) /* Config structure. */ #define OLC_CONFIG(d) (OLC(d)->config) /**< Config structure. */
#define OLC_TRIG(d) (OLC(d)->trig) /* Trigger structure. */ #define OLC_TRIG(d) (OLC(d)->trig) /**< Trigger structure. */
#define OLC_QUEST(d) (OLC(d)->quest) /**< Quest structure */
#define OLC_ACTION(d) (OLC(d)->action) /* Action structure */ #define OLC_ACTION(d) (OLC(d)->action) /**< Action structure */
#define OLC_HELP(d) (OLC(d)->help) /* Hedit structure */ #define OLC_HELP(d) (OLC(d)->help) /**< Hedit structure */
/* Other macros. */ /* Other macros. */
#define OLC_EXIT(d) (OLC_ROOM(d)->dir_option[OLC_VAL(d)]) #define OLC_EXIT(d) (OLC_ROOM(d)->dir_option[OLC_VAL(d)])
@ -355,6 +347,9 @@ extern const char *nrm, *grn, *cyn, *yel;
#define CEDIT_NAMESERVER_IS_SLOW 51 #define CEDIT_NAMESERVER_IS_SLOW 51
#define CEDIT_USE_AUTOWIZ 52 #define CEDIT_USE_AUTOWIZ 52
#define CEDIT_MIN_WIZLIST_LEV 53 #define CEDIT_MIN_WIZLIST_LEV 53
#define CEDIT_MAP_OPTION 54
#define CEDIT_MAP_SIZE 55
#define CEDIT_MINIMAP_SIZE 56
/* Hedit Submodes of connectedness. */ /* Hedit Submodes of connectedness. */
#define HEDIT_CONFIRM_SAVESTRING 0 #define HEDIT_CONFIRM_SAVESTRING 0
@ -365,25 +360,29 @@ extern const char *nrm, *grn, *cyn, *yel;
#define HEDIT_KEYWORDS 5 #define HEDIT_KEYWORDS 5
#define HEDIT_MIN_LEVEL 6 #define HEDIT_MIN_LEVEL 6
#ifndef __GENOLC_C__ int save_config( IDXTYPE nowhere );
/* Prototypes to keep. */ /* Prototypes to keep. */
#ifndef ACMD
#define ACMD(name) \
void name(struct char_data *ch, char *argument, int cmd, int subcmd)
#endif
void clear_screen(struct descriptor_data *); void clear_screen(struct descriptor_data *);
int can_edit_zone(struct char_data *ch, zone_rnum rnum); int can_edit_zone(struct char_data *ch, zone_rnum rnum);
ACMD(do_oasis); ACMD(do_oasis);
/* public functions from medit.c */
void medit_setup_existing(struct descriptor_data *d, int rnum);
void medit_save_internally(struct descriptor_data *d);
void medit_parse(struct descriptor_data *d, char *arg); void medit_parse(struct descriptor_data *d, char *arg);
void medit_string_cleanup(struct descriptor_data *d, int terminator); void medit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_medit); ACMD(do_oasis_medit);
/* public functions from oedit.c */
void oedit_setup_existing(struct descriptor_data *d, int rnum);
void oedit_save_internally(struct descriptor_data *d);
void oedit_parse(struct descriptor_data *d, char *arg); void oedit_parse(struct descriptor_data *d, char *arg);
void oedit_string_cleanup(struct descriptor_data *d, int terminator); void oedit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_oedit); ACMD(do_oasis_oedit);
/* public functions from redit.c */
void redit_setup_existing(struct descriptor_data *d, int rnum);
void redit_string_cleanup(struct descriptor_data *d, int terminator); void redit_string_cleanup(struct descriptor_data *d, int terminator);
void redit_save_internally(struct descriptor_data *d); void redit_save_internally(struct descriptor_data *d);
void redit_save_to_disk(zone_vnum zone_num); void redit_save_to_disk(zone_vnum zone_num);
@ -391,36 +390,56 @@ void redit_parse(struct descriptor_data *d, char *arg);
void free_room(struct room_data *room); void free_room(struct room_data *room);
ACMD(do_oasis_redit); ACMD(do_oasis_redit);
/* public functions from sedit.c */
void sedit_setup_existing(struct descriptor_data *d, int rnum);
void sedit_save_internally(struct descriptor_data *d);
void sedit_parse(struct descriptor_data *d, char *arg); void sedit_parse(struct descriptor_data *d, char *arg);
ACMD(do_oasis_sedit); ACMD(do_oasis_sedit);
/* public functions from zedit.c */
void zedit_parse(struct descriptor_data *d, char *arg); void zedit_parse(struct descriptor_data *d, char *arg);
ACMD(do_oasis_zedit); ACMD(do_oasis_zedit);
/* public functions from cedit.c */
void cedit_save_to_disk( void );
void cedit_parse(struct descriptor_data *d, char *arg); void cedit_parse(struct descriptor_data *d, char *arg);
void cedit_string_cleanup(struct descriptor_data *d, int terminator); void cedit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_cedit); ACMD(do_oasis_cedit);
/* public functions from dg_olc.c */
void trigedit_parse(struct descriptor_data *d, char *arg); void trigedit_parse(struct descriptor_data *d, char *arg);
ACMD(do_oasis_trigedit); ACMD(do_oasis_trigedit);
/* public functions from from aedit.c */
void aedit_parse(struct descriptor_data * d, char *arg); void aedit_parse(struct descriptor_data * d, char *arg);
void free_action(struct social_messg *mess);
ACMD(do_oasis_aedit); ACMD(do_oasis_aedit);
ACMD(do_astat);
/* public functions from hedit.c */
void hedit_parse(struct descriptor_data *d, char *arg); void hedit_parse(struct descriptor_data *d, char *arg);
void hedit_string_cleanup(struct descriptor_data *d, int terminator); void hedit_string_cleanup(struct descriptor_data *d, int terminator);
void free_help(struct help_index_element *help); void free_help(struct help_index_element *help);
ACMD(do_oasis_hedit); ACMD(do_oasis_hedit);
/* public functions from tedit.c */
void tedit_string_cleanup(struct descriptor_data *d, int terminator); void tedit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_tedit); ACMD(do_tedit);
/* oasis_delete.c */ /* public functions from qedit.c */
ACMD(do_oasis_qedit);
/* public functions from oasis_copy.c */
int buildwalk(struct char_data *ch, int dir);
ACMD(do_dig);
ACMD(do_oasis_copy);
/* public functions from oasis_delete.c */
int free_strings(void *data, int type); int free_strings(void *data, int type);
/* oasis_list.c */ /* public functions from oasis_list.c */
ACMD(do_oasis_list);
ACMD(do_oasis_links);
void print_zone(struct char_data *ch, zone_rnum rnum); void print_zone(struct char_data *ch, zone_rnum rnum);
#endif /** @deprecated is do_oasis_links intentionally dead code? */
ACMD(do_oasis_links);
ACMD(do_oasis_list);
#endif /* _OASIS_H_ */

View file

@ -24,22 +24,9 @@
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
/* Internal Functions */ /* Local, filescope function prototypes */
ACMD(do_dig); /* Utility function for buildwalk */
room_vnum redit_find_new_vnum(zone_rnum zone); static room_vnum redit_find_new_vnum(zone_rnum zone);
int buildwalk(struct char_data *ch, int dir);
/* External Functions */
void trigedit_save(struct descriptor_data *d);
void redit_save_internally(struct descriptor_data *d);
void oedit_save_internally(struct descriptor_data *d);
void medit_save_internally(struct descriptor_data *d);
void sedit_save_internally(struct descriptor_data *d);
void trigedit_setup_existing(struct descriptor_data *d, int rnum);
void redit_setup_existing(struct descriptor_data *d, int rnum);
void oedit_setup_existing(struct descriptor_data *d, int rnum);
void medit_setup_existing(struct descriptor_data *d, int rnum);
void sedit_setup_existing(struct descriptor_data *d, int rnum);
/*********************************************************** /***********************************************************
@ -302,7 +289,7 @@ ACMD(do_dig)
/* BuildWalk - OasisOLC Extension by D. Tyler Barnes. */ /* BuildWalk - OasisOLC Extension by D. Tyler Barnes. */
/* For buildwalk. Finds the next free vnum in the zone */ /* For buildwalk. Finds the next free vnum in the zone */
room_vnum redit_find_new_vnum(zone_rnum zone) static room_vnum redit_find_new_vnum(zone_rnum zone)
{ {
room_vnum vnum = genolc_zone_bottom(zone); room_vnum vnum = genolc_zone_bottom(zone);
room_rnum rnum = real_room(vnum); room_rnum rnum = real_room(vnum);

View file

@ -21,14 +21,15 @@
#include "screen.h" #include "screen.h"
#include "constants.h" #include "constants.h"
#include "dg_scripts.h" #include "dg_scripts.h"
#include "quest.h"
/* local functions */ /* local functions */
void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax); static void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax);
void list_rooms(struct char_data *ch , zone_rnum rnum, room_vnum vmin, room_vnum vmax); static void list_rooms(struct char_data *ch , zone_rnum rnum, room_vnum vmin, room_vnum vmax);
void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin , mob_vnum vmax ); static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin , mob_vnum vmax );
void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin , obj_vnum vmax ); static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin , obj_vnum vmax );
void list_shops(struct char_data *ch , zone_rnum rnum, shop_vnum vmin, shop_vnum vmax); static void list_shops(struct char_data *ch , zone_rnum rnum, shop_vnum vmin, shop_vnum vmax);
void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax); static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax);
/* Ingame Commands */ /* Ingame Commands */
ACMD(do_oasis_list) ACMD(do_oasis_list)
@ -67,6 +68,7 @@ ACMD(do_oasis_list)
case SCMD_OASIS_RLIST: list_rooms(ch, rzone, vmin, vmax); break; case SCMD_OASIS_RLIST: list_rooms(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_TLIST: list_triggers(ch, rzone, vmin, vmax); break; case SCMD_OASIS_TLIST: list_triggers(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_SLIST: list_shops(ch, rzone, vmin, vmax); break; case SCMD_OASIS_SLIST: list_shops(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_QLIST: list_quests(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_ZLIST: case SCMD_OASIS_ZLIST:
if (!*smin) if (!*smin)
list_zones(ch, NOWHERE, 0, zone_table[top_of_zone_table].number); list_zones(ch, NOWHERE, 0, zone_table[top_of_zone_table].number);
@ -133,7 +135,7 @@ ACMD(do_oasis_links)
/* Helper Functions */ /* Helper Functions */
/* List all rooms in a zone. */ /* List all rooms in a zone. */
void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax) static void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax)
{ {
room_rnum i; room_rnum i;
room_vnum bottom, top; room_vnum bottom, top;
@ -187,7 +189,7 @@ void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum
} }
/* List all mobiles in a zone. */ /* List all mobiles in a zone. */
void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mob_vnum vmax) static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mob_vnum vmax)
{ {
mob_rnum i; mob_rnum i;
mob_vnum bottom, top; mob_vnum bottom, top;
@ -226,7 +228,7 @@ void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mob_vnum
} }
/* List all objects in a zone. */ /* List all objects in a zone. */
void list_objects(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax) static void list_objects(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax)
{ {
obj_rnum i; obj_rnum i;
obj_vnum bottom, top; obj_vnum bottom, top;
@ -266,7 +268,7 @@ void list_objects(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnu
} }
/* List all shops in a zone. */ /* List all shops in a zone. */
void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, shop_vnum vmax) static void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, shop_vnum vmax)
{ {
shop_rnum i; shop_rnum i;
shop_vnum bottom, top; shop_vnum bottom, top;
@ -310,7 +312,7 @@ void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, shop_vnum
} }
/* List all zones in the world (sort of like 'show zones'). */ /* List all zones in the world (sort of like 'show zones'). */
void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax) static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax)
{ {
int counter = 0; int counter = 0;
zone_rnum i; zone_rnum i;
@ -349,7 +351,7 @@ void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum
void print_zone(struct char_data *ch, zone_vnum vnum) void print_zone(struct char_data *ch, zone_vnum vnum)
{ {
zone_rnum rnum; zone_rnum rnum;
int size_rooms, size_objects, size_mobiles, i; int size_rooms, size_objects, size_mobiles, size_quests, i;
room_vnum top, bottom; room_vnum top, bottom;
int largest_table; int largest_table;
@ -370,6 +372,7 @@ void print_zone(struct char_data *ch, zone_vnum vnum)
size_rooms = 0; size_rooms = 0;
size_objects = 0; size_objects = 0;
size_mobiles = 0; size_mobiles = 0;
size_quests = 0;
top = zone_table[rnum].top; top = zone_table[rnum].top;
bottom = zone_table[rnum].bot; bottom = zone_table[rnum].bot;
@ -386,7 +389,8 @@ void print_zone(struct char_data *ch, zone_vnum vnum)
if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top) if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top)
size_mobiles++; size_mobiles++;
} }
size_quests = count_quests(bottom, top);
/* Display all of the zone information at once. */ /* Display all of the zone information at once. */
send_to_char(ch, send_to_char(ch,
"%sVirtual Number = %s%d\r\n" "%sVirtual Number = %s%d\r\n"
@ -400,7 +404,8 @@ void print_zone(struct char_data *ch, zone_vnum vnum)
"%sSize\r\n" "%sSize\r\n"
"%s Rooms = %s%d\r\n" "%s Rooms = %s%d\r\n"
"%s Objects = %s%d\r\n" "%s Objects = %s%d\r\n"
"%s Mobiles = %s%d%s\r\n", "%s Mobiles = %s%d\r\n"
"%s Quests = %s%d%s\r\n",
QGRN, QCYN, zone_table[rnum].number, QGRN, QCYN, zone_table[rnum].number,
QGRN, QCYN, zone_table[rnum].name, QGRN, QCYN, zone_table[rnum].name,
QGRN, QCYN, zone_table[rnum].builders, QGRN, QCYN, zone_table[rnum].builders,
@ -413,11 +418,12 @@ void print_zone(struct char_data *ch, zone_vnum vnum)
QGRN, QGRN,
QGRN, QCYN, size_rooms, QGRN, QCYN, size_rooms,
QGRN, QCYN, size_objects, QGRN, QCYN, size_objects,
QGRN, QCYN, size_mobiles, QNRM); QGRN, QCYN, size_mobiles,
QGRN, QCYN, size_quests, QNRM);
} }
/* List code by Ronald Evers. */ /* List code by Ronald Evers. */
void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax) static void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax)
{ {
int i, bottom, top, counter = 0; int i, bottom, top, counter = 0;
char trgtypes[256]; char trgtypes[256];

View file

@ -11,12 +11,17 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "handler.h" #include "handler.h"
#include "db.h" #include "db.h"
#include "interpreter.h" #include "interpreter.h"
#include "utils.h"
#include "spells.h" #include "spells.h"
#include "act.h"
#include "class.h"
#include "config.h"
#include "modify.h"
#include "genolc.h" /* for strip_cr and sprintascii */
/* these factors should be unique integers */ /* these factors should be unique integers */
#define RENT_FACTOR 1 #define RENT_FACTOR 1
@ -25,48 +30,25 @@
#define LOC_INVENTORY 0 #define LOC_INVENTORY 0
#define MAX_BAG_ROWS 5 #define MAX_BAG_ROWS 5
/* external variables */
extern struct player_index_element *player_table;
extern int top_of_p_table;
extern int rent_file_timeout, crash_file_timeout;
extern int free_rent;
extern int min_rent_cost;
extern int max_obj_save; /* change in config.c */
/* Extern functions */
ACMD(do_action);
SPECIAL(receptionist);
SPECIAL(cryogenicist);
int invalid_class(struct char_data *ch, struct obj_data *obj);
bitvector_t asciiflag_conv(char *flag);
int sprintascii(char *out, bitvector_t bits);
/* local functions */ /* local functions */
void Crash_extract_norent_eq(struct char_data *ch); static int Crash_save(struct obj_data *obj, FILE *fp, int location);
void auto_equip(struct char_data *ch, struct obj_data *obj, int location); static void Crash_extract_norent_eq(struct char_data *ch);
int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, int display, int factor); static void auto_equip(struct char_data *ch, struct obj_data *obj, int location);
int Crash_report_unrentables(struct char_data *ch, struct char_data *recep, struct obj_data *obj); static int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, int display, int factor);
void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct obj_data *obj, long *cost, long *nitems, int display, int factor); static int Crash_report_unrentables(struct char_data *ch, struct char_data *recep, struct obj_data *obj);
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location); static void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct obj_data *obj, long *cost, long *nitems, int display, int factor);
void update_obj_file(void); static int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, char *arg, int mode);
int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, char *arg, int mode); static void Crash_rent_deadline(struct char_data *ch, struct char_data *recep, long cost);
int Crash_save(struct obj_data *obj, FILE *fp, int location); static void Crash_restore_weight(struct obj_data *obj);
void Crash_rent_deadline(struct char_data *ch, struct char_data *recep, long cost); static void Crash_extract_objs(struct obj_data *obj);
void Crash_restore_weight(struct obj_data *obj); static int Crash_is_unrentable(struct obj_data *obj);
void Crash_extract_objs(struct obj_data *obj); static void Crash_extract_norents(struct obj_data *obj);
int Crash_is_unrentable(struct obj_data *obj); static void Crash_extract_expensive(struct obj_data *obj);
void Crash_extract_norents(struct obj_data *obj); static void Crash_calculate_rent(struct obj_data *obj, int *cost);
void Crash_extract_expensive(struct obj_data *obj); static void Crash_cryosave(struct char_data *ch, int cost);
void Crash_calculate_rent(struct obj_data *obj, int *cost); static int Crash_load_objs(struct char_data *ch);
void Crash_rentsave(struct char_data *ch, int cost); static int handle_obj(struct obj_data *obj, struct char_data *ch, int locate, struct obj_data **cont_rows);
void Crash_cryosave(struct char_data *ch, int cost); static int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch);
int Crash_load_objs(struct char_data *ch);
void tag_argument(char *argument, char *tag);
int handle_obj(struct obj_data *obj, struct char_data *ch, int locate, struct obj_data **cont_rows);
obj_save_data *objsave_parse_objects(FILE *fl);
int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch);
int objsave_save_obj_record(struct obj_data *obj, FILE *fl, int location);
void strip_cr(char *buffer);
/* Writes one object record to FILE. Old name: Obj_to_store() */ /* Writes one object record to FILE. Old name: Obj_to_store() */
int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate) int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate)
@ -182,7 +164,7 @@ int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate)
#undef TEST_OBJN #undef TEST_OBJN
/* AutoEQ by Burkhard Knopf. */ /* AutoEQ by Burkhard Knopf. */
void auto_equip(struct char_data *ch, struct obj_data *obj, int location) static void auto_equip(struct char_data *ch, struct obj_data *obj, int location)
{ {
int j; int j;
@ -356,7 +338,7 @@ int Crash_clean_file(char *name)
if ((rentcode == RENT_CRASH) || if ((rentcode == RENT_CRASH) ||
(rentcode == RENT_FORCED) || (rentcode == RENT_FORCED) ||
(rentcode == RENT_TIMEDOUT) ) { (rentcode == RENT_TIMEDOUT) ) {
if (timed < time(0) - (crash_file_timeout * SECS_PER_REAL_DAY)) { if (timed < time(0) - (CONFIG_CRASH_TIMEOUT * SECS_PER_REAL_DAY)) {
Crash_delete_file(name); Crash_delete_file(name);
switch (rentcode) { switch (rentcode) {
case RENT_CRASH: case RENT_CRASH:
@ -377,7 +359,7 @@ int Crash_clean_file(char *name)
} }
/* Must retrieve rented items w/in 30 days */ /* Must retrieve rented items w/in 30 days */
} else if (rentcode == RENT_RENTED) } else if (rentcode == RENT_RENTED)
if (timed < time(0) - (rent_file_timeout * SECS_PER_REAL_DAY)) { if (timed < time(0) - (CONFIG_RENT_TIMEOUT * SECS_PER_REAL_DAY)) {
Crash_delete_file(name); Crash_delete_file(name);
log(" Deleting %s's rent file.", name); log(" Deleting %s's rent file.", name);
return TRUE; return TRUE;
@ -470,7 +452,7 @@ int Crash_load(struct char_data *ch)
return (Crash_load_objs(ch)); return (Crash_load_objs(ch));
} }
int Crash_save(struct obj_data *obj, FILE *fp, int location) static int Crash_save(struct obj_data *obj, FILE *fp, int location)
{ {
struct obj_data *tmp; struct obj_data *tmp;
int result; int result;
@ -490,7 +472,7 @@ int Crash_save(struct obj_data *obj, FILE *fp, int location)
return (TRUE); return (TRUE);
} }
void Crash_restore_weight(struct obj_data *obj) static void Crash_restore_weight(struct obj_data *obj)
{ {
if (obj) { if (obj) {
Crash_restore_weight(obj->contains); Crash_restore_weight(obj->contains);
@ -502,7 +484,7 @@ void Crash_restore_weight(struct obj_data *obj)
/* Get !RENT items from equipment to inventory and extract !RENT out of worn /* Get !RENT items from equipment to inventory and extract !RENT out of worn
* containers. */ * containers. */
void Crash_extract_norent_eq(struct char_data *ch) static void Crash_extract_norent_eq(struct char_data *ch)
{ {
int j; int j;
@ -517,7 +499,7 @@ void Crash_extract_norent_eq(struct char_data *ch)
} }
} }
void Crash_extract_objs(struct obj_data *obj) static void Crash_extract_objs(struct obj_data *obj)
{ {
if (obj) { if (obj) {
Crash_extract_objs(obj->contains); Crash_extract_objs(obj->contains);
@ -526,7 +508,7 @@ void Crash_extract_objs(struct obj_data *obj)
} }
} }
int Crash_is_unrentable(struct obj_data *obj) static int Crash_is_unrentable(struct obj_data *obj)
{ {
if (!obj) if (!obj)
return FALSE; return FALSE;
@ -542,7 +524,7 @@ int Crash_is_unrentable(struct obj_data *obj)
return FALSE; return FALSE;
} }
void Crash_extract_norents(struct obj_data *obj) static void Crash_extract_norents(struct obj_data *obj)
{ {
if (obj) { if (obj) {
Crash_extract_norents(obj->contains); Crash_extract_norents(obj->contains);
@ -552,7 +534,7 @@ void Crash_extract_norents(struct obj_data *obj)
} }
} }
void Crash_extract_expensive(struct obj_data *obj) static void Crash_extract_expensive(struct obj_data *obj)
{ {
struct obj_data *tobj, *max; struct obj_data *tobj, *max;
@ -563,7 +545,7 @@ void Crash_extract_expensive(struct obj_data *obj)
extract_obj(max); extract_obj(max);
} }
void Crash_calculate_rent(struct obj_data *obj, int *cost) static void Crash_calculate_rent(struct obj_data *obj, int *cost)
{ {
if (obj) { if (obj) {
*cost += MAX(0, GET_OBJ_RENT(obj)); *cost += MAX(0, GET_OBJ_RENT(obj));
@ -725,7 +707,7 @@ void Crash_rentsave(struct char_data *ch, int cost)
Crash_extract_objs(ch->carrying); Crash_extract_objs(ch->carrying);
} }
int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch) static int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char_data *ch)
{ {
if (fprintf(fl, "%d %ld %d %d %d %d\r\n", if (fprintf(fl, "%d %ld %d %d %d %d\r\n",
rentcode, rentcode,
@ -743,7 +725,7 @@ int objsave_write_rentcode(FILE *fl, int rentcode, int cost_per_day, struct char
} }
void Crash_cryosave(struct char_data *ch, int cost) static void Crash_cryosave(struct char_data *ch, int cost)
{ {
char buf[MAX_INPUT_LENGTH]; char buf[MAX_INPUT_LENGTH];
int j; int j;
@ -787,7 +769,7 @@ void Crash_cryosave(struct char_data *ch, int cost)
} }
/* Routines used for the receptionist. */ /* Routines used for the receptionist. */
void Crash_rent_deadline(struct char_data *ch, struct char_data *recep, static void Crash_rent_deadline(struct char_data *ch, struct char_data *recep,
long cost) long cost)
{ {
long rent_deadline; long rent_deadline;
@ -802,7 +784,7 @@ void Crash_rent_deadline(struct char_data *ch, struct char_data *recep,
act(buf, FALSE, recep, 0, ch, TO_VICT); act(buf, FALSE, recep, 0, ch, TO_VICT);
} }
int Crash_report_unrentables(struct char_data *ch, struct char_data *recep, static int Crash_report_unrentables(struct char_data *ch, struct char_data *recep,
struct obj_data *obj) struct obj_data *obj)
{ {
char buf[128]; char buf[128];
@ -820,7 +802,7 @@ int Crash_report_unrentables(struct char_data *ch, struct char_data *recep,
return (has_norents); return (has_norents);
} }
void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct static void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct
obj_data *obj, long *cost, long *nitems, int display, int factor) obj_data *obj, long *cost, long *nitems, int display, int factor)
{ {
static char buf[256]; static char buf[256];
@ -840,7 +822,7 @@ void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct
} }
} }
int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, static int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist,
int display, int factor) int display, int factor)
{ {
char buf[MAX_INPUT_LENGTH]; char buf[MAX_INPUT_LENGTH];
@ -854,7 +836,7 @@ int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist,
if (norent) if (norent)
return FALSE; return FALSE;
totalcost = min_rent_cost * factor; totalcost = CONFIG_MIN_RENT_COST * factor;
Crash_report_rent(ch, receptionist, ch->carrying, &totalcost, &numitems, display, factor); Crash_report_rent(ch, receptionist, ch->carrying, &totalcost, &numitems, display, factor);
@ -866,15 +848,15 @@ int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist,
FALSE, receptionist, 0, ch, TO_VICT); FALSE, receptionist, 0, ch, TO_VICT);
return FALSE; return FALSE;
} }
if (numitems > max_obj_save) { if (numitems > CONFIG_MAX_OBJ_SAVE) {
sprintf(buf, "$n tells you, 'Sorry, but I cannot store more than %d items.'", sprintf(buf, "$n tells you, 'Sorry, but I cannot store more than %d items.'",
max_obj_save); CONFIG_MAX_OBJ_SAVE);
act(buf, FALSE, receptionist, 0, ch, TO_VICT); act(buf, FALSE, receptionist, 0, ch, TO_VICT);
return FALSE; return FALSE;
} }
if (display) { if (display) {
sprintf(buf, "$n tells you, 'Plus, my %d coin fee..'", sprintf(buf, "$n tells you, 'Plus, my %d coin fee..'",
min_rent_cost * factor); CONFIG_MIN_RENT_COST * factor);
act(buf, FALSE, receptionist, 0, ch, TO_VICT); act(buf, FALSE, receptionist, 0, ch, TO_VICT);
sprintf(buf, "$n tells you, 'For a total of %ld coins%s.'", sprintf(buf, "$n tells you, 'For a total of %ld coins%s.'",
totalcost, (factor == RENT_FACTOR ? " per day" : "")); totalcost, (factor == RENT_FACTOR ? " per day" : ""));
@ -889,7 +871,7 @@ int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist,
return (totalcost); return (totalcost);
} }
int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, static int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd,
char *arg, int mode) char *arg, int mode)
{ {
int cost; int cost;
@ -917,7 +899,7 @@ int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd,
return (TRUE); return (TRUE);
} }
if (free_rent) { if (CONFIG_FREE_RENT) {
act("$n tells you, 'Rent is free here. Just quit, and your objects will be saved!'", act("$n tells you, 'Rent is free here. Just quit, and your objects will be saved!'",
FALSE, recep, 0, ch, TO_VICT); FALSE, recep, 0, ch, TO_VICT);
return TRUE; return TRUE;
@ -1178,7 +1160,7 @@ obj_save_data *objsave_parse_objects(FILE *fl)
return head; return head;
} }
int Crash_load_objs(struct char_data *ch) { static int Crash_load_objs(struct char_data *ch) {
FILE *fl; FILE *fl;
char fname[MAX_STRING_LENGTH]; char fname[MAX_STRING_LENGTH];
char line[READ_SIZE]; char line[READ_SIZE];
@ -1265,7 +1247,7 @@ int Crash_load_objs(struct char_data *ch) {
/* Little hoarding check. -gg 3/1/98 */ /* Little hoarding check. -gg 3/1/98 */
mudlog(NRM, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE, "%s (level %d) has %d objects (max %d).", mudlog(NRM, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE, "%s (level %d) has %d objects (max %d).",
GET_NAME(ch), GET_LEVEL(ch), num_objs, max_obj_save); GET_NAME(ch), GET_LEVEL(ch), num_objs, CONFIG_MAX_OBJ_SAVE);
fclose(fl); fclose(fl);
@ -1275,7 +1257,7 @@ int Crash_load_objs(struct char_data *ch) {
return 1; return 1;
} }
int handle_obj(struct obj_data *temp, struct char_data *ch, int locate, struct obj_data **cont_row) static int handle_obj(struct obj_data *temp, struct char_data *ch, int locate, struct obj_data **cont_row)
{ {
int j; int j;
struct obj_data *obj1; struct obj_data *obj1;

View file

@ -8,10 +8,10 @@
#include "conf.h" #include "conf.h"
#include "sysdep.h" #include "sysdep.h"
#include "structs.h" #include "structs.h"
#include "utils.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "spells.h" #include "spells.h"
#include "utils.h"
#include "db.h" #include "db.h"
#include "boards.h" #include "boards.h"
#include "constants.h" #include "constants.h"
@ -22,33 +22,28 @@
#include "oasis.h" #include "oasis.h"
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "fight.h"
/* external variables */ #include "modify.h"
extern struct attack_hit_type attack_hit_text[];
extern struct spell_info_type spell_info[];
extern struct board_info_type board_info[];
/* local functions */ /* local functions */
void oedit_setup_new(struct descriptor_data *d); static void oedit_setup_new(struct descriptor_data *d);
void oedit_setup_existing(struct descriptor_data *d, int real_num); static void oedit_disp_container_flags_menu(struct descriptor_data *d);
void oedit_save_internally(struct descriptor_data *d); static void oedit_disp_extradesc_menu(struct descriptor_data *d);
void oedit_save_to_disk(int zone_num); static void oedit_disp_prompt_apply_menu(struct descriptor_data *d);
void oedit_disp_container_flags_menu(struct descriptor_data *d); static void oedit_liquid_type(struct descriptor_data *d);
void oedit_disp_extradesc_menu(struct descriptor_data *d); static void oedit_disp_apply_menu(struct descriptor_data *d);
void oedit_disp_prompt_apply_menu(struct descriptor_data *d); static void oedit_disp_weapon_menu(struct descriptor_data *d);
void oedit_liquid_type(struct descriptor_data *d); static void oedit_disp_spells_menu(struct descriptor_data *d);
void oedit_disp_apply_menu(struct descriptor_data *d); static void oedit_disp_val1_menu(struct descriptor_data *d);
void oedit_disp_weapon_menu(struct descriptor_data *d); static void oedit_disp_val2_menu(struct descriptor_data *d);
void oedit_disp_spells_menu(struct descriptor_data *d); static void oedit_disp_val3_menu(struct descriptor_data *d);
void oedit_disp_val1_menu(struct descriptor_data *d); static void oedit_disp_val4_menu(struct descriptor_data *d);
void oedit_disp_val2_menu(struct descriptor_data *d); static void oedit_disp_type_menu(struct descriptor_data *d);
void oedit_disp_val3_menu(struct descriptor_data *d); static void oedit_disp_extra_menu(struct descriptor_data *d);
void oedit_disp_val4_menu(struct descriptor_data *d); static void oedit_disp_wear_menu(struct descriptor_data *d);
void oedit_disp_type_menu(struct descriptor_data *d); static void oedit_disp_menu(struct descriptor_data *d);
void oedit_disp_extra_menu(struct descriptor_data *d); static void oedit_disp_perm_menu(struct descriptor_data *d);
void oedit_disp_wear_menu(struct descriptor_data *d); static void oedit_save_to_disk(int zone_num);
void oedit_disp_menu(struct descriptor_data *d);
void oedit_disp_perm_menu(struct descriptor_data *d);
/* handy macro */ /* handy macro */
#define S_PRODUCT(s, i) ((s)->producing[(i)]) #define S_PRODUCT(s, i) ((s)->producing[(i)])
@ -182,7 +177,7 @@ ACMD(do_oasis_oedit)
GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch)); GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch));
} }
void oedit_setup_new(struct descriptor_data *d) static void oedit_setup_new(struct descriptor_data *d)
{ {
CREATE(OLC_OBJ(d), struct obj_data, 1); CREATE(OLC_OBJ(d), struct obj_data, 1);
@ -284,14 +279,14 @@ void oedit_save_internally(struct descriptor_data *d)
} }
} }
void oedit_save_to_disk(int zone_num) static void oedit_save_to_disk(int zone_num)
{ {
save_objects(zone_num); save_objects(zone_num);
} }
/* Menu functions */ /* Menu functions */
/* For container flags. */ /* For container flags. */
void oedit_disp_container_flags_menu(struct descriptor_data *d) static void oedit_disp_container_flags_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
get_char_colors(d->character); get_char_colors(d->character);
@ -309,7 +304,7 @@ void oedit_disp_container_flags_menu(struct descriptor_data *d)
} }
/* For extra descriptions. */ /* For extra descriptions. */
void oedit_disp_extradesc_menu(struct descriptor_data *d) static void oedit_disp_extradesc_menu(struct descriptor_data *d)
{ {
struct extra_descr_data *extra_desc = OLC_DESC(d); struct extra_descr_data *extra_desc = OLC_DESC(d);
@ -330,7 +325,7 @@ void oedit_disp_extradesc_menu(struct descriptor_data *d)
} }
/* Ask for *which* apply to edit. */ /* Ask for *which* apply to edit. */
void oedit_disp_prompt_apply_menu(struct descriptor_data *d) static void oedit_disp_prompt_apply_menu(struct descriptor_data *d)
{ {
char apply_buf[MAX_STRING_LENGTH]; char apply_buf[MAX_STRING_LENGTH];
int counter; int counter;
@ -352,7 +347,7 @@ void oedit_disp_prompt_apply_menu(struct descriptor_data *d)
} }
/* Ask for liquid type. */ /* Ask for liquid type. */
void oedit_liquid_type(struct descriptor_data *d) static void oedit_liquid_type(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -368,7 +363,7 @@ void oedit_liquid_type(struct descriptor_data *d)
} }
/* The actual apply to set. */ /* The actual apply to set. */
void oedit_disp_apply_menu(struct descriptor_data *d) static void oedit_disp_apply_menu(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -384,7 +379,7 @@ void oedit_disp_apply_menu(struct descriptor_data *d)
} }
/* Weapon type. */ /* Weapon type. */
void oedit_disp_weapon_menu(struct descriptor_data *d) static void oedit_disp_weapon_menu(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -400,7 +395,7 @@ void oedit_disp_weapon_menu(struct descriptor_data *d)
} }
/* Spell type. */ /* Spell type. */
void oedit_disp_spells_menu(struct descriptor_data *d) static void oedit_disp_spells_menu(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -415,7 +410,7 @@ void oedit_disp_spells_menu(struct descriptor_data *d)
} }
/* Object value #1 */ /* Object value #1 */
void oedit_disp_val1_menu(struct descriptor_data *d) static void oedit_disp_val1_menu(struct descriptor_data *d)
{ {
OLC_MODE(d) = OEDIT_VALUE_1; OLC_MODE(d) = OEDIT_VALUE_1;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) { switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
@ -459,7 +454,7 @@ void oedit_disp_val1_menu(struct descriptor_data *d)
} }
/* Object value #2 */ /* Object value #2 */
void oedit_disp_val2_menu(struct descriptor_data *d) static void oedit_disp_val2_menu(struct descriptor_data *d)
{ {
OLC_MODE(d) = OEDIT_VALUE_2; OLC_MODE(d) = OEDIT_VALUE_2;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) { switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
@ -492,7 +487,7 @@ void oedit_disp_val2_menu(struct descriptor_data *d)
} }
/* Object value #3 */ /* Object value #3 */
void oedit_disp_val3_menu(struct descriptor_data *d) static void oedit_disp_val3_menu(struct descriptor_data *d)
{ {
OLC_MODE(d) = OEDIT_VALUE_3; OLC_MODE(d) = OEDIT_VALUE_3;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) { switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
@ -523,7 +518,7 @@ void oedit_disp_val3_menu(struct descriptor_data *d)
} }
/* Object value #4 */ /* Object value #4 */
void oedit_disp_val4_menu(struct descriptor_data *d) static void oedit_disp_val4_menu(struct descriptor_data *d)
{ {
OLC_MODE(d) = OEDIT_VALUE_4; OLC_MODE(d) = OEDIT_VALUE_4;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) { switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
@ -547,7 +542,7 @@ void oedit_disp_val4_menu(struct descriptor_data *d)
} }
/* Object type. */ /* Object type. */
void oedit_disp_type_menu(struct descriptor_data *d) static void oedit_disp_type_menu(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -562,7 +557,7 @@ void oedit_disp_type_menu(struct descriptor_data *d)
} }
/* Object extra flags. */ /* Object extra flags. */
void oedit_disp_extra_menu(struct descriptor_data *d) static void oedit_disp_extra_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int counter, columns = 0; int counter, columns = 0;
@ -581,7 +576,7 @@ void oedit_disp_extra_menu(struct descriptor_data *d)
} }
/* Object perm flags. */ /* Object perm flags. */
void oedit_disp_perm_menu(struct descriptor_data *d) static void oedit_disp_perm_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int counter, columns = 0; int counter, columns = 0;
@ -598,7 +593,7 @@ void oedit_disp_perm_menu(struct descriptor_data *d)
} }
/* Object wear flags. */ /* Object wear flags. */
void oedit_disp_wear_menu(struct descriptor_data *d) static void oedit_disp_wear_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int counter, columns = 0; int counter, columns = 0;
@ -616,7 +611,7 @@ void oedit_disp_wear_menu(struct descriptor_data *d)
} }
/* Display main menu. */ /* Display main menu. */
void oedit_disp_menu(struct descriptor_data *d) static void oedit_disp_menu(struct descriptor_data *d)
{ {
char buf1[MAX_STRING_LENGTH]; char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH];

View file

@ -1,8 +1,12 @@
/************************************************************************** /**
* File: pfdefaults.h Part of tbaMUD * * @file pfdefaults.h
* Usage: ASCII player file defaults. * * ASCII player file defaults.
**************************************************************************/ *
* Part of the core tbaMUD source code distribution, which is a derivative
* of, and continuation of, CircleMUD.
*
* This set of code was not originally part of the circlemud distribution.
*/
#ifndef _PFDEFAULTS_H_ #ifndef _PFDEFAULTS_H_
#define _PFDEFAULTS_H_ #define _PFDEFAULTS_H_
@ -50,7 +54,10 @@
#define PFDEF_DRUNK 0 #define PFDEF_DRUNK 0
#define PFDEF_OLC NOWHERE #define PFDEF_OLC NOWHERE
#define PFDEF_PAGELENGTH 22 #define PFDEF_PAGELENGTH 22
#define PFDEF_SCREENWIDTH 80
#define PFDEF_QUESTPOINTS 0 #define PFDEF_QUESTPOINTS 0
#define PFDEF_QUESTCOUNT 0
#define PFDEF_COMPQUESTS 0
#define PFDEF_CURRQUEST NOTHING
#endif #endif /* _PFDEFAULTS_H_ */

View file

@ -18,37 +18,35 @@
#include "dg_scripts.h" #include "dg_scripts.h"
#include "comm.h" #include "comm.h"
#include "interpreter.h" #include "interpreter.h"
#include "genolc.h" /* for strip_cr */
#include "config.h" /* for pclean_criteria[] */
#include "spells.h" /* for NUM_OF_SAVING_THROWS */
#include "dg_scripts.h" /* To enable saving of player variables to disk */
#include "quest.h"
#define LOAD_HIT 0 #define LOAD_HIT 0
#define LOAD_MANA 1 #define LOAD_MANA 1
#define LOAD_MOVE 2 #define LOAD_MOVE 2
#define LOAD_STRENGTH 3 #define LOAD_STRENGTH 3
/* 'global' vars defined here and used externally */
/** @deprecated Since this file really is basically a functional extension
* of the database handling in db.c, until the day that the mud is broken
* down to be less monolithic, I don't see why the following should be defined
* anywhere but there.
struct player_index_element *player_table = NULL;
int top_of_p_table = 0;
int top_of_p_file = 0;
long top_idnum = 0;
*/
/* local functions */ /* local functions */
void build_player_index(void); static void load_affects(FILE *fl, struct char_data *ch);
int sprintascii(char *out, bitvector_t bits); static void load_skills(FILE *fl, struct char_data *ch);
void tag_argument(char *argument, char *tag); static void load_quests(FILE *fl, struct char_data *ch);
void load_affects(FILE *fl, struct char_data *ch); static void load_HMVS(struct char_data *ch, const char *line, int mode);
void load_skills(FILE *fl, struct char_data *ch); static void write_aliases_ascii(FILE *file, struct char_data *ch);
void load_HMVS(struct char_data *ch, const char *line, int mode); static void read_aliases_ascii(FILE *file, struct char_data *ch, int count);
void write_aliases_ascii(FILE *file, struct char_data *ch);
void read_aliases_ascii(FILE *file, struct char_data *ch, int count);
/* external fuctions */
bitvector_t asciiflag_conv(char *flag);
void save_char_vars(struct char_data *ch);
void save_char_vars_ascii(FILE *file, struct char_data *ch);
void read_saved_vars_ascii(FILE *file, struct char_data *ch, int count);
void strip_cr(char *buffer);
/* 'global' vars */
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 */
/* external ASCII Player Files vars */
extern struct pclean_criteria_data pclean_criteria[];
/* New version to build player index for ASCII Player Files. Generate index /* New version to build player index for ASCII Player Files. Generate index
* table for the player file. */ * table for the player file. */
@ -81,7 +79,7 @@ void build_player_index(void)
for (i = 0; i < rec_count; i++) { for (i = 0; i < rec_count; i++) {
get_line(plr_index, line); get_line(plr_index, line);
sscanf(line, "%ld %s %d %s %ld", &player_table[i].id, arg2, sscanf(line, "%ld %s %d %s %ld", &player_table[i].id, arg2,
&player_table[i].level, bits, &player_table[i].last); &player_table[i].level, bits, (long *)&player_table[i].last);
CREATE(player_table[i].name, char, strlen(arg2) + 1); CREATE(player_table[i].name, char, strlen(arg2) + 1);
strcpy(player_table[i].name, arg2); strcpy(player_table[i].name, arg2);
player_table[i].flags = asciiflag_conv(bits); player_table[i].flags = asciiflag_conv(bits);
@ -139,7 +137,7 @@ void save_player_index(void)
sprintascii(bits, player_table[i].flags); sprintascii(bits, player_table[i].flags);
fprintf(index_file, "%ld %s %d %s %ld\n", player_table[i].id, fprintf(index_file, "%ld %s %d %s %ld\n", player_table[i].id,
player_table[i].name, player_table[i].level, *bits ? bits : "0", player_table[i].name, player_table[i].level, *bits ? bits : "0",
player_table[i].last); (long)player_table[i].last);
} }
fprintf(index_file, "~\n"); fprintf(index_file, "~\n");
@ -196,8 +194,6 @@ char *get_name_by_id(long id)
} }
/* Stuff related to the save/load player system. */ /* Stuff related to the save/load player system. */
#define NUM_OF_SAVE_THROWS 5
/* New load_char reads ASCII Player Files. Load a char, TRUE if loaded, FALSE /* New load_char reads ASCII Player Files. Load a char, TRUE if loaded, FALSE
* if not. */ * if not. */
int load_char(const char *name, struct char_data *ch) int load_char(const char *name, struct char_data *ch)
@ -228,7 +224,7 @@ int load_char(const char *name, struct char_data *ch)
GET_HEIGHT(ch) = PFDEF_HEIGHT; GET_HEIGHT(ch) = PFDEF_HEIGHT;
GET_WEIGHT(ch) = PFDEF_WEIGHT; GET_WEIGHT(ch) = PFDEF_WEIGHT;
GET_ALIGNMENT(ch) = PFDEF_ALIGNMENT; GET_ALIGNMENT(ch) = PFDEF_ALIGNMENT;
for (i = 0; i < NUM_OF_SAVE_THROWS; i++) for (i = 0; i < NUM_OF_SAVING_THROWS; i++)
GET_SAVE(ch, i) = PFDEF_SAVETHROW; GET_SAVE(ch, i) = PFDEF_SAVETHROW;
GET_LOADROOM(ch) = PFDEF_LOADROOM; GET_LOADROOM(ch) = PFDEF_LOADROOM;
GET_INVIS_LEV(ch) = PFDEF_INVISLEV; GET_INVIS_LEV(ch) = PFDEF_INVISLEV;
@ -260,11 +256,15 @@ int load_char(const char *name, struct char_data *ch)
GET_MAX_MOVE(ch) = PFDEF_MAXMOVE; GET_MAX_MOVE(ch) = PFDEF_MAXMOVE;
GET_OLC_ZONE(ch) = PFDEF_OLC; GET_OLC_ZONE(ch) = PFDEF_OLC;
GET_PAGE_LENGTH(ch) = PFDEF_PAGELENGTH; GET_PAGE_LENGTH(ch) = PFDEF_PAGELENGTH;
GET_SCREEN_WIDTH(ch) = PFDEF_SCREENWIDTH;
GET_ALIASES(ch) = NULL; GET_ALIASES(ch) = NULL;
SITTING(ch) = NULL; SITTING(ch) = NULL;
NEXT_SITTING(ch) = NULL; NEXT_SITTING(ch) = NULL;
GET_QUESTPOINTS(ch) = PFDEF_QUESTPOINTS; GET_QUESTPOINTS(ch) = PFDEF_QUESTPOINTS;
GET_QUEST_COUNTER(ch) = PFDEF_QUESTCOUNT;
GET_QUEST(ch) = PFDEF_CURRQUEST;
GET_NUM_QUESTS(ch) = PFDEF_COMPQUESTS;
for (i = 0; i < AF_ARRAY_MAX; i++) for (i = 0; i < AF_ARRAY_MAX; i++)
AFF_FLAGS(ch)[i] = PFDEF_AFFFLAGS; AFF_FLAGS(ch)[i] = PFDEF_AFFFLAGS;
for (i = 0; i < PM_ARRAY_MAX; i++) for (i = 0; i < PM_ARRAY_MAX; i++)
@ -387,6 +387,10 @@ int load_char(const char *name, struct char_data *ch)
case 'Q': case 'Q':
if (!strcmp(tag, "Qstp")) GET_QUESTPOINTS(ch) = atoi(line); if (!strcmp(tag, "Qstp")) GET_QUESTPOINTS(ch) = atoi(line);
else if (!strcmp(tag, "Qpnt")) GET_QUESTPOINTS(ch) = atoi(line); /* Backward compatibility */
else if (!strcmp(tag, "Qcur")) GET_QUEST(ch) = atoi(line);
else if (!strcmp(tag, "Qcnt")) GET_QUEST_COUNTER(ch) = atoi(line);
else if (!strcmp(tag, "Qest")) load_quests(fl, ch);
break; break;
case 'R': case 'R':
@ -395,6 +399,7 @@ int load_char(const char *name, struct char_data *ch)
case 'S': case 'S':
if (!strcmp(tag, "Sex ")) GET_SEX(ch) = atoi(line); if (!strcmp(tag, "Sex ")) GET_SEX(ch) = atoi(line);
else if (!strcmp(tag, "ScrW")) GET_SCREEN_WIDTH(ch) = atoi(line);
else if (!strcmp(tag, "Skil")) load_skills(fl, ch); else if (!strcmp(tag, "Skil")) load_skills(fl, ch);
else if (!strcmp(tag, "Str ")) load_HMVS(ch, line, LOAD_STRENGTH); else if (!strcmp(tag, "Str ")) load_HMVS(ch, line, LOAD_STRENGTH);
break; break;
@ -531,9 +536,9 @@ void save_char(struct char_data * ch)
if (GET_LEVEL(ch) != PFDEF_LEVEL) fprintf(fl, "Levl: %d\n", GET_LEVEL(ch)); if (GET_LEVEL(ch) != PFDEF_LEVEL) fprintf(fl, "Levl: %d\n", GET_LEVEL(ch));
fprintf(fl, "Id : %ld\n", GET_IDNUM(ch)); fprintf(fl, "Id : %ld\n", GET_IDNUM(ch));
fprintf(fl, "Brth: %ld\n", ch->player.time.birth); fprintf(fl, "Brth: %ld\n", (long)ch->player.time.birth);
fprintf(fl, "Plyd: %d\n", ch->player.time.played); fprintf(fl, "Plyd: %d\n", ch->player.time.played);
fprintf(fl, "Last: %ld\n", ch->player.time.logon); fprintf(fl, "Last: %ld\n", (long)ch->player.time.logon);
if (GET_HOST(ch)) fprintf(fl, "Host: %s\n", GET_HOST(ch)); if (GET_HOST(ch)) fprintf(fl, "Host: %s\n", GET_HOST(ch));
if (GET_HEIGHT(ch) != PFDEF_HEIGHT) fprintf(fl, "Hite: %d\n", GET_HEIGHT(ch)); if (GET_HEIGHT(ch) != PFDEF_HEIGHT) fprintf(fl, "Hite: %d\n", GET_HEIGHT(ch));
@ -598,8 +603,18 @@ void save_char(struct char_data * ch)
if (GET_DAMROLL(ch) != PFDEF_DAMROLL) fprintf(fl, "Drol: %d\n", GET_DAMROLL(ch)); if (GET_DAMROLL(ch) != PFDEF_DAMROLL) fprintf(fl, "Drol: %d\n", GET_DAMROLL(ch));
if (GET_OLC_ZONE(ch) != PFDEF_OLC) fprintf(fl, "Olc : %d\n", GET_OLC_ZONE(ch)); if (GET_OLC_ZONE(ch) != PFDEF_OLC) fprintf(fl, "Olc : %d\n", GET_OLC_ZONE(ch));
if (GET_PAGE_LENGTH(ch) != PFDEF_PAGELENGTH) fprintf(fl, "Page: %d\n", GET_PAGE_LENGTH(ch)); if (GET_PAGE_LENGTH(ch) != PFDEF_PAGELENGTH) fprintf(fl, "Page: %d\n", GET_PAGE_LENGTH(ch));
if (GET_SCREEN_WIDTH(ch) != PFDEF_SCREENWIDTH) fprintf(fl, "ScrW: %d\n", GET_SCREEN_WIDTH(ch));
if (GET_QUESTPOINTS(ch) != PFDEF_QUESTPOINTS) fprintf(fl, "Qstp: %d\n", GET_QUESTPOINTS(ch)); if (GET_QUESTPOINTS(ch) != PFDEF_QUESTPOINTS) fprintf(fl, "Qstp: %d\n", GET_QUESTPOINTS(ch));
if (GET_QUEST_COUNTER(ch)!= PFDEF_QUESTCOUNT) fprintf(fl, "Qcnt: %d\n", GET_QUEST_COUNTER(ch));
if (GET_NUM_QUESTS(ch) != PFDEF_COMPQUESTS) {
fprintf(fl, "Qest:\n");
for (i = 0; i < GET_NUM_QUESTS(ch); i++)
fprintf(fl, "%d\n", ch->player_specials->saved.completed_quests[i]);
fprintf(fl, "%d\n", NOTHING);
}
if (GET_QUEST(ch) != PFDEF_CURRQUEST) fprintf(fl, "Qcur: %d\n", GET_QUEST(ch));
/* Save skills */ /* Save skills */
if (GET_LEVEL(ch) < LVL_IMMORT) { if (GET_LEVEL(ch) < LVL_IMMORT) {
fprintf(fl, "Skil:\n"); fprintf(fl, "Skil:\n");
@ -755,7 +770,7 @@ void clean_pfiles(void)
* entries of the players that were just deleted. */ * entries of the players that were just deleted. */
} }
void load_affects(FILE *fl, struct char_data *ch) static void load_affects(FILE *fl, struct char_data *ch)
{ {
int num = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, i; int num = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, i;
char line[MAX_INPUT_LENGTH + 1]; char line[MAX_INPUT_LENGTH + 1];
@ -777,7 +792,7 @@ void load_affects(FILE *fl, struct char_data *ch)
} while (num != 0); } while (num != 0);
} }
void load_skills(FILE *fl, struct char_data *ch) static void load_skills(FILE *fl, struct char_data *ch)
{ {
int num = 0, num2 = 0; int num = 0, num2 = 0;
char line[MAX_INPUT_LENGTH + 1]; char line[MAX_INPUT_LENGTH + 1];
@ -790,7 +805,20 @@ void load_skills(FILE *fl, struct char_data *ch)
} while (num != 0); } while (num != 0);
} }
void load_HMVS(struct char_data *ch, const char *line, int mode) void load_quests(FILE *fl, struct char_data *ch)
{
int num = NOTHING;
char line[MAX_INPUT_LENGTH + 1];
do {
get_line(fl, line);
sscanf(line, "%d", &num);
if (num != NOTHING)
add_completed_quest(ch, num);
} while (num != NOTHING);
}
static void load_HMVS(struct char_data *ch, const char *line, int mode)
{ {
int num = 0, num2 = 0; int num = 0, num2 = 0;
@ -820,7 +848,7 @@ void load_HMVS(struct char_data *ch, const char *line, int mode)
} }
/* Aliases are now saved in pfiles only. */ /* Aliases are now saved in pfiles only. */
void write_aliases_ascii(FILE *file, struct char_data *ch) static void write_aliases_ascii(FILE *file, struct char_data *ch)
{ {
struct alias_data *temp; struct alias_data *temp;
int count = 0; int count = 0;
@ -844,7 +872,7 @@ void write_aliases_ascii(FILE *file, struct char_data *ch)
} }
} }
void read_aliases_ascii(FILE *file, struct char_data *ch, int count) static void read_aliases_ascii(FILE *file, struct char_data *ch, int count)
{ {
int i; int i;
struct alias_data *temp; struct alias_data *temp;

View file

@ -19,6 +19,11 @@
* THIS GENERATOR REPRESENTS THE MINIMUM STANDARD AGAINST WHICH OTHER * THIS GENERATOR REPRESENTS THE MINIMUM STANDARD AGAINST WHICH OTHER
* GENERATORS SHOULD BE JUDGED. */ * GENERATORS SHOULD BE JUDGED. */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h" /* for function prototypes */
#define m (unsigned long)2147483647 #define m (unsigned long)2147483647
#define q (unsigned long)127773 #define q (unsigned long)127773
@ -37,10 +42,6 @@
static unsigned long seed; static unsigned long seed;
/* local functions */
void circle_srandom(unsigned long initial_seed);
unsigned long circle_random(void);
void circle_srandom(unsigned long initial_seed) void circle_srandom(unsigned long initial_seed)
{ {
seed = initial_seed; seed = initial_seed;

View file

@ -20,16 +20,16 @@
#include "improved-edit.h" #include "improved-edit.h"
#include "dg_olc.h" #include "dg_olc.h"
#include "constants.h" #include "constants.h"
#include "modify.h"
/* local functions */ /* local functions */
void redit_setup_new(struct descriptor_data *d); static void redit_setup_new(struct descriptor_data *d);
void redit_setup_existing(struct descriptor_data *d, int real_num); static void redit_disp_extradesc_menu(struct descriptor_data *d);
void redit_disp_extradesc_menu(struct descriptor_data *d); static void redit_disp_exit_menu(struct descriptor_data *d);
void redit_disp_exit_menu(struct descriptor_data *d); static void redit_disp_exit_flag_menu(struct descriptor_data *d);
void redit_disp_exit_flag_menu(struct descriptor_data *d); static void redit_disp_flag_menu(struct descriptor_data *d);
void redit_disp_flag_menu(struct descriptor_data *d); static void redit_disp_sector_menu(struct descriptor_data *d);
void redit_disp_sector_menu(struct descriptor_data *d); static void redit_disp_menu(struct descriptor_data *d);
void redit_disp_menu(struct descriptor_data *d);
/* Utils and exported functions. */ /* Utils and exported functions. */
ACMD(do_oasis_redit) ACMD(do_oasis_redit)
@ -148,7 +148,7 @@ ACMD(do_oasis_redit)
GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch)); GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch));
} }
void redit_setup_new(struct descriptor_data *d) static void redit_setup_new(struct descriptor_data *d)
{ {
CREATE(OLC_ROOM(d), struct room_data, 1); CREATE(OLC_ROOM(d), struct room_data, 1);
@ -298,7 +298,7 @@ void free_room(struct room_data *room)
/* Menu functions */ /* Menu functions */
/* For extra descriptions. */ /* For extra descriptions. */
void redit_disp_extradesc_menu(struct descriptor_data *d) static void redit_disp_extradesc_menu(struct descriptor_data *d)
{ {
struct extra_descr_data *extra_desc = OLC_DESC(d); struct extra_descr_data *extra_desc = OLC_DESC(d);
@ -319,7 +319,7 @@ void redit_disp_extradesc_menu(struct descriptor_data *d)
} }
/* For exits. */ /* For exits. */
void redit_disp_exit_menu(struct descriptor_data *d) static void redit_disp_exit_menu(struct descriptor_data *d)
{ {
char door_buf[24]; char door_buf[24];
/* if exit doesn't exist, alloc/create it */ /* if exit doesn't exist, alloc/create it */
@ -358,7 +358,7 @@ void redit_disp_exit_menu(struct descriptor_data *d)
} }
/* For exit flags. */ /* For exit flags. */
void redit_disp_exit_flag_menu(struct descriptor_data *d) static void redit_disp_exit_flag_menu(struct descriptor_data *d)
{ {
get_char_colors(d->character); get_char_colors(d->character);
write_to_output(d, "%s0%s) No door\r\n" write_to_output(d, "%s0%s) No door\r\n"
@ -368,7 +368,7 @@ void redit_disp_exit_flag_menu(struct descriptor_data *d)
} }
/* For room flags. */ /* For room flags. */
void redit_disp_flag_menu(struct descriptor_data *d) static void redit_disp_flag_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int counter, columns = 0; int counter, columns = 0;
@ -386,7 +386,7 @@ void redit_disp_flag_menu(struct descriptor_data *d)
} }
/* For sector type. */ /* For sector type. */
void redit_disp_sector_menu(struct descriptor_data *d) static void redit_disp_sector_menu(struct descriptor_data *d)
{ {
int counter, columns = 0; int counter, columns = 0;
@ -400,7 +400,7 @@ void redit_disp_sector_menu(struct descriptor_data *d)
} }
/* The main menu. */ /* The main menu. */
void redit_disp_menu(struct descriptor_data *d) static void redit_disp_menu(struct descriptor_data *d)
{ {
char buf1[MAX_STRING_LENGTH]; char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH];

View file

@ -1,12 +1,16 @@
/************************************************************************** /**
* File: screen.h Part of tbaMUD * * @file screen.h
* Usage: Header file with ANSI color codes for online color. * * Header file with ANSI color codes for online color.
* * *
* All rights reserved. See license.doc for complete information. * * Part of the core tbaMUD source code distribution, which is a derivative
* * * of, and continuation of, CircleMUD.
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * * All rights reserved. See license 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 _SCREEN_H_
#define _SCREEN_H_
#define CNRM "\x1B[0;0m" /* "Normal" */ #define CNRM "\x1B[0;0m" /* "Normal" */
#define CNUL "" /* No Change */ #define CNUL "" /* No Change */
@ -175,3 +179,5 @@
#define QBKMAG CBKMAG(ch,C_SPR) #define QBKMAG CBKMAG(ch,C_SPR)
#define QBKCYN CBKCYN(ch,C_SPR) #define QBKCYN CBKCYN(ch,C_SPR)
#define QBKWHT CBKWHT(ch,C_SPR) #define QBKWHT CBKWHT(ch,C_SPR)
#endif /* _SCREEN_H_ */

View file

@ -18,27 +18,20 @@
#include "genzon.h" #include "genzon.h"
#include "oasis.h" #include "oasis.h"
#include "constants.h" #include "constants.h"
#include "shop.h"
/* external functions */
SPECIAL(shop_keeper);
/* external variables */
extern const char *trade_letters[];
extern const char *shop_bits[];
/* local functions */ /* local functions */
void sedit_setup_new(struct descriptor_data *d); static void sedit_setup_new(struct descriptor_data *d);
void sedit_setup_existing(struct descriptor_data *d, int rshop_num); static void sedit_save_to_disk(int zone_num);
void sedit_save_internally(struct descriptor_data *d); static void sedit_products_menu(struct descriptor_data *d);
void sedit_save_to_disk(int zone_num); static void sedit_compact_rooms_menu(struct descriptor_data *d);
void sedit_products_menu(struct descriptor_data *d); static void sedit_rooms_menu(struct descriptor_data *d);
void sedit_compact_rooms_menu(struct descriptor_data *d); static void sedit_namelist_menu(struct descriptor_data *d);
void sedit_rooms_menu(struct descriptor_data *d); static void sedit_shop_flags_menu(struct descriptor_data *d);
void sedit_namelist_menu(struct descriptor_data *d); static void sedit_no_trade_menu(struct descriptor_data *d);
void sedit_shop_flags_menu(struct descriptor_data *d); static void sedit_types_menu(struct descriptor_data *d);
void sedit_no_trade_menu(struct descriptor_data *d); static void sedit_disp_menu(struct descriptor_data *d);
void sedit_types_menu(struct descriptor_data *d);
void sedit_disp_menu(struct descriptor_data *d);
void sedit_save_internally(struct descriptor_data *d) void sedit_save_internally(struct descriptor_data *d)
{ {
@ -46,7 +39,7 @@ void sedit_save_internally(struct descriptor_data *d)
add_shop(OLC_SHOP(d)); add_shop(OLC_SHOP(d));
} }
void sedit_save_to_disk(int num) static void sedit_save_to_disk(int num)
{ {
save_shops(num); save_shops(num);
} }
@ -174,7 +167,7 @@ ACMD(do_oasis_sedit)
GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch)); GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch));
} }
void sedit_setup_new(struct descriptor_data *d) static void sedit_setup_new(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
@ -219,7 +212,7 @@ void sedit_setup_existing(struct descriptor_data *d, int rshop_num)
} }
/* Menu functions */ /* Menu functions */
void sedit_products_menu(struct descriptor_data *d) static void sedit_products_menu(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
int i; int i;
@ -243,7 +236,7 @@ void sedit_products_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_PRODUCTS_MENU; OLC_MODE(d) = SEDIT_PRODUCTS_MENU;
} }
void sedit_compact_rooms_menu(struct descriptor_data *d) static void sedit_compact_rooms_menu(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
int i; int i;
@ -269,7 +262,7 @@ void sedit_compact_rooms_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_ROOMS_MENU; OLC_MODE(d) = SEDIT_ROOMS_MENU;
} }
void sedit_rooms_menu(struct descriptor_data *d) static void sedit_rooms_menu(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
int i; int i;
@ -300,7 +293,7 @@ void sedit_rooms_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_ROOMS_MENU; OLC_MODE(d) = SEDIT_ROOMS_MENU;
} }
void sedit_namelist_menu(struct descriptor_data *d) static void sedit_namelist_menu(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
int i; int i;
@ -324,7 +317,7 @@ void sedit_namelist_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_NAMELIST_MENU; OLC_MODE(d) = SEDIT_NAMELIST_MENU;
} }
void sedit_shop_flags_menu(struct descriptor_data *d) static void sedit_shop_flags_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int i, count = 0; int i, count = 0;
@ -341,7 +334,7 @@ void sedit_shop_flags_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_SHOP_FLAGS; OLC_MODE(d) = SEDIT_SHOP_FLAGS;
} }
void sedit_no_trade_menu(struct descriptor_data *d) static void sedit_no_trade_menu(struct descriptor_data *d)
{ {
char bits[MAX_STRING_LENGTH]; char bits[MAX_STRING_LENGTH];
int i, count = 0; int i, count = 0;
@ -358,7 +351,7 @@ void sedit_no_trade_menu(struct descriptor_data *d)
OLC_MODE(d) = SEDIT_NOTRADE; OLC_MODE(d) = SEDIT_NOTRADE;
} }
void sedit_types_menu(struct descriptor_data *d) static void sedit_types_menu(struct descriptor_data *d)
{ {
struct shop_data *shop; struct shop_data *shop;
int i, count = 0; int i, count = 0;
@ -376,7 +369,7 @@ void sedit_types_menu(struct descriptor_data *d)
} }
/* Display main menu. */ /* Display main menu. */
void sedit_disp_menu(struct descriptor_data *d) static void sedit_disp_menu(struct descriptor_data *d)
{ {
char buf1[MAX_STRING_LENGTH]; char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH];

Some files were not shown because too many files have changed in this diff Show more