Setting up 3.5.0 as trunk

This commit is contained in:
Rumble 2006-12-19 22:56:18 +00:00
parent 0ddbd8b56e
commit 99e3aa4d8b
1336 changed files with 514917 additions and 0 deletions

199
src/Makefile.amiga Normal file
View file

@ -0,0 +1,199 @@
# CircleMUD Makefile.in - Makefile template used by 'configure'
#
# C compiler to use
CC = gcc
# Any special flags you want to pass to the compiler
MYFLAGS =
#Amiga Stuff <jpatton@intserv.com>
MYFLAGS = -g -Wall -DAMIGA -DNOCRYPT
LIBS = -lc -lamiga -lauto
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.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 \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
spells.o utils.o weather.o alias.o players.o
default: .accepted
$(MAKE) ../bin/circle
.accepted:
./licheck
utils: .accepted
$(MAKE) ../bin/asciipasswd
$(MAKE) ../bin/autowiz
$(MAKE) ../bin/listrent
$(MAKE) ../bin/plrtoascii
$(MAKE) ../bin/shopconv
$(MAKE) ../bin/sign
$(MAKE) ../bin/split
$(MAKE) ../bin/wld2html
all: .accepted
$(MAKE) ../bin/circle
$(MAKE) utils
circle:
$(MAKE) ../bin/circle
asciipasswd:
$(MAKE) ../bin/asciipasswd
autowiz:
$(MAKE) ../bin/autowiz
listrent:
$(MAKE) ../bin/listrent
plrtoascii:
$(MAKE) ../bin/plrtoascii
shopconv:
$(MAKE) ../bin/shopconv
sign:
$(MAKE) ../bin/sign
split:
$(MAKE) ../bin/split
wld2html:
$(MAKE) ../bin/wld2html
../bin/asciipasswd: util/asciipasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/asciipasswd util/asciipasswd.c $(LIBS)
../bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) -o ../bin/autowiz util/autowiz.c
../bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/listrent util/listrent.c
../bin/plrtoascii: util/plrtoascii.c conf.h sysdep.h db.h pfdefaults.h
$(CC) $(CFLAGS) -o ../bin/plrtoascii util/plrtoascii.c
../bin/shopconv: util/shopconv.c conf.h sysdep.h structs.h db.h utils.h shop.h
$(CC) $(CFLAGS) -o ../bin/shopconv util/shopconv.c
../bin/sign: util/sign.c conf.h sysdep.h
$(CC) $(CFLAGS) -o ../bin/sign util/sign.c $(LIBS)
../bin/split: util/split.c
$(CC) $(CFLAGS) -o ../bin/split util/split.c
../bin/wld2html: util/wld2html.c
$(CC) $(CFLAGS) -o ../bin/wld2html util/wld2html.c
../bin/circle : $(OBJFILES)
$(CC) -o ../bin/circle $(PROFILE) $(OBJFILES) $(LIBS)
clean:
rm -f *.o
# Dependencies for the object files (automagically generated with
# gcc -MM)
alias.o: alias.c conf.h sysdep.h structs.h utils.h interpreter.h db.h
$(CC) -c $(CFLAGS) alias.c
act.comm.o: act.comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h screen.h
$(CC) -c $(CFLAGS) act.comm.c
act.informative.o: act.informative.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h screen.h constants.h
$(CC) -c $(CFLAGS) act.informative.c
act.item.o: act.item.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.item.c
act.movement.o: act.movement.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h constants.h
$(CC) -c $(CFLAGS) act.movement.c
act.offensive.o: act.offensive.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.offensive.c
act.other.o: act.other.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h screen.h house.h
$(CC) -c $(CFLAGS) act.other.c
act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.social.c
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \
interpreter.h handler.h
$(CC) -c $(CFLAGS) boards.c
castle.o: castle.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) castle.c
class.o: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) -c $(CFLAGS) class.c
comm.o: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h house.h
$(CC) -c $(CFLAGS) comm.c
config.o: config.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) constants.c
db.o: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
interpreter.h house.h
$(CC) -c $(CFLAGS) db.c
fight.o: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
$(CC) -c $(CFLAGS) fight.c
graph.o: graph.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h spells.h
$(CC) -c $(CFLAGS) graph.c
handler.o: handler.c conf.h sysdep.h structs.h utils.h comm.h db.h handler.h \
interpreter.h spells.h
$(CC) -c $(CFLAGS) handler.c
house.o: house.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h house.h constants.h
$(CC) -c $(CFLAGS) house.c
interpreter.o: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
utils.h spells.h handler.h mail.h screen.h
$(CC) -c $(CFLAGS) interpreter.c
limits.o: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
$(CC) -c $(CFLAGS) limits.c
magic.o: magic.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h db.h
$(CC) -c $(CFLAGS) magic.c
mail.o: mail.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h \
handler.h mail.h
$(CC) -c $(CFLAGS) mail.c
mobact.o: mobact.c conf.h sysdep.h structs.h utils.h db.h comm.h interpreter.h \
handler.h spells.h
$(CC) -c $(CFLAGS) mobact.c
modify.o: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
comm.h spells.h mail.h boards.h
$(CC) -c $(CFLAGS) modify.c
objsave.o: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
$(CC) -c $(CFLAGS) objsave.c
olc.o: olc.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h \
olc.h
$(CC) -c $(CFLAGS) olc.c
players.o: players.c conf.h sysdep.h structs.h utils.h db.h handler.h pfdefaults.h
$(CC) -c $(CFLAGS) players.c
random.o: random.c
$(CC) -c $(CFLAGS) random.c
shop.o: shop.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h shop.h
$(CC) -c $(CFLAGS) shop.c
spec_assign.o: spec_assign.c conf.h sysdep.h structs.h db.h interpreter.h \
utils.h
$(CC) -c $(CFLAGS) spec_assign.c
spec_procs.o: spec_procs.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) spec_procs.c
spell_parser.o: spell_parser.c conf.h sysdep.h structs.h utils.h interpreter.h \
spells.h handler.h comm.h db.h
$(CC) -c $(CFLAGS) spell_parser.c
spells.o: spells.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h \
db.h constants.h
$(CC) -c $(CFLAGS) spells.c
utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
handler.h
$(CC) -c $(CFLAGS) utils.c
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c

157
src/Makefile.arc Normal file
View file

@ -0,0 +1,157 @@
# CircleMUD Makefile/arc - manually created (G. Duncan 13 June 98)
#
# C compiler to use
CC = gcc
LINK = drlink
# Any special flags you want to pass to the compiler
MYFLAGS = -O2 -Iunix:Sockets.Include -Irun:
LIBS = unix:Sockets.Libs.o.socklib unix:Sockets.Libs.o.inetlib \
gcc:o.libgcc unix:o.UnixLib -rescan
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
BINDIR = ^.bin
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = o.comm act.o.comm act.o.informative act.o.movement act.o.item \
act.o.offensive act.o.other act.o.social act.o.wizard o.ban o.boards \
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.objsave o.olc o.random o.shop o.spec_assign o.spec_procs \
o.spell_parser o.spells o.utils o.weather o.players o.alias
default: all
all: $(BINDIR).circle
$(BINDIR).circle: $(OBJFILES)
$(LINK) -o $(BINDIR).circle $(PROFILE) $(OBJFILES) $(LIBS)
clean:
wipe o.* ~V~CF
# Dependencies for the object files (automagically generated with
# gcc -MM)
o.alias: c.alias h.conf h.sysdep h.structs h.utils h.interpreter h.db
$(CC) -c $(CFLAGS) c.alias -o o.alias
act.o.comm: act.c.comm h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.screen
$(CC) -c $(CFLAGS) act.c.comm -o act.o.comm
act.o.informative: act.c.informative h.conf h.sysdep \
h.structs h.utils h.comm h.interpreter \
h.handler h.db h.spells h.screen h.constants
$(CC) -c $(CFLAGS) act.c.informative -o act.o.informative
act.o.item: act.c.item h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.spells
$(CC) -c $(CFLAGS) act.c.item -o act.o.item
act.o.movement: act.c.movement h.conf h.sysdep \
h.structs h.utils h.comm h.interpreter \
h.handler h.db h.spells h.house h.constants
$(CC) -c $(CFLAGS) act.c.movement -o act.o.movement
act.o.offensive: act.c.offensive h.conf h.sysdep \
h.structs h.utils h.comm h.interpreter \
h.handler h.db h.spells
$(CC) -c $(CFLAGS) act.c.offensive -o act.o.offensive
act.o.other: act.c.other h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.spells h.screen h.house
$(CC) -c $(CFLAGS) act.c.other -o act.o.other
act.o.social: act.c.social h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.spells
$(CC) -c $(CFLAGS) act.c.social -o act.o.social
act.o.wizard: act.c.wizard h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.spells h.house h.screen h.constants
$(CC) -c $(CFLAGS) act.c.wizard -o act.o.wizard
o.ban: c.ban h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler h.db
$(CC) -c $(CFLAGS) c.ban
o.boards: c.boards h.conf h.sysdep h.structs h.utils h.comm h.db h.boards \
h.interpreter h.handler
$(CC) -c $(CFLAGS) c.boards
o.castle: c.castle h.conf h.sysdep h.structs h.utils h.comm h.interpreter \
h.handler h.db h.spells
$(CC) -c $(CFLAGS) c.castle
o.class: c.class h.conf h.sysdep h.structs h.db h.utils h.spells h.interpreter
$(CC) -c $(CFLAGS) c.class
o.comm: c.comm h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler \
h.db h.house
$(CC) -c $(CFLAGS) c.comm
o.config: c.config h.conf h.sysdep h.structs
$(CC) -c $(CFLAGS) c.config
o.constants: c.constants h.conf h.sysdep h.structs
$(CC) -c $(CFLAGS) c.constants
o.db: c.db h.conf h.sysdep h.structs h.utils h.db h.comm h.handler h.spells h.mail \
h.interpreter h.house
$(CC) -c $(CFLAGS) c.db
o.fight: c.fight h.conf h.sysdep h.structs h.utils h.comm h.handler h.interpreter \
h.db h.spells h.screen
$(CC) -c $(CFLAGS) c.fight
o.graph: c.graph h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler \
h.db h.spells
$(CC) -c $(CFLAGS) c.graph
o.handler: c.handler h.conf h.sysdep h.structs h.utils h.comm h.db h.handler \
h.interpreter h.spells
$(CC) -c $(CFLAGS) c.handler
o.house: c.house h.conf h.sysdep h.structs h.comm h.handler h.db h.interpreter \
h.utils h.house h.constants
$(CC) -c $(CFLAGS) c.house
o.interpreter: c.interpreter h.conf h.sysdep h.structs h.comm h.interpreter h.db \
h.utils h.spells h.handler h.mail h.screen
$(CC) -c $(CFLAGS) c.interpreter
o.limits: c.limits h.conf h.sysdep h.structs h.utils h.spells h.comm h.db \
h.handler
$(CC) -c $(CFLAGS) c.limits
o.magic: c.magic h.conf h.sysdep h.structs h.utils h.comm h.spells h.handler h.db
$(CC) -c $(CFLAGS) c.magic
o.mail: c.mail h.conf h.sysdep h.structs h.utils h.comm h.db h.interpreter \
h.handler h.mail
$(CC) -c $(CFLAGS) c.mail
o.mobact: c.mobact h.conf h.sysdep h.structs h.utils h.db h.comm h.interpreter \
h.handler h.spells
$(CC) -c $(CFLAGS) c.mobact
o.modify: c.modify h.conf h.sysdep h.structs h.utils h.interpreter h.handler h.db \
h.comm h.spells h.mail h.boards
$(CC) -c $(CFLAGS) c.modify
o.objsave: c.objsave h.conf h.sysdep h.structs h.comm h.handler h.db \
h.interpreter h.utils h.spells
$(CC) -c $(CFLAGS) c.objsave
o.olc: c.olc h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler h.db \
h.olc
$(CC) -c $(CFLAGS) c.olc
o.players: c.players.c h.conf h.sysdep h.structs h.utils h.db h.handler h.pfdefaults
$(CC) -c $(CFLAGS) c.players
o.random: c.random h.utils
$(CC) -c $(CFLAGS) c.random
o.shop: c.shop h.conf h.sysdep h.structs h.comm h.handler h.db h.interpreter \
h.utils h.shop
$(CC) -c $(CFLAGS) c.shop
o.spec_assign: c.spec_assign h.conf h.sysdep h.structs h.db h.interpreter \
h.utils
$(CC) -c $(CFLAGS) c.spec_assign
o.spec_procs: c.spec_procs h.conf h.sysdep h.structs h.utils h.comm \
h.interpreter h.handler h.db h.spells
$(CC) -c $(CFLAGS) c.spec_procs
o.spell_parser: c.spell_parser h.conf h.sysdep h.structs h.utils h.interpreter \
h.spells h.handler h.comm h.db
$(CC) -c $(CFLAGS) c.spell_parser
o.spells: c.spells h.conf h.sysdep h.structs h.utils h.comm h.spells h.handler \
h.db h.constants
$(CC) -c $(CFLAGS) c.spells
o.utils: c.utils h.conf h.sysdep h.structs h.utils h.comm h.screen h.spells \
h.handler h.db
$(CC) -c $(CFLAGS) c.utils
o.weather: c.weather h.conf h.sysdep h.structs h.utils h.comm h.handler \
h.interpreter h.db
$(CC) -c $(CFLAGS) c.weather

336
src/Makefile.bcc Normal file
View file

@ -0,0 +1,336 @@
#
# Borland C++ IDE generated makefile
# Generated 12/26/97 at 5:04:53 AM
#
.AUTODEPEND
#
# Borland C++ tools
#
IMPLIB = Implib
BCC32 = Bcc32 +BccW32.cfg
BCC32I = Bcc32i +BccW32.cfg
TLINK32 = TLink32
TLIB = TLib
BRC32 = Brc32
TASM32 = Tasm32
#
# IDE macros
#
#
# Options
#
IDE_LinkFLAGS32 = -LC:\BC5\LIB
LinkerLocalOptsAtC32_circledexe = -Tpe -ap -c
ResLocalOptsAtC32_circledexe =
BLocalOptsAtC32_circledexe =
CompInheritOptsAt_circledexe = -IC:\BC5\INCLUDE -D_RTLDLL;_BIDSDLL;
LinkerInheritOptsAt_circledexe = -x
LinkerOptsAt_circledexe = $(LinkerLocalOptsAtC32_circledexe)
ResOptsAt_circledexe = $(ResLocalOptsAtC32_circledexe)
BOptsAt_circledexe = $(BLocalOptsAtC32_circledexe)
#
# Dependency List
#
Dep_circle = \
circle.exe
circle : BccW32.cfg $(Dep_circle)
echo MakeNode
Dep_circledexe = \
alias.obj\
act.comm.obj\
act.movement.obj\
act.item.obj\
act.informative.obj\
act.offensive.obj\
act.other.obj\
boards.obj\
ban.obj\
act.wizard.obj\
act.social.obj\
castle.obj\
class.obj\
db.obj\
constants.obj\
config.obj\
comm.obj\
fight.obj\
graph.obj\
limits.obj\
interpreter.obj\
house.obj\
handler.obj\
magic.obj\
mail.obj\
olc.obj\
objsave.obj\
players.obj\
modify.obj\
mobact.obj\
random.obj\
shop.obj\
spells.obj\
spell_parser.obj\
spec_procs.obj\
spec_assign.obj\
utils.obj\
weather.obj
circle.exe : $(Dep_circledexe)
$(TLINK32) @&&|
/v $(IDE_LinkFLAGS32) $(LinkerOptsAt_circledexe) $(LinkerInheritOptsAt_circledexe) +
C:\BC5\LIB\c0x32.obj+
alias.obj+
act.comm.obj+
act.movement.obj+
act.item.obj+
act.informative.obj+
act.offensive.obj+
act.other.obj+
boards.obj+
ban.obj+
act.wizard.obj+
act.social.obj+
castle.obj+
class.obj+
db.obj+
constants.obj+
config.obj+
comm.obj+
fight.obj+
graph.obj+
limits.obj+
interpreter.obj+
house.obj+
handler.obj+
magic.obj+
mail.obj+
olc.obj+
objsave.obj+
players.obj+
modify.obj+
mobact.obj+
random.obj+
shop.obj+
spells.obj+
spell_parser.obj+
spec_procs.obj+
spec_assign.obj+
utils.obj+
weather.obj
$<,$*
C:\BC5\LIB\bidsfi.lib+
C:\BC5\LIB\import32.lib+
C:\BC5\LIB\cw32i.lib
|
alias.obj : alias.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ alias.c
|
act.comm.obj : act.comm.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.comm.c
|
act.movement.obj : act.movement.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.movement.c
|
act.item.obj : act.item.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.item.c
|
act.informative.obj : act.informative.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.informative.c
|
act.offensive.obj : act.offensive.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.offensive.c
|
act.other.obj : act.other.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.other.c
|
boards.obj : boards.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ boards.c
|
ban.obj : ban.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ ban.c
|
act.wizard.obj : act.wizard.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.wizard.c
|
act.social.obj : act.social.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.social.c
|
castle.obj : castle.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ castle.c
|
class.obj : class.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ class.c
|
db.obj : db.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ db.c
|
constants.obj : constants.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ constants.c
|
config.obj : config.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ config.c
|
comm.obj : comm.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ comm.c
|
fight.obj : fight.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ fight.c
|
graph.obj : graph.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ graph.c
|
limits.obj : limits.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ limits.c
|
interpreter.obj : interpreter.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ interpreter.c
|
house.obj : house.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ house.c
|
handler.obj : handler.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ handler.c
|
magic.obj : magic.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ magic.c
|
mail.obj : mail.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ mail.c
|
olc.obj : olc.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ olc.c
|
objsave.obj : objsave.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ objsave.c
|
players.obj : players.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ players.c
modify.obj : modify.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ modify.c
|
mobact.obj : mobact.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ mobact.c
|
random.obj : random.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ random.c
|
shop.obj : shop.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ shop.c
|
spells.obj : spells.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spells.c
|
spell_parser.obj : spell_parser.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spell_parser.c
|
spec_procs.obj : spec_procs.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spec_procs.c
|
spec_assign.obj : spec_assign.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spec_assign.c
|
utils.obj : utils.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ utils.c
|
weather.obj : weather.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c
|
# Compiler configuration file
BccW32.cfg :
Copy &&|
-w
-R
-v
-vi
-H
-H=circle.csm
-WC
-g0
| $@

336
src/Makefile.bcc55 Normal file
View file

@ -0,0 +1,336 @@
# For Borland C++ 5.5
#
# Borland C++ IDE generated makefile
# Generated 12/26/97 at 5:04:53 AM
#
.AUTODEPEND
#
# Borland C++ tools
#
IMPLIB = Implib
BCC32 = Bcc32
BCC32I = Bcc32i
TLINK32 = ILink32
TLIB = TLib
BRC32 = Brc32
TASM32 = Tasm32
#
# IDE macros
#
#
# Options
#
IDE_LinkFLAGS32 = -LC:\BORLAND\BCC55\LIB
LinkerLocalOptsAtC32_circledexe = -Tpe -ap -c
ResLocalOptsAtC32_circledexe =
BLocalOptsAtC32_circledexe =
CompInheritOptsAt_circledexe = -IC:\BORLAND\BCC55\INCLUDE;
LinkerInheritOptsAt_circledexe = -x
LinkerOptsAt_circledexe = $(LinkerLocalOptsAtC32_circledexe)
ResOptsAt_circledexe = $(ResLocalOptsAtC32_circledexe)
BOptsAt_circledexe = $(BLocalOptsAtC32_circledexe)
#
# Dependency List
#
Dep_circle = \
circle.exe
circle : BccW32.cfg $(Dep_circle)
echo MakeNode
Dep_circledexe = \
alias.obj\
act.comm.obj\
act.movement.obj\
act.item.obj\
act.informative.obj\
act.offensive.obj\
act.other.obj\
boards.obj\
ban.obj\
act.wizard.obj\
act.social.obj\
castle.obj\
class.obj\
db.obj\
constants.obj\
config.obj\
comm.obj\
fight.obj\
graph.obj\
limits.obj\
interpreter.obj\
house.obj\
handler.obj\
magic.obj\
mail.obj\
olc.obj\
objsave.obj\
players.obj\
modify.obj\
mobact.obj\
random.obj\
shop.obj\
spells.obj\
spell_parser.obj\
spec_procs.obj\
spec_assign.obj\
utils.obj\
weather.obj
circle.exe : $(Dep_circledexe)
$(TLINK32) @&&|
/v $(IDE_LinkFLAGS32) $(LinkerOptsAt_circledexe) $(LinkerInheritOptsAt_circledexe) +
C:\BORLAND\BCC55\LIB\c0x32.obj+
alias.obj+
act.comm.obj+
act.movement.obj+
act.item.obj+
act.informative.obj+
act.offensive.obj+
act.other.obj+
boards.obj+
ban.obj+
act.wizard.obj+
act.social.obj+
castle.obj+
class.obj+
db.obj+
constants.obj+
config.obj+
comm.obj+
fight.obj+
graph.obj+
limits.obj+
interpreter.obj+
house.obj+
handler.obj+
magic.obj+
mail.obj+
olc.obj+
objsave.obj+
players.obj+
modify.obj+
mobact.obj+
random.obj+
shop.obj+
spells.obj+
spell_parser.obj+
spec_procs.obj+
spec_assign.obj+
utils.obj+
weather.obj
$<,$*
C:\BORLAND\BCC55\LIB\import32.lib+
C:\BORLAND\BCC55\LIB\cw32i.lib
|
alias.obj : alias.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ alias.c
|
act.comm.obj : act.comm.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.comm.c
|
act.movement.obj : act.movement.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.movement.c
|
act.item.obj : act.item.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.item.c
|
act.informative.obj : act.informative.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.informative.c
|
act.offensive.obj : act.offensive.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.offensive.c
|
act.other.obj : act.other.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.other.c
|
boards.obj : boards.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ boards.c
|
ban.obj : ban.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ ban.c
|
act.wizard.obj : act.wizard.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.wizard.c
|
act.social.obj : act.social.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.social.c
|
castle.obj : castle.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ castle.c
|
class.obj : class.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ class.c
|
db.obj : db.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ db.c
|
constants.obj : constants.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ constants.c
|
config.obj : config.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ config.c
|
comm.obj : comm.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ comm.c
|
fight.obj : fight.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ fight.c
|
graph.obj : graph.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ graph.c
|
limits.obj : limits.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ limits.c
|
interpreter.obj : interpreter.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ interpreter.c
|
house.obj : house.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ house.c
|
handler.obj : handler.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ handler.c
|
magic.obj : magic.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ magic.c
|
mail.obj : mail.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ mail.c
|
olc.obj : olc.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ olc.c
|
objsave.obj : objsave.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ objsave.c
|
players.obj : players.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ players.c
|
modify.obj : modify.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ modify.c
|
mobact.obj : mobact.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ mobact.c
|
random.obj : random.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ random.c
|
shop.obj : shop.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ shop.c
|
spells.obj : spells.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spells.c
|
spell_parser.obj : spell_parser.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spell_parser.c
|
spec_procs.obj : spec_procs.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spec_procs.c
|
spec_assign.obj : spec_assign.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ spec_assign.c
|
utils.obj : utils.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ utils.c
|
weather.obj : weather.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ weather.c
|
# Compiler configuration file
BccW32.cfg :
Copy &&|
-w
-R
-v
-vi
-H
-H=circle.csm
-WC
-g0
| $@

110
src/Makefile.in Normal file
View file

@ -0,0 +1,110 @@
# CircleMUD Makefile.in - Makefile template used by 'configure'
#
# C compiler to use
CC = @CC@
# Path to cxref utility
CXREF = cxref
# Any special flags you want to pass to the compiler
MYFLAGS = @MYFLAGS@
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
BINDIR = ../bin
CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE)
LIBS = @LIBS@ @CRYPTLIB@ @NETLIB@
OBJFILES = act.comm.o act.informative.o act.item.o act.movement.o \
act.offensive.o act.other.o act.social.o act.wizard.o alias.o ban.o \
boards.o castle.o cedit.o class.o comm.o config.o constants.o db.o \
fight.o genmob.o genobj.o genolc.o genshp.o genwld.o genzon.o graph.o \
handler.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 olc.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 bsd-snprintf.o \
dg_comm.o dg_db_scripts.o dg_event.o dg_handler.o dg_mobcmd.o \
dg_misc.o dg_objcmd.o dg_scripts.o dg_triggers.o dg_wldcmd.o dg_olc.o \
dg_variables.o \
context_help.o hedit.o aedit.o zmalloc.o players.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 alias.c ban.c \
boards.c castle.c cedit.c class.c comm.c config.c constants.c db.c \
fight.c genmob.c genobj.c genolc.c genshp.c genwld.c genzon.c graph.c \
handler.c house.c improved-edit.c interpreter.c limits.c magic.c mail.c \
medit.c mobact.c modify.c oasis.c oasis_copy.o oasis_delete.c \
oasis_list.o objsave.c oedit.c olc.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 hedit.c bsd-snprintf.c players.c
default: all
all: .accepted
$(MAKE) $(BINDIR)/circle
$(MAKE) utils
.accepted:
@./licheck @MORE@
utils: .accepted
(cd util; $(MAKE) all)
circle:
$(MAKE) $(BINDIR)/circle
$(BINDIR)/circle : $(OBJFILES)
$(CC) -o $(BINDIR)/circle $(PROFILE) $(OBJFILES) $(LIBS)
clean:
rm -f *.o
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
# gcc -MM)
depend:
$(CC) -MM *.c > depend
-include depend

579
src/Makefile.lcc Normal file
View file

@ -0,0 +1,579 @@
# Makefile for LCC-Win32 compile of CircleMUD
# Created by Eric Jones (mailto:fpicard@mindless.com)
# 08/31/98
# Added LCCDIR variable because new release of LCC-Win32 extracts
# to \LCC instead of \LCCPUB as in older versions
# Added DISTDIR variable to allow for an easy way to change
# where Circle is located, plus will allow for changes in the
# path between versions (e.g. bplZZ is circle30bplZZ)
# With addition of new variables as replacements for old
# hard-coded paths, display lines will be less than 80 columns
# thus less clutter on the screen during the make
LCCDIR=c:\lccpub
DISTDIR=c:\circle
CFLAGS=-c -I$(LCCDIR)\include -DLCC_WIN32
CC=lcc
OBJS=\
weather.obj \
utils.obj \
spells.obj \
spell_parser.obj \
spec_procs.obj \
spec_assign.obj \
shop.obj \
random.obj \
players.obj \
olc.obj \
objsave.obj \
modify.obj \
mobact.obj \
mail.obj \
magic.obj \
limits.obj \
interpreter.obj \
house.obj \
handler.obj \
graph.obj \
fight.obj \
db.obj \
constants.obj \
config.obj \
comm.obj \
class.obj \
castle.obj \
boards.obj \
ban.obj \
act.wizard.obj \
act.social.obj \
act.other.obj \
act.offensive.obj \
act.movement.obj \
act.item.obj \
act.informative.obj \
act.comm.obj \
alias.obj
LIBS=$(LCCDIR)\lib\wsock32.lib
circle.exe: $(OBJS)
lcclnk -subsystem console -o $(DISTDIR)\bin\circle.exe $(OBJS) $(LIBS)
# Build WEATHER.C
WEATHER_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\
weather.obj: $(WEATHER_C) $(DISTDIR)\src\weather.c
$(CC) $(CFLAGS) $(DISTDIR)\src\weather.c
# Build UTILS.C
UTILS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\handler.h\
utils.obj: $(UTILS_C) $(DISTDIR)\src\utils.c
$(CC) $(CFLAGS) $(DISTDIR)\src\utils.c
# Build SPELLS.C
SPELLS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\constants.h\
spells.obj: $(SPELLS_C) $(DISTDIR)\src\spells.c
$(CC) $(CFLAGS) $(DISTDIR)\src\spells.c
# Build SPELL_PARSER.C
SPELL_PARSER_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
spell_parser.obj: $(SPELL_PARSER_C) $(DISTDIR)\src\spell_parser.c
$(CC) $(CFLAGS) $(DISTDIR)\src\spell_parser.c
# Build SPEC_PROCS.C
SPEC_PROCS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
spec_procs.obj: $(SPEC_PROCS_C) $(DISTDIR)\src\spec_procs.c
$(CC) $(CFLAGS) $(DISTDIR)\src\spec_procs.c
# Build SPEC_ASSIGN.C
SPEC_ASSIGN_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\utils.h\
spec_assign.obj: $(SPEC_ASSIGN_C) $(DISTDIR)\src\spec_assign.c
$(CC) $(CFLAGS) $(DISTDIR)\src\spec_assign.c
# Build SHOP.C
SHOP_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\shop.h\
shop.obj: $(SHOP_C) $(DISTDIR)\src\shop.c
$(CC) $(CFLAGS) $(DISTDIR)\src\shop.c
# Build RANDOM.C
RANDOM_C=\
random.obj: $(RANDOM_C) $(DISTDIR)\src\random.c
$(CC) $(CFLAGS) $(DISTDIR)\src\random.c
# Build PLAYERS.C
PLAYERS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\pfdefaults.h\
players.o: $(PLAYERS_C) $(DISTDIR)\src\players.c
$(CC) $(CFLAGS) $(DISTDIR)\src\players.c
# Build OLC.C
OLC_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\olc.h\
olc.obj: $(OLC_C) $(DISTDIR)\src\olc.c
$(CC) $(CFLAGS) $(DISTDIR)\src\olc.c
# Build OBJSAVE.C
OBJSAVE_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\spells.h\
objsave.obj: $(OBJSAVE_C) $(DISTDIR)\src\objsave.c
$(CC) $(CFLAGS) $(DISTDIR)\src\objsave.c
# Build MODIFY.C
MODIFY_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\mail.h\
$(DISTDIR)\src\boards.h\
modify.obj: $(MODIFY_C) $(DISTDIR)\src\modify.c
$(CC) $(CFLAGS) $(DISTDIR)\src\modify.c
# Build MOBACT.C
MOBACT_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\spells.h\
mobact.obj: $(MOBACT_C) $(DISTDIR)\src\mobact.c
$(CC) $(CFLAGS) $(DISTDIR)\src\mobact.c
# Build MAIL.C
MAIL_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\mail.h\
mail.obj: $(MAIL_C) $(DISTDIR)\src\mail.c
$(CC) $(CFLAGS) $(DISTDIR)\src\mail.c
# Build MAGIC.C
MAGIC_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
magic.obj: $(MAGIC_C) $(DISTDIR)\src\magic.c
$(CC) $(CFLAGS) $(DISTDIR)\src\magic.c
# Build LIMITS.C
LIMITS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\handler.h\
limits.obj: $(LIMITS_C) $(DISTDIR)\src\limits.c
$(CC) $(CFLAGS) $(DISTDIR)\src\limits.c
# Build INTERPRETER.C
INTERPRETER_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\mail.h\
$(DISTDIR)\src\screen.h\
interpreter.obj: $(INTERPRETER_C) $(DISTDIR)\src\interpreter.c
$(CC) $(CFLAGS) $(DISTDIR)\src\interpreter.c
# Build HOUSE.C
HOUSE_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\house.h\
$(DISTDIR)\src\constants.h\
house.obj: $(HOUSE_C) $(DISTDIR)\src\house.c
$(CC) $(CFLAGS) $(DISTDIR)\src\house.c
# Build HANDLER.C
HANDLER_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\spells.h\
handler.obj: $(HANDLER_C) $(DISTDIR)\src\handler.c
$(CC) $(CFLAGS) $(DISTDIR)\src\handler.c
# Build GRAPH.C
GRAPH_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
graph.obj: $(GRAPH_C) $(DISTDIR)\src\graph.c
$(CC) $(CFLAGS) $(DISTDIR)\src\graph.c
# Build FIGHT.C
FIGHT_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\spells.h\
$(DISTDIR)\src\screen.h\
fight.obj: $(FIGHT_C) $(DISTDIR)\src\fight.c
$(CC) $(CFLAGS) $(DISTDIR)\src\fight.c
# Build DB.C
DB_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\mail.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\house.h\
db.obj: $(DB_C) $(DISTDIR)\src\db.c
$(CC) $(CFLAGS) $(DISTDIR)\src\db.c
# Build CONSTANTS.C
CONSTANTS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
constants.obj: $(CONSTANTS_C) $(DISTDIR)\src\constants.c
$(CC) $(CFLAGS) $(DISTDIR)\src\constants.c
# Build CONFIG.C
CONFIG_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
config.obj: $(CONFIG_C) $(DISTDIR)\src\config.c
$(CC) $(CFLAGS) $(DISTDIR)\src\config.c
# Build COMM.C
COMM_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\house.h\
$(DISTDIR)\src\telnet.h\
comm.obj: $(COMM_C) $(DISTDIR)\src\comm.c
$(CC) $(CFLAGS) $(DISTDIR)\src\comm.c
# Build CLASS.C
CLASS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\interpreter.h\
class.obj: $(CLASS_C) $(DISTDIR)\src\class.c
$(CC) $(CFLAGS) $(DISTDIR)\src\class.c
# Build CASTLE.C
CASTLE_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
castle.obj: $(CASTLE_C) $(DISTDIR)\src\castle.c
$(CC) $(CFLAGS) $(DISTDIR)\src\castle.c
# Build BOARDS.C
BOARDS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\boards.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
boards.obj: $(BOARDS_C) $(DISTDIR)\src\boards.c
$(CC) $(CFLAGS) $(DISTDIR)\src\boards.c
# Build BAN.C
BAN_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
ban.obj: $(BAN_C) $(DISTDIR)\src\ban.c
$(CC) $(CFLAGS) $(DISTDIR)\src\ban.c
# Build ACT.WIZARD.C
ACT_WIZARD_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\house.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\constants.h\
act.wizard.obj: $(ACT_WIZARD_C) $(DISTDIR)\src\act.wizard.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.wizard.c
# Build ACT.SOCIAL.C
ACT_SOCIAL_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
act.social.obj: $(ACT_SOCIAL_C) $(DISTDIR)\src\act.social.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.social.c
# Build ACT.OTHER.C
ACT_OTHER_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\house.h\
act.other.obj: $(ACT_OTHER_C) $(DISTDIR)\src\act.other.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.other.c
# Build ACT.OFFENSIVE.C
ACT_OFFENSIVE_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
act.offensive.obj: $(ACT_OFFENSIVE_C) $(DISTDIR)\src\act.offensive.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.offensive.c
# Build ACT.MOVEMENT.C
ACT_MOVEMENT_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\house.h\
$(DISTDIR)\src\constants.h\
act.movement.obj: $(ACT_MOVEMENT_C) $(DISTDIR)\src\act.movement.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.movement.c
# Build ACT.ITEM.C
ACT_ITEM_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
act.item.obj: $(ACT_ITEM_C) $(DISTDIR)\src\act.item.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.item.c
# Build ACT.INFORMATIVE.C
ACT_INFORMATIVE_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\spells.h\
$(DISTDIR)\src\screen.h\
$(DISTDIR)\src\constants.h\
act.informative.obj: $(ACT_INFORMATIVE_C)
$(DISTDIR)\src\act.informative.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.informative.c
# Build ACT.COMM.C
ACT_COMM_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\screen.h\
act.comm.obj: $(ACT_COMM_C) $(DISTDIR)\src\act.comm.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.comm.c
# Build ALIAS.C
ALIAS_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\db.h\
alias.obj: $(ALIAS_C) $(DISTDIR)\src\alias.c
$(CC) $(CFLAGS) $(DISTDIR)\src\alias.c

160
src/Makefile.msvc Normal file
View file

@ -0,0 +1,160 @@
#
# CircleMUD Makefile for Microsoft Visual C++ 4.0, Windows 95/NT
# (manually created by Jeremy Elson)
#
# NOTE: This Makefile is only for MSVC 4.0. If you have a different
# compiler, see the file doc/README.WIN for instructions.
#
# This Makefile assumes that Microsoft Visual C++ v4.0 installed in
# \MSDEV. If you have MSVC++ installed in a different directory,
# change the CLFAGS and LIB lines to reflect the location of your
# header files and standard libraries, respectively.
#
# Make sure that the location of your compiler, linker, and make binaries
# (e.g., \msdev\bin) is in your path.
#
# COMPILER PARAMETERS
# Name of the C compiler
CC=cl
# Flags to pass to the compiler
CFLAGS = /nologo /I. /IC:\MSDEV\INCLUDE
# LINK PARAMETERS
# Name of the linker
LINK=link
# Directory that contains the standard libraries
LIB=C:\MSDEV\LIB
# Flags to pass to the linker
LFLAGS=/OUT:circle.exe /nologo /subsystem:console
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
MAKE = $(MAKE) /NOLOGO /S
OBJFILES = comm.obj act.comm.obj act.informative.obj act.movement.obj act.item.obj \
act.offensive.obj act.other.obj act.social.obj act.wizard.obj ban.obj boards.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 \
objsave.obj olc.obj shop.obj spec_assign.obj spec_procs.obj spell_parser.obj \
spells.obj utils.obj weather.obj random.obj alias.obj players.obj
default: circle.exe
$(MAKE) circle.exe
circle.exe : $(OBJFILES)
set lib=$(LIB)
$(LINK) $(LFLAGS) $(OBJFILES) wsock32.lib
# Dependencies for the object files (automagically generated with
# gcc -MM)
alias.obj: alias.c conf.h sysdep.h structs.h utils.h interpreter.h db.h
$(CC) -c $(CFLAGS) alias.c
act.comm.obj: act.comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h screen.h
$(CC) -c $(CFLAGS) act.comm.c
act.informative.obj: act.informative.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h screen.h constants.h
$(CC) -c $(CFLAGS) act.informative.c
act.item.obj: act.item.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.item.c
act.movement.obj: act.movement.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h constants.h
$(CC) -c $(CFLAGS) act.movement.c
act.offensive.obj: act.offensive.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.offensive.c
act.other.obj: act.other.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h screen.h house.h
$(CC) -c $(CFLAGS) act.other.c
act.social.obj: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.social.c
act.wizard.obj: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
ban.obj: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.obj: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \
interpreter.h handler.h
$(CC) -c $(CFLAGS) boards.c
castle.obj: castle.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) castle.c
class.obj: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) -c $(CFLAGS) class.c
comm.obj: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h house.h
$(CC) -c $(CFLAGS) comm.c
config.obj: config.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) config.c
constants.obj: constants.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) constants.c
db.obj: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
interpreter.h house.h
$(CC) -c $(CFLAGS) db.c
fight.obj: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
$(CC) -c $(CFLAGS) fight.c
graph.obj: graph.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h spells.h
$(CC) -c $(CFLAGS) graph.c
handler.obj: handler.c conf.h sysdep.h structs.h utils.h comm.h db.h handler.h \
interpreter.h spells.h
$(CC) -c $(CFLAGS) handler.c
house.obj: house.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h house.h constants.h
$(CC) -c $(CFLAGS) house.c
interpreter.obj: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
utils.h spells.h handler.h mail.h screen.h
$(CC) -c $(CFLAGS) interpreter.c
limits.obj: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
$(CC) -c $(CFLAGS) limits.c
magic.obj: magic.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h db.h
$(CC) -c $(CFLAGS) magic.c
mail.obj: mail.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h \
handler.h mail.h
$(CC) -c $(CFLAGS) mail.c
mobact.obj: mobact.c conf.h sysdep.h structs.h utils.h db.h comm.h interpreter.h \
handler.h spells.h
$(CC) -c $(CFLAGS) mobact.c
modify.obj: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
comm.h spells.h mail.h boards.h
$(CC) -c $(CFLAGS) modify.c
objsave.obj: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
$(CC) -c $(CFLAGS) objsave.c
olc.obj: olc.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h \
olc.h
$(CC) -c $(CFLAGS) olc.c
players.o: players.c conf.h sysdep.h structs.h utils.h db.h handler.h pfdefaults.h
$(CC) -c $(CFLAGS) players.c
random.obj: random.c
$(CC) -c $(CFLAGS) random.c
shop.obj: shop.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h shop.h
$(CC) -c $(CFLAGS) shop.c
spec_assign.obj: spec_assign.c conf.h sysdep.h structs.h db.h interpreter.h \
utils.h
$(CC) -c $(CFLAGS) spec_assign.c
spec_procs.obj: spec_procs.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) spec_procs.c
spell_parser.obj: spell_parser.c conf.h sysdep.h structs.h utils.h interpreter.h \
spells.h handler.h comm.h db.h
$(CC) -c $(CFLAGS) spell_parser.c
spells.obj: spells.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h \
db.h constants.h
$(CC) -c $(CFLAGS) spells.c
utils.obj: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
handler.h
$(CC) -c $(CFLAGS) utils.c
weather.obj: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c

201
src/Makefile.os2 Normal file
View file

@ -0,0 +1,201 @@
# CircleMUD Makefile for OS/2 (manually created by David Carver)
# C compiler to use
CC = gcc
# Any special flags you want to pass to the compiler
MYFLAGS = -O2 -Wall
#flags for profiling (see hacker.doc for more information)
PROFILE =
# Libraires that need to be included for use with GCC for OS/2
LIB = -lsocket
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
# For compiling circle with GDB debugger Information
#CFLAGS = -g -O $(MYFLAGS) $(PROFILE)
# Uncomment the line below if you don't want to compile with GDB info
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.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 \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
spells.o utils.o weather.o random.o alias.o players.o
default: .accepted
$(MAKE) ../bin/circle
.accepted:
@./licheck more
utils: .accepted
$(MAKE) ../bin/asciipasswd
$(MAKE) ../bin/autowiz
$(MAKE) ../bin/listrent
$(MAKE) ../bin/plrtoascii
$(MAKE) ../bin/shopconv
$(MAKE) ../bin/sign
$(MAKE) ../bin/split
$(MAKE) ../bin/wld2html
all: .accepted
$(MAKE) ../bin/circle
$(MAKE) utils
circle:
$(MAKE) ../bin/circle
asciipasswd:
$(MAKE) ../bin/asciipasswd
autowiz:
$(MAKE) ../bin/autowiz
listrent:
$(MAKE) ../bin/listrent
plrtoascii:
$(MAKE) ../bin/plrtoascii
shopconv:
$(MAKE) ../bin/shopconv
sign:
$(MAKE) ../bin/sign
split:
$(MAKE) ../bin/split
wld2html:
$(MAKE) ../bin/wld2html
../bin/asciipasswd: util/asciipasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/asciipasswd util/asciipasswd.c
../bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) -o ../bin/autowiz util/autowiz.c
../bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/listrent util/listrent.c
../bin/plrtoascii: util/plrtoascii.c conf.h sysdep.h db.h pfdefaults.h
$(CC) $(CFLAGS) -o ../bin/plrtoascii util/plrtoascii.c
../bin/shopconv: util/shopconv.c conf.h sysdep.h structs.h db.h utils.h shop.h
$(CC) $(CFLAGS) -o ../bin/shopconv util/shopconv.c
../bin/sign: util/sign.c conf.h sysdep.h
$(CC) $(CFLAGS) -o ../bin/sign util/sign.c
../bin/split: util/split.c
$(CC) $(CFLAGS) -o ../bin/split util/split.c
../bin/wld2html: util/wld2html.c
$(CC) $(CFLAGS) -o ../bin/wld2html util/wld2html.c
../bin/circle : $(OBJFILES)
$(CC) -o circle.exe $(PROFILE) $(OBJFILES) $(LIB)
clean:
rm -f *.o
# Dependencies for the object files (automagically generated with
# gcc -MM)
alias.o: alias.c conf.h sysdep.h structs.h utils.h interpreter.h db.h
$(CC) -c $(CFLAGS) alias.c
act.comm.o: act.comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h screen.h
$(CC) -c $(CFLAGS) act.comm.c
act.informative.o: act.informative.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h screen.h constants.h
$(CC) -c $(CFLAGS) act.informative.c
act.item.o: act.item.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.item.c
act.movement.o: act.movement.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h constants.h
$(CC) -c $(CFLAGS) act.movement.c
act.offensive.o: act.offensive.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.offensive.c
act.other.o: act.other.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h screen.h house.h
$(CC) -c $(CFLAGS) act.other.c
act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) act.social.c
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \
interpreter.h handler.h
$(CC) -c $(CFLAGS) boards.c
castle.o: castle.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) -c $(CFLAGS) castle.c
class.o: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) -c $(CFLAGS) class.c
comm.o: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h house.h
$(CC) -c $(CFLAGS) comm.c
config.o: config.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h
$(CC) -c $(CFLAGS) constants.c
db.o: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
interpreter.h house.h
$(CC) -c $(CFLAGS) db.c
fight.o: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
$(CC) -c $(CFLAGS) fight.c
graph.o: graph.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h spells.h
$(CC) -c $(CFLAGS) graph.c
handler.o: handler.c conf.h sysdep.h structs.h utils.h comm.h db.h handler.h \
interpreter.h spells.h
$(CC) -c $(CFLAGS) handler.c
house.o: house.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h house.h constants.h
$(CC) -c $(CFLAGS) house.c
interpreter.o: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
utils.h spells.h handler.h mail.h screen.h
$(CC) -c $(CFLAGS) interpreter.c
limits.o: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
$(CC) -c $(CFLAGS) limits.c
magic.o: magic.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h db.h
$(CC) -c $(CFLAGS) magic.c
mail.o: mail.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h \
handler.h mail.h
$(CC) -c $(CFLAGS) mail.c
mobact.o: mobact.c conf.h sysdep.h structs.h utils.h db.h comm.h interpreter.h \
handler.h spells.h
$(CC) -c $(CFLAGS) mobact.c
modify.o: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
comm.h spells.h mail.h boards.h
$(CC) -c $(CFLAGS) modify.c
objsave.o: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
$(CC) -c $(CFLAGS) objsave.c
olc.o: olc.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h \
olc.h
$(CC) -c $(CFLAGS) olc.c
players.o: players.c conf.h sysdep.h structs.h utils.h db.h handler.h pfdefaults.h
$(CC) -c $(CFLAGS) players.c
random.o: random.c
$(CC) -c $(CFLAGS) random.c
shop.o: shop.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h shop.h
$(CC) -c $(CFLAGS) shop.c
spec_assign.o: spec_assign.c conf.h sysdep.h structs.h db.h interpreter.h \
utils.h
$(CC) -c $(CFLAGS) spec_assign.c
spec_procs.o: spec_procs.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) -c $(CFLAGS) spec_procs.c
spell_parser.o: spell_parser.c conf.h sysdep.h structs.h utils.h interpreter.h \
spells.h handler.h comm.h db.h
$(CC) -c $(CFLAGS) spell_parser.c
spells.o: spells.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h \
db.h constants.h
$(CC) -c $(CFLAGS) spells.c
utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
handler.h
$(CC) -c $(CFLAGS) utils.c
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) -c $(CFLAGS) weather.c

12
src/SCOPTIONS Normal file
View file

@ -0,0 +1,12 @@
DATA=FAR
CODE=FAR
MATH=STANDARD
ANSI
NOSTACKCHECK
MODIFIED
STACKEXTEND
NOICONS
ONERROR=CONTINUE
INCLUDEDIR=include:netinclude
LIBRARY=LIB:net.lib
LINKEROPTIONS="bufsize 4096"

192
src/Smakefile Normal file
View file

@ -0,0 +1,192 @@
# CircleMUD makefile for the Amiga
# C compiler to use
CC = sc
# Any special flags you want to pass to the compiler
MYFLAGS =
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
CFLAGS = NOLINK $(MYFLAGS) $(PROFILE)
MAKE = SMAKE
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.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 \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
spells.o utils.o weather.o random.o players.o
default:
$(MAKE) /bin/circle
utils:
$(MAKE) /bin/asciipasswd
$(MAKE) /bin/autowiz
$(MAKE) /bin/listrent
$(MAKE) /bin/plrtoascii
$(MAKE) /bin/shopconv
$(MAKE) /bin/sign
$(MAKE) /bin/split
$(MAKE) /bin/wld2html
all: .accepted
$(MAKE) /bin/circle
$(MAKE) utils
circle:
$(MAKE) /bin/circle
asciipasswd:
$(MAKE) /bin/asciipasswd
autowiz:
$(MAKE) /bin/autowiz
listrent:
$(MAKE) /bin/listrent
plrtoascii:
$(MAKE) /bin/plrtoascii
shopconv:
$(MAKE) /bin/shopconv
sign:
$(MAKE) /bin/sign
split:
$(MAKE) /bin/split
wld2html:
$(MAKE) /bin/wld2html
/bin/asciipasswd: util/asciipasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) /bin/asciipasswd util/asciipasswd.c LINK
/bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) /bin/autowiz util/autowiz.c LINK
/bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) /bin/listrent util/listrent.c LINK
/bin/plrtoascii: util/plrtoascii.c conf.h sysdep.h db.h pfdefaults.h
$(CC) $(CFLAGS) /bin/plrtoascii util/plrtoascii.c LINK
/bin/shopconv: util/shopconv.c conf.h sysdep.h structs.h db.h utils.h shop.h
$(CC) $(CFLAGS) /bin/shopconv util/shopconv.c LINK
/bin/sign: util/sign.c conf.h sysdep.h
$(CC) $(CFLAGS) /bin/sign util/sign.c LINK
/bin/split: util/split.c
$(CC) $(CFLAGS) /bin/split util/split.c LINK
/bin/wld2html: util/wld2html.c
$(CC) $(CFLAGS) /bin/wld2html util/wld2html.c LINK
/bin/circle : $(OBJFILES)
$(CC) $(PROFILE) $(OBJFILES) TO /bin/circle LINK
# Dependencies for the object files (automagically generated with
# gcc -MM)
act.comm.o: act.comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h screen.h
$(CC) $(CFLAGS) act.comm.c
act.informative.o: act.informative.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h screen.h
$(CC) $(CFLAGS) act.informative.c
act.item.o: act.item.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) $(CFLAGS) act.item.c
act.movement.o: act.movement.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h
$(CC) $(CFLAGS) act.movement.c
act.offensive.o: act.offensive.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) $(CFLAGS) act.offensive.c
act.other.o: act.other.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h screen.h house.h
$(CC) $(CFLAGS) act.other.c
act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) $(CFLAGS) act.social.c
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h
$(CC) $(CFLAGS) act.wizard.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \
interpreter.h handler.h
$(CC) $(CFLAGS) boards.c
castle.o: castle.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h \
handler.h db.h spells.h
$(CC) $(CFLAGS) castle.c
class.o: class.c conf.h sysdep.h structs.h db.h utils.h spells.h interpreter.h
$(CC) $(CFLAGS) class.c
comm.o: comm.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h house.h
$(CC) $(CFLAGS) comm.c
config.o: config.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) constants.c
db.o: db.c conf.h sysdep.h structs.h utils.h db.h comm.h handler.h spells.h mail.h \
interpreter.h house.h
$(CC) $(CFLAGS) db.c
fight.o: fight.c conf.h sysdep.h structs.h utils.h comm.h handler.h interpreter.h \
db.h spells.h screen.h
$(CC) $(CFLAGS) fight.c
graph.o: graph.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h \
db.h spells.h
$(CC) $(CFLAGS) graph.c
handler.o: handler.c conf.h sysdep.h structs.h utils.h comm.h db.h handler.h \
interpreter.h spells.h
$(CC) $(CFLAGS) handler.c
house.o: house.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h house.h
$(CC) $(CFLAGS) house.c
interpreter.o: interpreter.c conf.h sysdep.h structs.h comm.h interpreter.h db.h \
utils.h spells.h handler.h mail.h screen.h
$(CC) $(CFLAGS) interpreter.c
limits.o: limits.c conf.h sysdep.h structs.h utils.h spells.h comm.h db.h \
handler.h
$(CC) $(CFLAGS) limits.c
magic.o: magic.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h db.h
$(CC) $(CFLAGS) magic.c
mail.o: mail.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h \
handler.h mail.h
$(CC) $(CFLAGS) mail.c
mobact.o: mobact.c conf.h sysdep.h structs.h utils.h db.h comm.h interpreter.h \
handler.h spells.h
$(CC) $(CFLAGS) mobact.c
modify.o: modify.c conf.h sysdep.h structs.h utils.h interpreter.h handler.h db.h \
comm.h spells.h mail.h boards.h
$(CC) $(CFLAGS) modify.c
objsave.o: objsave.c conf.h sysdep.h structs.h comm.h handler.h db.h \
interpreter.h utils.h spells.h
$(CC) $(CFLAGS) objsave.c
olc.o: olc.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h \
olc.h
$(CC) $(CFLAGS) olc.c
players.o: players.c conf.h sysdep.h structs.h utils.h db.h handler.h pfdefaults.h
$(CC) -c $(CFLAGS) players.c
random.o: random.c
$(CC) $(CFLAGS) random.c
shop.o: shop.c conf.h sysdep.h structs.h comm.h handler.h db.h interpreter.h \
utils.h shop.h
$(CC) $(CFLAGS) shop.c
spec_assign.o: spec_assign.c conf.h sysdep.h structs.h db.h interpreter.h \
utils.h
$(CC) $(CFLAGS) spec_assign.c
spec_procs.o: spec_procs.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h
$(CC) $(CFLAGS) spec_procs.c
spell_parser.o: spell_parser.c conf.h sysdep.h structs.h utils.h interpreter.h \
spells.h handler.h comm.h db.h
$(CC) $(CFLAGS) spell_parser.c
spells.o: spells.c conf.h sysdep.h structs.h utils.h comm.h spells.h handler.h \
db.h
$(CC) $(CFLAGS) spells.c
utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
handler.h
$(CC) $(CFLAGS) utils.c
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) $(CFLAGS) weather.c

683
src/act.comm.c Normal file
View file

@ -0,0 +1,683 @@
/* ************************************************************************
* File: act.comm.c Part of CircleMUD *
* Usage: Player-level communication commands *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "screen.h"
#include "improved-edit.h"
#include "dg_scripts.h"
/* local functions */
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg);
int is_tell_ok(struct char_data *ch, struct char_data *vict);
ACMD(do_say);
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);
ACMD(do_list_history);
void new_hist_messg(struct descriptor_data *d, const char *msg);
void free_hist_messg(struct descriptor_data *d);
static long last_webster_teller = -1L;
ACMD(do_say)
{
skip_spaces(&argument);
if (!*argument)
send_to_char(ch, "Yes, but WHAT do you want to say?\r\n");
else {
char buf[MAX_INPUT_LENGTH + 14];
snprintf(buf, sizeof(buf), "$n says, '%s@n'", argument);
act(buf, FALSE, ch, 0, 0, TO_ROOM | DG_NO_TRIG | LOG_MESSG);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
delete_doubledollar(argument);
send_to_char(ch, "You say, '%s@n'\r\n", argument);
}
}
/* trigger check */
speech_mtrigger(ch, argument);
speech_wtrigger(ch, argument);
}
ACMD(do_gsay)
{
struct char_data *k;
struct follow_type *f;
skip_spaces(&argument);
if (!AFF_FLAGGED(ch, AFF_GROUP)) {
send_to_char(ch, "But you are not the member of a group!\r\n");
return;
}
if (!*argument)
send_to_char(ch, "Yes, but WHAT do you want to group-say?\r\n");
else {
char buf[MAX_STRING_LENGTH];
if (ch->master)
k = ch->master;
else
k = ch;
snprintf(buf, sizeof(buf), "$n tells the group, '%s@n'", argument);
if (AFF_FLAGGED(k, AFF_GROUP) && (k != ch))
act(buf, FALSE, ch, 0, k, TO_VICT | TO_SLEEP | LOG_MESSG);
for (f = k->followers; f; f = f->next)
if (AFF_FLAGGED(f->follower, AFF_GROUP) && (f->follower != ch))
act(buf, FALSE, ch, 0, f->follower, TO_VICT | TO_SLEEP | LOG_MESSG);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "You tell the group, '%s@n'\r\n", argument);
}
}
void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
{
char buf[MAX_STRING_LENGTH];
send_to_char(vict, "%s", CCRED(vict, C_NRM));
snprintf(buf, sizeof(buf), "$n tells you, '%s'", arg);
act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP | LOG_MESSG);
send_to_char(vict, "%s", CCNRM(vict, C_NRM));
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
send_to_char(ch, "%s", CCRED(ch, C_CMP));
snprintf(buf, sizeof(buf), "You tell $N, '%s'", arg);
act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
send_to_char(ch, "%s", CCNRM(ch, C_CMP));
}
if (!IS_NPC(vict) && !IS_NPC(ch))
GET_LAST_TELL(vict) = GET_IDNUM(ch);
}
int is_tell_ok(struct char_data *ch, struct char_data *vict)
{
if (ch == vict)
send_to_char(ch, "You try to tell yourself something.\r\n");
else if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOTELL))
send_to_char(ch, "You can't tell other people while you have notell on.\r\n");
else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
send_to_char(ch, "The walls seem to absorb your words.\r\n");
else if (!IS_NPC(vict) && !vict->desc) /* linkless */
act("$E's linkless at the moment.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else if (PLR_FLAGGED(vict, PLR_WRITING))
act("$E's writing a message right now; try again later.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else if ((!IS_NPC(vict) && PRF_FLAGGED(vict, PRF_NOTELL)) || (ROOM_FLAGGED(IN_ROOM(vict), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)))
act("$E can't hear you.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else
return (TRUE);
return (FALSE);
}
/*
* Yes, do_tell probably could be combined with whisper and ask, but
* called frequently, and should IMHO be kept as tight as possible.
*/
ACMD(do_tell)
{
struct char_data *vict = NULL;
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
half_chop(argument, buf, buf2);
if (!*buf || !*buf2)
send_to_char(ch, "Who do you wish to tell what??\r\n");
else if (!strcmp(buf, "m-w")) {
char word[MAX_INPUT_LENGTH], *p, *q;
if (last_webster_teller != -1L) {
if (GET_IDNUM(ch) == last_webster_teller) {
send_to_char(ch, "You are still waiting for a response.\r\n");
return;
} else {
send_to_char(ch, "Hold on, m-w is busy. Try again in a couple of seconds.\r\n");
return;
}
}
/* only a-z and +/- allowed */
for (p = buf2, q = word; *p ; p++) {
if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-'))
*q++ = *p;
}
*q = '\0';
if (!*word) {
send_to_char(ch, "Sorry, only letters and +/- are allowed characters.\r\n");
return;
}
snprintf(buf, sizeof(buf), "../bin/webster %s %d &", word, (int) getpid());
system(buf);
last_webster_teller = GET_IDNUM(ch);
send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word);
} else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (is_tell_ok(ch, vict))
perform_tell(ch, vict, buf2);
}
ACMD(do_reply)
{
struct char_data *tch = character_list;
if (IS_NPC(ch))
return;
skip_spaces(&argument);
if (GET_LAST_TELL(ch) == NOBODY)
send_to_char(ch, "You have nobody to reply to!\r\n");
else if (!*argument)
send_to_char(ch, "What is your reply?\r\n");
else {
/*
* Make sure the person you're replying to is still playing by searching
* for them. Note, now last tell is stored as player IDnum instead of
* a pointer, which is much better because it's safer, plus will still
* work if someone logs out and back in again.
*/
/*
* XXX: A descriptor list based search would be faster although
* we could not find link dead people. Not that they can
* hear tells anyway. :) -gg 2/24/98
*/
while (tch != NULL && (IS_NPC(tch) || GET_IDNUM(tch) != GET_LAST_TELL(ch)))
tch = tch->next;
if (tch == NULL)
send_to_char(ch, "They are no longer playing.\r\n");
else if (is_tell_ok(ch, tch))
perform_tell(ch, tch, argument);
}
}
ACMD(do_spec_comm)
{
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
struct char_data *vict;
const char *action_sing, *action_plur, *action_others;
switch (subcmd) {
case SCMD_WHISPER:
action_sing = "whisper to";
action_plur = "whispers to";
action_others = "$n whispers something to $N.";
break;
case SCMD_ASK:
action_sing = "ask";
action_plur = "asks";
action_others = "$n asks $N a question.";
break;
default:
action_sing = "oops";
action_plur = "oopses";
action_others = "$n is tongue-tied trying to speak with $N.";
break;
}
half_chop(argument, buf, buf2);
if (!*buf || !*buf2)
send_to_char(ch, "Whom do you want to %s.. and what??\r\n", action_sing);
else if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (vict == ch)
send_to_char(ch, "You can't get your mouth close enough to your ear...\r\n");
else {
char buf1[MAX_STRING_LENGTH];
snprintf(buf1, sizeof(buf1), "$n %s you, '%s'", action_plur, buf2);
act(buf1, FALSE, ch, 0, vict, TO_VICT | LOG_MESSG);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "You %s %s, '%s'\r\n", action_sing, GET_NAME(vict), buf2);
act(action_others, FALSE, ch, 0, vict, TO_NOTVICT);
}
}
/*
* buf1, buf2 = MAX_OBJECT_NAME_LENGTH
* (if it existed)
*/
ACMD(do_write)
{
struct obj_data *paper, *pen = NULL;
char *papername, *penname;
char buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
papername = buf1;
penname = buf2;
two_arguments(argument, papername, penname);
if (!ch->desc)
return;
if (!*papername) { /* nothing was delivered */
send_to_char(ch, "Write? With what? ON what? What are you trying to do?!?\r\n");
return;
}
if (*penname) { /* there were two arguments */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "You have no %s.\r\n", papername);
return;
}
if (!(pen = get_obj_in_list_vis(ch, penname, NULL, ch->carrying))) {
send_to_char(ch, "You have no %s.\r\n", penname);
return;
}
} else { /* there was one arg.. let's see what we can find */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "There is no %s in your inventory.\r\n", papername);
return;
}
if (GET_OBJ_TYPE(paper) == ITEM_PEN) { /* oops, a pen.. */
pen = paper;
paper = NULL;
} else if (GET_OBJ_TYPE(paper) != ITEM_NOTE) {
send_to_char(ch, "That thing has nothing to do with writing.\r\n");
return;
}
/* One object was found.. now for the other one. */
if (!GET_EQ(ch, WEAR_HOLD)) {
send_to_char(ch, "You can't write with %s %s alone.\r\n", AN(papername), papername);
return;
}
if (!CAN_SEE_OBJ(ch, GET_EQ(ch, WEAR_HOLD))) {
send_to_char(ch, "The stuff in your hand is invisible! Yeech!!\r\n");
return;
}
if (pen)
paper = GET_EQ(ch, WEAR_HOLD);
else
pen = GET_EQ(ch, WEAR_HOLD);
}
/* ok.. now let's see what kind of stuff we've found */
if (GET_OBJ_TYPE(pen) != ITEM_PEN)
act("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR);
else if (GET_OBJ_TYPE(paper) != ITEM_NOTE)
act("You can't write on $p.", FALSE, ch, paper, 0, TO_CHAR);
else {
char *backstr = NULL;
/* Something on it, display it as that's in input buffer. */
if (paper->action_description) {
backstr = strdup(paper->action_description);
send_to_char(ch, "There's something written on it already:\r\n");
send_to_char(ch, "%s", paper->action_description);
}
/* we can write - hooray! */
act("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM);
send_editor_help(ch->desc);
string_write(ch->desc, &paper->action_description, MAX_NOTE_LENGTH, 0, backstr);
}
}
ACMD(do_page)
{
struct descriptor_data *d;
struct char_data *vict;
char buf2[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
half_chop(argument, arg, buf2);
if (IS_NPC(ch))
send_to_char(ch, "Monsters can't page.. go away.\r\n");
else if (!*arg)
send_to_char(ch, "Whom do you wish to page?\r\n");
else {
char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof(buf), "\007\007*$n* %s", buf2);
if (!str_cmp(arg, "all")) {
if (GET_LEVEL(ch) > LVL_GOD) {
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_PLAYING && d->character)
act(buf, FALSE, ch, 0, d->character, TO_VICT | LOG_MESSG);
} else
send_to_char(ch, "You will never be godly enough to do that!\r\n");
return;
}
if ((vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)) != NULL) {
act(buf, FALSE, ch, 0, vict, TO_VICT | LOG_MESSG);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
act(buf, FALSE, ch, 0, vict, TO_CHAR);
} else
send_to_char(ch, "There is no such person in the game!\r\n");
}
}
/**********************************************************************
* generalized communication func, originally by Fred C. Merkel (Torg) *
*********************************************************************/
ACMD(do_gen_comm)
{
struct descriptor_data *i;
char color_on[24];
char buf1[MAX_INPUT_LENGTH];
/* Array of flags which must _not_ be set in order for comm to be heard */
int channels[] = {
0,
PRF_NOSHOUT,
PRF_NOGOSS,
PRF_NOAUCT,
PRF_NOGRATZ,
PRF_NOGOSS,
0
};
/*
* com_msgs: [0] Message if you can't perform the action because of noshout
* [1] name of the action
* [2] message if you're not on the channel
* [3] a color string.
*/
const char *com_msgs[][4] = {
{"You cannot holler!!\r\n",
"holler",
"",
KYEL},
{"You cannot shout!!\r\n",
"shout",
"Turn off your noshout flag first!\r\n",
KYEL},
{"You cannot gossip!!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL},
{"You cannot auction!!\r\n",
"auction",
"You aren't even on the channel!\r\n",
KMAG},
{"You cannot congratulate!\r\n",
"congrat",
"You aren't even on the channel!\r\n",
KGRN},
{"You cannot gossip your emotions!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL}
};
/* to keep pets, etc from being ordered to shout */
if (!ch->desc)
return;
if (PLR_FLAGGED(ch, PLR_NOSHOUT)) {
send_to_char(ch, "%s", com_msgs[subcmd][0]);
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)) {
send_to_char(ch, "The walls seem to absorb your words.\r\n");
return;
}
if (subcmd == SCMD_GOSSIP && *argument == '*') {
subcmd = SCMD_GEMOTE;
}
if (subcmd == SCMD_GEMOTE) {
ACMD(do_gmote);
if (*argument == '*')
do_gmote(ch, argument + 1, 0, 1);
else
do_gmote(ch, argument, 0, 1);
return;
}
/* level_can_shout defined in config.c */
if (GET_LEVEL(ch) < CONFIG_LEVEL_CAN_SHOUT) {
send_to_char(ch, "You must be at least level %d before you can %s.\r\n", CONFIG_LEVEL_CAN_SHOUT, com_msgs[subcmd][1]);
return;
}
/* make sure the char is on the channel */
if (PRF_FLAGGED(ch, channels[subcmd])) {
send_to_char(ch, "%s", com_msgs[subcmd][2]);
return;
}
/* skip leading spaces */
skip_spaces(&argument);
/* make sure that there is something there to say! */
if (!*argument) {
send_to_char(ch, "Yes, %s, fine, %s we must, but WHAT???\r\n", com_msgs[subcmd][1], com_msgs[subcmd][1]);
return;
}
if (subcmd == SCMD_HOLLER) {
if (GET_MOVE(ch) < CONFIG_HOLLER_MOVE_COST) {
send_to_char(ch, "You're too exhausted to holler.\r\n");
return;
} else
GET_MOVE(ch) -= CONFIG_HOLLER_MOVE_COST;
}
/* set up the color on code */
strlcpy(color_on, com_msgs[subcmd][3], sizeof(color_on));
/* first, set up strings to be given to the communicator */
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "%sYou %s, '%s'%s\r\n", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, CCNRM(ch, C_CMP));
snprintf(buf1, sizeof(buf1), "$n %ss, '%s'", com_msgs[subcmd][1], argument);
/* now send all the strings out */
for (i = descriptor_list; i; i = i->next) {
if (STATE(i) != CON_PLAYING || i == ch->desc || !i->character )
continue;
if(PRF_FLAGGED(i->character, channels[subcmd]) || PLR_FLAGGED(i->character, PLR_WRITING))
continue;
if(ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
continue;
if (subcmd == SCMD_SHOUT &&
((world[IN_ROOM(ch)].zone != world[IN_ROOM(i->character)].zone) ||
!AWAKE(i->character)))
continue;
if (COLOR_LEV(i->character) >= C_NRM)
send_to_char(i->character, "%s", color_on);
act(buf1, FALSE, ch, 0, i->character, TO_VICT | TO_SLEEP | LOG_MESSG);
if (COLOR_LEV(i->character) >= C_NRM)
send_to_char(i->character, "%s", KNRM);
}
}
ACMD(do_qcomm)
{
if (!PRF_FLAGGED(ch, PRF_QUEST)) {
send_to_char(ch, "You aren't even part of the quest!\r\n");
return;
}
skip_spaces(&argument);
if (!*argument)
send_to_char(ch, "%c%s? Yes, fine, %s we must, but WHAT??\r\n", UPPER(*CMD_NAME), CMD_NAME + 1, CMD_NAME);
else {
char buf[MAX_STRING_LENGTH];
struct descriptor_data *i;
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else if (subcmd == SCMD_QSAY) {
snprintf(buf, sizeof(buf), "You quest-say, '%s'", argument);
act(buf, FALSE, ch, 0, argument, TO_CHAR);
} else
act(argument, FALSE, ch, 0, argument, TO_CHAR);
if (subcmd == SCMD_QSAY)
snprintf(buf, sizeof(buf), "$n quest-says, '%s'", argument);
else {
strlcpy(buf, argument, sizeof(buf));
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE, "(GC) %s qechoed: %s", GET_NAME(ch), argument);
}
for (i = descriptor_list; i; i = i->next)
if (STATE(i) == CON_PLAYING && i != ch->desc && PRF_FLAGGED(i->character, PRF_QUEST))
act(buf, 0, ch, 0, i->character, TO_VICT | TO_SLEEP | LOG_MESSG);
}
}
#define HIST_LENGTH 100
void free_hist_messg(struct descriptor_data *d)
{
struct txt_block *tmp = d->comms, *ftmp;
while (tmp) {
ftmp = tmp;
tmp = tmp->next;
if (ftmp->text)
free(ftmp->text);
free(ftmp);
}
d->comms = NULL;
}
void new_hist_messg(struct descriptor_data *d, const char *msg)
{
struct txt_block *tmp = d->comms;
int l = 0;
if (!tmp) {
CREATE(d->comms, struct txt_block, 1);
d->comms->text = strdup(msg);
return;
}
while (tmp->next)
tmp = tmp->next;
CREATE(tmp->next, struct txt_block, 1);
tmp->next->text = strdup(msg);
for (tmp = d->comms; tmp ; tmp= tmp->next)
l++;
for (; l > HIST_LENGTH && d->comms; l--) {
tmp = d->comms;
d->comms = tmp->next;
if (tmp->text)
free(tmp->text);
free(tmp);
}
}
ACMD(do_list_history)
{
struct txt_block *tmp;
struct descriptor_data *d = ch->desc;
if (!d)
return;
if (!d->comms) {
write_to_output(d, "No communications in history.\r\n");
return;
}
write_to_output(d, "Last %d communications:\r\n", HIST_LENGTH);
for (tmp = d->comms;tmp;tmp = tmp->next)
write_to_output(d, "%s%s%s", QWHT, tmp->text, QNRM);
free_hist_messg(d);
}
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);
}

1892
src/act.informative.c Normal file

File diff suppressed because it is too large Load diff

1507
src/act.item.c Normal file

File diff suppressed because it is too large Load diff

763
src/act.movement.c Normal file
View file

@ -0,0 +1,763 @@
/* ************************************************************************
* File: act.movement.c Part of CircleMUD *
* Usage: movement commands, door handling, & sleep/rest/etc state *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
#include "house.h"
#include "constants.h"
#include "dg_scripts.h"
/* 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 */
int has_boat(struct char_data *ch);
int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname);
int has_key(struct char_data *ch, obj_vnum key);
void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd);
int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd);
ACMD(do_gen_door);
ACMD(do_enter);
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 */
int has_boat(struct char_data *ch)
{
struct obj_data *obj;
int i;
/*
if (ROOM_IDENTITY(IN_ROOM(ch)) == DEAD_SEA)
return (1);
*/
if (GET_LEVEL(ch) > LVL_IMMORT)
return (1);
if (AFF_FLAGGED(ch, AFF_WATERWALK))
return (1);
/* non-wearable boats in inventory will do it */
for (obj = ch->carrying; obj; obj = obj->next_content)
if (GET_OBJ_TYPE(obj) == ITEM_BOAT && (find_eq_pos(ch, obj, NULL) < 0))
return (1);
/* and any boat you're wearing will do it too */
for (i = 0; i < NUM_WEARS; i++)
if (GET_EQ(ch, i) && GET_OBJ_TYPE(GET_EQ(ch, i)) == ITEM_BOAT)
return (1);
return (0);
}
/* do_simple_move assumes
* 1. That there is no master and no followers.
* 2. That the direction exists.
*
* Returns :
* 1 : If succes.
* 0 : If fail
*/
int do_simple_move(struct char_data *ch, int dir, int need_specials_check)
{
char throwaway[MAX_INPUT_LENGTH] = ""; /* Functions assume writable. */
room_rnum was_in = IN_ROOM(ch);
int need_movement;
/*
* Check for special routines (North is 1 in command list, but 0 here) Note
* -- 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 */
return 0;
if (!leave_wtrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
return 0;
if (!leave_otrigger(&world[IN_ROOM(ch)], ch, dir) || IN_ROOM(ch) != was_in) /* prevent teleport crashes */
return 0;
/* charmed? */
if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && IN_ROOM(ch) == IN_ROOM(ch->master)) {
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);
return (0);
}
/* if this room or the one we're going to needs a boat, check for one */
if ((SECT(IN_ROOM(ch)) == SECT_WATER_NOSWIM) ||
(SECT(EXIT(ch, dir)->to_room) == SECT_WATER_NOSWIM)) {
if (!has_boat(ch)) {
send_to_char(ch, "You need a boat to go there.\r\n");
return (0);
}
}
/* move points needed is avg. move loss for src and destination sect type */
need_movement = (movement_loss[SECT(IN_ROOM(ch))] +
movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2;
if (GET_MOVE(ch) < need_movement && !IS_NPC(ch)) {
if (need_specials_check && ch->master)
send_to_char(ch, "You are too exhausted to follow.\r\n");
else
send_to_char(ch, "You are too exhausted.\r\n");
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. */
if (GET_LEVEL(ch) < LVL_IMMORT && !IS_NPC(ch))
GET_MOVE(ch) -= need_movement;
if (!AFF_FLAGGED(ch, AFF_SNEAK)) {
char buf2[MAX_STRING_LENGTH];
snprintf(buf2, sizeof(buf2), "$n leaves %s.", dirs[dir]);
act(buf2, TRUE, ch, 0, 0, TO_ROOM);
}
was_in = IN_ROOM(ch);
char_from_room(ch);
char_to_room(ch, world[was_in].dir_option[dir]->to_room);
/* move them first, then move them back if they aren't allowed to go. */
/* see if an entry trigger disallows the move */
if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir)) {
char_from_room(ch);
char_to_room(ch, was_in);
return 0;
}
if (!AFF_FLAGGED(ch, AFF_SNEAK))
act("$n has arrived.", TRUE, ch, 0, 0, TO_ROOM);
if (ch->desc != NULL)
look_at_room(ch, 0);
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) {
log_death_trap(ch);
death_cry(ch);
extract_char(ch);
return (0);
}
entry_memory_mtrigger(ch);
if (!greet_mtrigger(ch, dir)) {
char_from_room(ch);
char_to_room(ch, was_in);
look_at_room(ch, 0);
} else greet_memory_mtrigger(ch);
return (1);
}
int perform_move(struct char_data *ch, int dir, int need_specials_check)
{
room_rnum was_in;
struct follow_type *k, *next;
if (ch == NULL || dir < 0 || dir >= NUM_OF_DIRS || FIGHTING(ch))
return (0);
else if ((!EXIT(ch, dir) && !buildwalk(ch, dir)) || EXIT(ch, dir)->to_room == NOWHERE)
send_to_char(ch, "Alas, you cannot go that way...\r\n");
else if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED)) {
if (EXIT(ch, dir)->keyword)
send_to_char(ch, "The %s seems to be closed.\r\n", fname(EXIT(ch, dir)->keyword));
else
send_to_char(ch, "It seems to be closed.\r\n");
} else {
if (!ch->followers)
return (do_simple_move(ch, dir, need_specials_check));
was_in = IN_ROOM(ch);
if (!do_simple_move(ch, dir, need_specials_check))
return (0);
for (k = ch->followers; k; k = next) {
next = k->next;
if ((IN_ROOM(k->follower) == was_in) &&
(GET_POS(k->follower) >= POS_STANDING)) {
act("You follow $N.\r\n", FALSE, k->follower, 0, ch, TO_CHAR);
perform_move(k->follower, dir, 1);
}
}
return (1);
}
return (0);
}
ACMD(do_move)
{
/*
* This is basically a mapping of cmd numbers to perform_move indices.
* It cannot be done in perform_move because perform_move is called
* by other 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)
{
int door;
if (*dir) { /* a direction was specified */
if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
send_to_char(ch, "That's not a direction.\r\n");
return (-1);
}
if (EXIT(ch, door)) { /* Braces added according to indent. -gg */
if (EXIT(ch, door)->keyword) {
if (is_name(type, EXIT(ch, door)->keyword))
return (door);
else {
send_to_char(ch, "I see no %s there.\r\n", type);
return (-1);
}
} else
return (door);
} else {
send_to_char(ch, "I really don't see how you can %s anything there.\r\n", cmdname);
return (-1);
}
} else { /* try to locate the keyword */
if (!*type) {
send_to_char(ch, "What is it you want to %s?\r\n", cmdname);
return (-1);
}
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->keyword)
if (is_name(type, EXIT(ch, door)->keyword))
return (door);
send_to_char(ch, "There doesn't seem to be %s %s here.\r\n", AN(type), type);
return (-1);
}
}
int has_key(struct char_data *ch, obj_vnum key)
{
struct obj_data *o;
for (o = ch->carrying; o; o = o->next_content)
if (GET_OBJ_VNUM(o) == key)
return (1);
if (GET_EQ(ch, WEAR_HOLD))
if (GET_OBJ_VNUM(GET_EQ(ch, WEAR_HOLD)) == key)
return (1);
return (0);
}
#define NEED_OPEN (1 << 0)
#define NEED_CLOSED (1 << 1)
#define NEED_UNLOCKED (1 << 2)
#define NEED_LOCKED (1 << 3)
const char *cmd_door[] =
{
"open",
"close",
"unlock",
"lock",
"pick"
};
const int flags_door[] =
{
NEED_CLOSED | NEED_UNLOCKED,
NEED_OPEN,
NEED_CLOSED | NEED_LOCKED,
NEED_CLOSED | NEED_UNLOCKED,
NEED_CLOSED | NEED_LOCKED
};
#define EXITN(room, door) (world[room].dir_option[door])
#define OPEN_DOOR(room, obj, door) ((obj) ?\
(REMOVE_BIT(GET_OBJ_VAL(obj, 1), CONT_CLOSED)) :\
(REMOVE_BIT(EXITN(room, door)->exit_info, EX_CLOSED)))
#define CLOSE_DOOR(room, obj, door) ((obj) ?\
(SET_BIT(GET_OBJ_VAL(obj, 1), CONT_CLOSED)) :\
(SET_BIT(EXITN(room, door)->exit_info, EX_CLOSED)))
#define LOCK_DOOR(room, obj, door) ((obj) ?\
(SET_BIT(GET_OBJ_VAL(obj, 1), CONT_LOCKED)) :\
(SET_BIT(EXITN(room, door)->exit_info, EX_LOCKED)))
#define UNLOCK_DOOR(room, obj, door) ((obj) ?\
(REMOVE_BIT(GET_OBJ_VAL(obj, 1), CONT_LOCKED)) :\
(REMOVE_BIT(EXITN(room, door)->exit_info, EX_LOCKED)))
#define TOGGLE_LOCK(room, obj, door) ((obj) ?\
(TOGGLE_BIT(GET_OBJ_VAL(obj, 1), CONT_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)
{
char buf[MAX_STRING_LENGTH];
size_t len;
room_rnum other_room = NOWHERE;
struct room_direction_data *back = NULL;
if (!door_mtrigger(ch, scmd, door))
return;
if (!door_wtrigger(ch, scmd, door))
return;
len = snprintf(buf, sizeof(buf), "$n %ss ", cmd_door[scmd]);
if (!obj && ((other_room = EXIT(ch, door)->to_room) != NOWHERE))
if ((back = world[other_room].dir_option[rev_dir[door]]) != NULL)
if (back->to_room != IN_ROOM(ch))
back = NULL;
switch (scmd) {
case SCMD_OPEN:
OPEN_DOOR(IN_ROOM(ch), obj, door);
if (back)
OPEN_DOOR(other_room, obj, rev_dir[door]);
send_to_char(ch, "%s", CONFIG_OK);
break;
case SCMD_CLOSE:
CLOSE_DOOR(IN_ROOM(ch), obj, door);
if (back)
CLOSE_DOOR(other_room, obj, rev_dir[door]);
send_to_char(ch, "%s", CONFIG_OK);
break;
case SCMD_LOCK:
LOCK_DOOR(IN_ROOM(ch), obj, door);
if (back)
LOCK_DOOR(other_room, obj, rev_dir[door]);
send_to_char(ch, "*Click*\r\n");
break;
case SCMD_UNLOCK:
UNLOCK_DOOR(IN_ROOM(ch), obj, door);
if (back)
UNLOCK_DOOR(other_room, obj, rev_dir[door]);
send_to_char(ch, "*Click*\r\n");
break;
case SCMD_PICK:
TOGGLE_LOCK(IN_ROOM(ch), obj, door);
if (back)
TOGGLE_LOCK(other_room, obj, rev_dir[door]);
send_to_char(ch, "The lock quickly yields to your skills.\r\n");
len = strlcpy(buf, "$n skillfully picks the lock on ", sizeof(buf));
break;
}
/* Notify the room. */
if (len < sizeof(buf))
snprintf(buf + len, sizeof(buf) - len, "%s%s.",
obj ? "" : "the ", obj ? "$p" : EXIT(ch, door)->keyword ? "$F" : "door");
if (!obj || IN_ROOM(obj) != NOWHERE)
act(buf, FALSE, ch, obj, obj ? 0 : EXIT(ch, door)->keyword, TO_ROOM);
/* Notify the other room */
if (back && (scmd == SCMD_OPEN || scmd == SCMD_CLOSE))
send_to_room(EXIT(ch, door)->to_room, "The %s is %s%s from the other side.\r\n",
back->keyword ? fname(back->keyword) : "door", cmd_door[scmd],
scmd == SCMD_CLOSE ? "d" : "ed");
}
int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd)
{
int percent, skill_lvl;
if (scmd != SCMD_PICK)
return (1);
percent = rand_number(1, 101);
skill_lvl = GET_SKILL(ch, SKILL_PICK_LOCK) + dex_app_skill[GET_DEX(ch)].p_locks;
if (keynum == NOTHING)
send_to_char(ch, "Odd - you can't seem to find a keyhole.\r\n");
else if (pickproof)
send_to_char(ch, "It resists your attempts to pick it.\r\n");
else if (percent > skill_lvl)
send_to_char(ch, "You failed to pick the lock.\r\n");
else
return (1);
return (0);
}
#define DOOR_IS_OPENABLE(ch, obj, door) ((obj) ? \
((GET_OBJ_TYPE(obj) == ITEM_CONTAINER) && \
OBJVAL_FLAGGED(obj, CONT_CLOSEABLE)) :\
(EXIT_FLAGGED(EXIT(ch, door), EX_ISDOOR)))
#define DOOR_IS_OPEN(ch, obj, door) ((obj) ? \
(!OBJVAL_FLAGGED(obj, CONT_CLOSED)) :\
(!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)))
#define DOOR_IS_UNLOCKED(ch, obj, door) ((obj) ? \
(!OBJVAL_FLAGGED(obj, CONT_LOCKED)) :\
(!EXIT_FLAGGED(EXIT(ch, door), EX_LOCKED)))
#define DOOR_IS_PICKPROOF(ch, obj, door) ((obj) ? \
(OBJVAL_FLAGGED(obj, CONT_PICKPROOF)) : \
(EXIT_FLAGGED(EXIT(ch, door), EX_PICKPROOF)))
#define DOOR_IS_CLOSED(ch, obj, door) (!(DOOR_IS_OPEN(ch, obj, door)))
#define DOOR_IS_LOCKED(ch, obj, door) (!(DOOR_IS_UNLOCKED(ch, obj, door)))
#define DOOR_KEY(ch, obj, door) ((obj) ? (GET_OBJ_VAL(obj, 2)) : \
(EXIT(ch, door)->key))
ACMD(do_gen_door)
{
int door = -1;
obj_vnum keynum;
char type[MAX_INPUT_LENGTH], dir[MAX_INPUT_LENGTH];
struct obj_data *obj = NULL;
struct char_data *victim = NULL;
skip_spaces(&argument);
if (!*argument) {
send_to_char(ch, "%c%s what?\r\n", UPPER(*cmd_door[subcmd]), cmd_door[subcmd] + 1);
return;
}
two_arguments(argument, type, dir);
if (!generic_find(type, FIND_OBJ_INV | FIND_OBJ_ROOM, ch, &victim, &obj))
door = find_door(ch, type, dir, cmd_door[subcmd]);
if ((obj) || (door >= 0)) {
keynum = DOOR_KEY(ch, obj, door);
if (!(DOOR_IS_OPENABLE(ch, obj, door)))
act("You can't $F that!", FALSE, ch, 0, cmd_door[subcmd], TO_CHAR);
else if (!DOOR_IS_OPEN(ch, obj, door) &&
IS_SET(flags_door[subcmd], NEED_OPEN))
send_to_char(ch, "But it's already closed!\r\n");
else if (!DOOR_IS_CLOSED(ch, obj, door) &&
IS_SET(flags_door[subcmd], NEED_CLOSED))
send_to_char(ch, "But it's currently open!\r\n");
else if (!(DOOR_IS_LOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_LOCKED))
send_to_char(ch, "Oh.. it wasn't locked, after all..\r\n");
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_UNLOCKED))
send_to_char(ch, "It seems to be locked.\r\n");
else if (!has_key(ch, keynum) && (GET_LEVEL(ch) < LVL_GOD) &&
((subcmd == SCMD_LOCK) || (subcmd == SCMD_UNLOCK)))
send_to_char(ch, "You don't seem to have the proper key.\r\n");
else if (ok_pick(ch, keynum, DOOR_IS_PICKPROOF(ch, obj, door), subcmd))
do_doorcmd(ch, obj, door, subcmd);
}
return;
}
ACMD(do_enter)
{
char buf[MAX_INPUT_LENGTH];
int door;
one_argument(argument, buf);
if (*buf) { /* an argument was supplied, search for door
* keyword */
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->keyword)
if (!str_cmp(EXIT(ch, door)->keyword, buf)) {
perform_move(ch, door, 1);
return;
}
send_to_char(ch, "There is no %s here.\r\n", buf);
} else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS))
send_to_char(ch, "You are already indoors.\r\n");
else {
/* try to locate an entrance */
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->to_room != NOWHERE)
if (!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) &&
ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_INDOORS)) {
perform_move(ch, door, 1);
return;
}
send_to_char(ch, "You can't seem to find anything to enter.\r\n");
}
}
ACMD(do_leave)
{
int door;
if (OUTSIDE(ch))
send_to_char(ch, "You are outside.. where do you want to go?\r\n");
else {
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->to_room != NOWHERE)
if (!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) &&
!ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_INDOORS)) {
perform_move(ch, door, 1);
return;
}
send_to_char(ch, "I see no obvious exits to the outside.\r\n");
}
}
ACMD(do_stand)
{
switch (GET_POS(ch)) {
case POS_STANDING:
send_to_char(ch, "You are already standing.\r\n");
break;
case POS_SITTING:
send_to_char(ch, "You stand up.\r\n");
act("$n clambers to $s feet.", TRUE, ch, 0, 0, TO_ROOM);
/* Will be sitting after a successful bash and may still be fighting. */
GET_POS(ch) = FIGHTING(ch) ? POS_FIGHTING : POS_STANDING;
break;
case POS_RESTING:
send_to_char(ch, "You stop resting, and stand up.\r\n");
act("$n stops resting, and clambers on $s feet.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_STANDING;
break;
case POS_SLEEPING:
send_to_char(ch, "You have to wake up first!\r\n");
break;
case POS_FIGHTING:
send_to_char(ch, "Do you not consider fighting as standing?\r\n");
break;
default:
send_to_char(ch, "You stop floating around, and put your feet on the ground.\r\n");
act("$n stops floating around, and puts $s feet on the ground.",
TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_STANDING;
break;
}
}
ACMD(do_sit)
{
switch (GET_POS(ch)) {
case POS_STANDING:
send_to_char(ch, "You sit down.\r\n");
act("$n sits down.", FALSE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SITTING;
break;
case POS_SITTING:
send_to_char(ch, "You're sitting already.\r\n");
break;
case POS_RESTING:
send_to_char(ch, "You stop resting, and sit up.\r\n");
act("$n stops resting.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SITTING;
break;
case POS_SLEEPING:
send_to_char(ch, "You have to wake up first.\r\n");
break;
case POS_FIGHTING:
send_to_char(ch, "Sit down while fighting? Are you MAD?\r\n");
break;
default:
send_to_char(ch, "You stop floating around, and sit down.\r\n");
act("$n stops floating around, and sits down.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SITTING;
break;
}
}
ACMD(do_rest)
{
switch (GET_POS(ch)) {
case POS_STANDING:
send_to_char(ch, "You sit down and rest your tired bones.\r\n");
act("$n sits down and rests.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_RESTING;
break;
case POS_SITTING:
send_to_char(ch, "You rest your tired bones.\r\n");
act("$n rests.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_RESTING;
break;
case POS_RESTING:
send_to_char(ch, "You are already resting.\r\n");
break;
case POS_SLEEPING:
send_to_char(ch, "You have to wake up first.\r\n");
break;
case POS_FIGHTING:
send_to_char(ch, "Rest while fighting? Are you MAD?\r\n");
break;
default:
send_to_char(ch, "You stop floating around, and stop to rest your tired bones.\r\n");
act("$n stops floating around, and rests.", FALSE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SITTING;
break;
}
}
ACMD(do_sleep)
{
switch (GET_POS(ch)) {
case POS_STANDING:
case POS_SITTING:
case POS_RESTING:
send_to_char(ch, "You go to sleep.\r\n");
act("$n lies down and falls asleep.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SLEEPING;
break;
case POS_SLEEPING:
send_to_char(ch, "You are already sound asleep.\r\n");
break;
case POS_FIGHTING:
send_to_char(ch, "Sleep while fighting? Are you MAD?\r\n");
break;
default:
send_to_char(ch, "You stop floating around, and lie down to sleep.\r\n");
act("$n stops floating around, and lie down to sleep.",
TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SLEEPING;
break;
}
}
ACMD(do_wake)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
int self = 0;
one_argument(argument, arg);
if (*arg) {
if (GET_POS(ch) == POS_SLEEPING)
send_to_char(ch, "Maybe you should wake yourself up first.\r\n");
else if ((vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)) == NULL)
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (vict == ch)
self = 1;
else if (AWAKE(vict))
act("$E is already awake.", FALSE, ch, 0, vict, TO_CHAR);
else if (AFF_FLAGGED(vict, AFF_SLEEP))
act("You can't wake $M up!", FALSE, ch, 0, vict, TO_CHAR);
else if (GET_POS(vict) < POS_SLEEPING)
act("$E's in pretty bad shape!", FALSE, ch, 0, vict, TO_CHAR);
else {
act("You wake $M up.", FALSE, ch, 0, vict, TO_CHAR);
act("You are awakened by $n.", FALSE, ch, 0, vict, TO_VICT | TO_SLEEP);
GET_POS(vict) = POS_SITTING;
}
if (!self)
return;
}
if (AFF_FLAGGED(ch, AFF_SLEEP))
send_to_char(ch, "You can't wake up!\r\n");
else if (GET_POS(ch) > POS_SLEEPING)
send_to_char(ch, "You are already awake...\r\n");
else {
send_to_char(ch, "You awaken, and sit up.\r\n");
act("$n awakens.", TRUE, ch, 0, 0, TO_ROOM);
GET_POS(ch) = POS_SITTING;
}
}
ACMD(do_follow)
{
char buf[MAX_INPUT_LENGTH];
struct char_data *leader;
one_argument(argument, buf);
if (*buf) {
if (!(leader = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "%s", CONFIG_NOPERSON);
return;
}
} else {
send_to_char(ch, "Whom do you wish to follow?\r\n");
return;
}
if (ch->master == leader) {
act("You are already following $M.", FALSE, ch, 0, leader, TO_CHAR);
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master)) {
act("But you only feel like following $N!", FALSE, ch, 0, ch->master, TO_CHAR);
} else { /* Not Charmed follow person */
if (leader == ch) {
if (!ch->master) {
send_to_char(ch, "You are already following yourself.\r\n");
return;
}
stop_follower(ch);
} else {
if (circle_follow(ch, leader)) {
send_to_char(ch, "Sorry, but following in loops is not allowed.\r\n");
return;
}
if (ch->master)
stop_follower(ch);
REMOVE_BIT(AFF_FLAGS(ch), AFF_GROUP);
add_follower(ch, leader);
}
}
}

449
src/act.offensive.c Normal file
View file

@ -0,0 +1,449 @@
/* ************************************************************************
* File: act.offensive.c Part of CircleMUD *
* Usage: player-level commands of an offensive nature *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
/* extern functions */
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)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *helpee, *opponent;
if (FIGHTING(ch)) {
send_to_char(ch, "You're already fighting! How can you assist someone else?\r\n");
return;
}
one_argument(argument, arg);
if (!*arg)
send_to_char(ch, "Whom do you wish to assist?\r\n");
else if (!(helpee = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (helpee == ch)
send_to_char(ch, "You can't help yourself any more than this!\r\n");
else {
/*
* Hit the same enemy the person you're helping is.
*/
if (FIGHTING(helpee))
opponent = FIGHTING(helpee);
else
for (opponent = world[IN_ROOM(ch)].people;
opponent && (FIGHTING(opponent) != helpee);
opponent = opponent->next_in_room)
;
if (!opponent)
act("But nobody is fighting $M!", FALSE, ch, 0, helpee, TO_CHAR);
else if (!CAN_SEE(ch, opponent))
act("You can't see who is fighting $M!", FALSE, ch, 0, helpee, TO_CHAR);
/* prevent accidental pkill */
else if (!CONFIG_PK_ALLOWED && !IS_NPC(opponent))
act("Use 'murder' if you really want to attack $N.", FALSE,
ch, 0, opponent, TO_CHAR);
else {
send_to_char(ch, "You join the fight!\r\n");
act("$N assists you!", 0, helpee, 0, ch, TO_CHAR);
act("$n assists $N.", FALSE, ch, 0, helpee, TO_NOTVICT);
hit(ch, opponent, TYPE_UNDEFINED);
}
}
}
ACMD(do_hit)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
one_argument(argument, arg);
if (!*arg)
send_to_char(ch, "Hit who?\r\n");
else if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "They don't seem to be here.\r\n");
else if (vict == ch) {
send_to_char(ch, "You hit yourself...OUCH!.\r\n");
act("$n hits $mself, and says OUCH!", FALSE, ch, 0, vict, TO_ROOM);
} else if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == vict))
act("$N is just such a good friend, you simply can't hit $M.", FALSE, ch, 0, vict, TO_CHAR);
else {
if (!CONFIG_PK_ALLOWED) {
if (!IS_NPC(vict) && !IS_NPC(ch)) {
if (subcmd != SCMD_MURDER) {
send_to_char(ch, "Use 'murder' to hit another player.\r\n");
return;
} else {
check_killer(ch, vict);
}
}
if (AFF_FLAGGED(ch, AFF_CHARM) && !IS_NPC(ch->master) && !IS_NPC(vict))
return; /* you can't order a charmed pet to attack a
* player */
}
if ((GET_POS(ch) == POS_STANDING) && (vict != FIGHTING(ch))) {
hit(ch, vict, TYPE_UNDEFINED);
WAIT_STATE(ch, PULSE_VIOLENCE + 2);
} else
send_to_char(ch, "You do the best you can!\r\n");
}
}
ACMD(do_kill)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
if (GET_LEVEL(ch) <= LVL_IMPL || IS_NPC(ch)) {
do_hit(ch, argument, cmd, subcmd);
return;
}
one_argument(argument, arg);
if (!*arg) {
send_to_char(ch, "Kill who?\r\n");
} else {
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "They aren't here.\r\n");
else if (ch == vict)
send_to_char(ch, "Your mother would be so sad.. :(\r\n");
else {
act("You chop $M to pieces! Ah! The blood!", FALSE, ch, 0, vict, TO_CHAR);
act("$N chops you to pieces!", FALSE, vict, 0, ch, TO_CHAR);
act("$n brutally slays $N!", FALSE, ch, 0, vict, TO_NOTVICT);
raw_kill(vict, ch);
}
}
}
ACMD(do_backstab)
{
char buf[MAX_INPUT_LENGTH];
struct char_data *vict;
int percent, prob;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_BACKSTAB)) {
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
one_argument(argument, buf);
if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Backstab who?\r\n");
return;
}
if (vict == ch) {
send_to_char(ch, "How can you sneak up on yourself?\r\n");
return;
}
if (!GET_EQ(ch, WEAR_WIELD)) {
send_to_char(ch, "You need to wield a weapon to make it a success.\r\n");
return;
}
if (GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD), 3) != TYPE_PIERCE - TYPE_HIT) {
send_to_char(ch, "Only piercing weapons can be used for backstabbing.\r\n");
return;
}
if (FIGHTING(vict)) {
send_to_char(ch, "You can't backstab a fighting person -- they're too alert!\r\n");
return;
}
if (MOB_FLAGGED(vict, MOB_AWARE) && AWAKE(vict)) {
act("You notice $N lunging at you!", FALSE, vict, 0, ch, TO_CHAR);
act("$e notices you lunging at $m!", FALSE, vict, 0, ch, TO_VICT);
act("$n notices $N lunging at $m!", FALSE, vict, 0, ch, TO_NOTVICT);
hit(vict, ch, TYPE_UNDEFINED);
return;
}
percent = rand_number(1, 101); /* 101% is a complete failure */
prob = GET_SKILL(ch, SKILL_BACKSTAB);
if (AWAKE(vict) && (percent > prob))
damage(ch, vict, 0, SKILL_BACKSTAB);
else
hit(ch, vict, SKILL_BACKSTAB);
WAIT_STATE(ch, 2 * PULSE_VIOLENCE);
}
ACMD(do_order)
{
char name[MAX_INPUT_LENGTH], message[MAX_INPUT_LENGTH];
bool found = FALSE;
struct char_data *vict;
struct follow_type *k;
half_chop(argument, name, message);
if (!*name || !*message)
send_to_char(ch, "Order who to do what?\r\n");
else if (!(vict = get_char_vis(ch, name, NULL, FIND_CHAR_ROOM)) && !is_abbrev(name, "followers"))
send_to_char(ch, "That person isn't here.\r\n");
else if (ch == vict)
send_to_char(ch, "You obviously suffer from skitzofrenia.\r\n");
else {
if (AFF_FLAGGED(ch, AFF_CHARM)) {
send_to_char(ch, "Your superior would not aprove of you giving orders.\r\n");
return;
}
if (vict) {
char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof(buf), "$N orders you to '%s'", message);
act(buf, FALSE, vict, 0, ch, TO_CHAR);
act("$n gives $N an order.", FALSE, ch, 0, vict, TO_ROOM);
if ((vict->master != ch) || !AFF_FLAGGED(vict, AFF_CHARM))
act("$n has an indifferent look.", FALSE, vict, 0, 0, TO_ROOM);
else {
send_to_char(ch, "%s", CONFIG_OK);
command_interpreter(vict, message);
}
} else { /* This is order "followers" */
char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof(buf), "$n issues the order '%s'.", message);
act(buf, FALSE, ch, 0, 0, TO_ROOM);
for (k = ch->followers; k; k = k->next) {
if (IN_ROOM(ch) == IN_ROOM(k->follower))
if (AFF_FLAGGED(k->follower, AFF_CHARM)) {
found = TRUE;
command_interpreter(k->follower, message);
}
}
if (found)
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "Nobody here is a loyal subject of yours!\r\n");
}
}
}
ACMD(do_flee)
{
int i, attempt, loss;
struct char_data *was_fighting;
if (GET_POS(ch) < POS_FIGHTING) {
send_to_char(ch, "You are in pretty bad shape, unable to flee!\r\n");
return;
}
for (i = 0; i < 6; i++) {
attempt = rand_number(0, NUM_OF_DIRS - 1); /* Select a random direction */
if (CAN_GO(ch, attempt) &&
!ROOM_FLAGGED(EXIT(ch, attempt)->to_room, ROOM_DEATH)) {
act("$n panics, and attempts to flee!", TRUE, ch, 0, 0, TO_ROOM);
was_fighting = FIGHTING(ch);
if (do_simple_move(ch, attempt, TRUE)) {
send_to_char(ch, "You flee head over heels.\r\n");
if (was_fighting && !IS_NPC(ch)) {
loss = GET_MAX_HIT(was_fighting) - GET_HIT(was_fighting);
loss *= GET_LEVEL(was_fighting);
gain_exp(ch, -loss);
}
} else {
act("$n tries to flee, but can't!", TRUE, ch, 0, 0, TO_ROOM);
}
return;
}
}
send_to_char(ch, "PANIC! You couldn't escape!\r\n");
}
ACMD(do_bash)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
int percent, prob;
one_argument(argument, arg);
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_BASH)) {
send_to_char(ch, "You have no idea how.\r\n");
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
send_to_char(ch, "This room just has such a peaceful, easy feeling...\r\n");
return;
}
if (!GET_EQ(ch, WEAR_WIELD)) {
send_to_char(ch, "You need to wield a weapon to make it a success.\r\n");
return;
}
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) {
if (FIGHTING(ch) && IN_ROOM(ch) == IN_ROOM(FIGHTING(ch))) {
vict = FIGHTING(ch);
} else {
send_to_char(ch, "Bash who?\r\n");
return;
}
}
if (vict == ch) {
send_to_char(ch, "Aren't we funny today...\r\n");
return;
}
percent = rand_number(1, 101); /* 101% is a complete failure */
prob = GET_SKILL(ch, SKILL_BASH);
if (MOB_FLAGGED(vict, MOB_NOBASH))
percent = 101;
if (percent > prob) {
damage(ch, vict, 0, SKILL_BASH);
GET_POS(ch) = POS_SITTING;
} else {
/*
* If we bash a player and they wimp out, they will move to the previous
* room before we set them sitting. If we try to set the victim sitting
* first to make sure they don't flee, then we can't bash them! So now
* we only set them sitting if they didn't flee. -gg 9/21/98
*/
if (damage(ch, vict, 1, SKILL_BASH) > 0) { /* -1 = dead, 0 = miss */
WAIT_STATE(vict, PULSE_VIOLENCE);
if (IN_ROOM(ch) == IN_ROOM(vict))
GET_POS(vict) = POS_SITTING;
}
}
WAIT_STATE(ch, PULSE_VIOLENCE * 2);
}
ACMD(do_rescue)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict, *tmp_ch;
int percent, prob;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_RESCUE)) {
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
one_argument(argument, arg);
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Whom do you want to rescue?\r\n");
return;
}
if (vict == ch) {
send_to_char(ch, "What about fleeing instead?\r\n");
return;
}
if (FIGHTING(ch) == vict) {
send_to_char(ch, "How can you rescue someone you are trying to kill?\r\n");
return;
}
for (tmp_ch = world[IN_ROOM(ch)].people; tmp_ch &&
(FIGHTING(tmp_ch) != vict); tmp_ch = tmp_ch->next_in_room);
if (!tmp_ch) {
act("But nobody is fighting $M!", FALSE, ch, 0, vict, TO_CHAR);
return;
}
percent = rand_number(1, 101); /* 101% is a complete failure */
prob = GET_SKILL(ch, SKILL_RESCUE);
if (percent > prob) {
send_to_char(ch, "You fail the rescue!\r\n");
return;
}
send_to_char(ch, "Banzai! To the rescue...\r\n");
act("You are rescued by $N, you are confused!", FALSE, vict, 0, ch, TO_CHAR);
act("$n heroically rescues $N!", FALSE, ch, 0, vict, TO_NOTVICT);
if (FIGHTING(vict) == tmp_ch)
stop_fighting(vict);
if (FIGHTING(tmp_ch))
stop_fighting(tmp_ch);
if (FIGHTING(ch))
stop_fighting(ch);
set_fighting(ch, tmp_ch);
set_fighting(tmp_ch, ch);
WAIT_STATE(vict, 2 * PULSE_VIOLENCE);
}
ACMD(do_kick)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
int percent, prob;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_KICK)) {
send_to_char(ch, "You have no idea how.\r\n");
return;
}
one_argument(argument, arg);
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM))) {
if (FIGHTING(ch) && IN_ROOM(ch) == IN_ROOM(FIGHTING(ch))) {
vict = FIGHTING(ch);
} else {
send_to_char(ch, "Kick who?\r\n");
return;
}
}
if (vict == ch) {
send_to_char(ch, "Aren't we funny today...\r\n");
return;
}
/* 101% is a complete failure */
percent = ((10 - (compute_armor_class(vict) / 10)) * 2) + rand_number(1, 101);
prob = GET_SKILL(ch, SKILL_KICK);
if (percent > prob) {
damage(ch, vict, 0, SKILL_KICK);
} else
damage(ch, vict, GET_LEVEL(ch) / 2, SKILL_KICK);
WAIT_STATE(ch, PULSE_VIOLENCE * 3);
}

1108
src/act.other.c Normal file

File diff suppressed because it is too large Load diff

464
src/act.social.c Normal file
View file

@ -0,0 +1,464 @@
/* ************************************************************************
* File: act.social.c Part of CircleMUD *
* Usage: Functions to handle socials *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
/* local functions */
char *fread_action(FILE *fl, int nr);
int find_action(int cmd);
ACMD(do_action);
ACMD(do_insult);
void boot_social_messages(void);
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)
{
char arg[MAX_INPUT_LENGTH], part[MAX_INPUT_LENGTH];
int act_nr;
struct social_messg *action;
struct char_data *vict;
struct obj_data *targ;
if ((act_nr = find_action(cmd)) < 0) {
send_to_char(ch, "That action is not supported.\r\n");
return;
}
action = &soc_mess_list[act_nr];
if (!argument || !*argument) {
send_to_char(ch, "%s\r\n", action->char_no_arg);
act(action->others_no_arg, action->hide, ch, 0, 0, TO_ROOM);
return;
}
two_arguments(argument, arg, part);
if ((!action->char_body_found) && (*part)) {
send_to_char(ch, "Sorry, this social does not support body parts.\r\n");
return;
}
if (!action->char_found)
*arg = '\0';
if (action->char_found && argument)
one_argument(argument, arg);
else
*arg = '\0';
vict = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM);
if (!vict) {
if (action->char_obj_found) {
targ = get_obj_in_list_vis(ch, arg, NULL, ch->carrying);
if (!targ) targ = get_obj_in_list_vis(ch, arg, NULL, world[IN_ROOM(ch)].contents);
if (targ) {
act(action->char_obj_found, action->hide, ch, targ, 0, TO_CHAR);
act(action->others_obj_found, action->hide, ch, targ, 0, TO_ROOM);
return;
}
}
if (action->not_found)
send_to_char(ch, "%s\r\n", action->not_found);
else
send_to_char(ch, "I don't see anything by that name here.\r\n");
return;
}
if (vict == ch) {
if (action->char_auto)
send_to_char(ch, "%s\r\n", action->char_auto);
else
send_to_char(ch, "Erm, no.");
act(action->others_auto, action->hide, ch, 0, 0, TO_ROOM);
return;
}
if (GET_POS(vict) < action->min_victim_position)
act("$N is not in a proper position for that.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else {
if (*part) {
act(action->char_body_found, 0, ch, (struct obj_data *)part, vict, TO_CHAR | TO_SLEEP);
act(action->others_body_found, action->hide, ch, (struct obj_data *)part, vict, TO_NOTVICT);
act(action->vict_body_found, action->hide, ch, (struct obj_data *)part, vict, TO_VICT);
} else {
act(action->char_found, 0, ch, 0, vict, TO_CHAR | TO_SLEEP);
act(action->others_found, action->hide, ch, 0, vict, TO_NOTVICT);
act(action->vict_found, action->hide, ch, 0, vict, TO_VICT);
}
}
}
ACMD(do_insult)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *victim;
one_argument(argument, arg);
if (*arg) {
if (!(victim = get_char_vis(ch, arg, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "Can't hear you!\r\n");
else {
if (victim != ch) {
send_to_char(ch, "You insult %s.\r\n", GET_NAME(victim));
switch (rand_number(0, 2)) {
case 0:
if (GET_SEX(ch) == SEX_MALE) {
if (GET_SEX(victim) == SEX_MALE)
act("$n accuses you of fighting like a woman!", FALSE, ch, 0, victim, TO_VICT);
else
act("$n says that women can't fight.", FALSE, ch, 0, victim, TO_VICT);
} else { /* Ch == Woman */
if (GET_SEX(victim) == SEX_MALE)
act("$n accuses you of having the smallest... (brain?)",
FALSE, ch, 0, victim, TO_VICT);
else
act("$n tells you that you'd lose a beauty contest against a troll.",
FALSE, ch, 0, victim, TO_VICT);
}
break;
case 1:
act("$n calls your mother a bitch!", FALSE, ch, 0, victim, TO_VICT);
break;
default:
act("$n tells you to get lost!", FALSE, ch, 0, victim, TO_VICT);
break;
} /* end switch */
act("$n insults $N.", TRUE, ch, 0, victim, TO_NOTVICT);
} else { /* ch == victim */
send_to_char(ch, "You feel insulted.\r\n");
}
}
} else
send_to_char(ch, "I'm sure you don't want to insult *everybody*...\r\n");
}
void boot_social_messages(void)
{
FILE *fl;
int nr = 0, hide, min_char_pos, min_pos, min_lvl, curr_soc = -1;
char next_soc[MAX_STRING_LENGTH], sorted[MAX_INPUT_LENGTH];
if (CONFIG_NEW_SOCIALS == TRUE) {
/* open social file */
if (!(fl = fopen(SOCMESS_FILE_NEW, "r"))) {
log("SYSERR: can't open socials file '%s': %s", SOCMESS_FILE_NEW, strerror(errno));
exit(1);
}
/* count socials */
*next_soc = '\0';
while (!feof(fl)) {
fgets(next_soc, MAX_STRING_LENGTH, fl);
if (*next_soc == '~') top_of_socialt++;
}
} else { /* old style */
/* open social file */
if (!(fl = fopen(SOCMESS_FILE, "r"))) {
log("SYSERR: can't open socials file '%s': %s", SOCMESS_FILE, strerror(errno));
exit(1);
}
/* count socials */
while (!feof(fl)) {
fgets(next_soc, MAX_STRING_LENGTH, fl);
if (*next_soc == '\n' || *next_soc == '\r') top_of_socialt++; /* all socials are followed by a blank line */
}
}
log("Social table contains %d socials.", top_of_socialt);
rewind(fl);
CREATE(soc_mess_list, struct social_messg, top_of_socialt + 1);
/* now read 'em */
for (;;) {
fscanf(fl, " %s ", next_soc);
if (*next_soc == '$') break;
if (CONFIG_NEW_SOCIALS == TRUE) {
if (fscanf(fl, " %s %d %d %d %d \n",
sorted, &hide, &min_char_pos, &min_pos, &min_lvl) != 5) {
log("SYSERR: format error in social file near social '%s'", next_soc);
exit(1);
}
curr_soc++;
soc_mess_list[curr_soc].command = strdup(next_soc+1);
soc_mess_list[curr_soc].sort_as = strdup(sorted);
soc_mess_list[curr_soc].hide = hide;
soc_mess_list[curr_soc].min_char_position = min_char_pos;
soc_mess_list[curr_soc].min_victim_position = min_pos;
soc_mess_list[curr_soc].min_level_char = min_lvl;
} else { /* old style */
if (fscanf(fl, " %d %d \n", &hide, &min_pos) != 2) {
log("SYSERR: format error in social file near social '%s'", next_soc);
exit(1);
}
curr_soc++;
soc_mess_list[curr_soc].command = strdup(next_soc);
soc_mess_list[curr_soc].sort_as = strdup(next_soc);
soc_mess_list[curr_soc].hide = hide;
soc_mess_list[curr_soc].min_char_position = POS_RESTING;
soc_mess_list[curr_soc].min_victim_position = min_pos;
soc_mess_list[curr_soc].min_level_char = 0;
}
#ifdef CIRCLE_ACORN
if (fgetc(fl) != '\n')
log("SYSERR: Acorn bug workaround failed.");
#endif
soc_mess_list[curr_soc].char_no_arg = fread_action(fl, nr);
soc_mess_list[curr_soc].others_no_arg = fread_action(fl, nr);
soc_mess_list[curr_soc].char_found = fread_action(fl, nr);
/* if no char_found, the rest is to be ignored */
if (CONFIG_NEW_SOCIALS == FALSE && !soc_mess_list[curr_soc].char_found)
continue;
soc_mess_list[curr_soc].others_found = fread_action(fl, nr);
soc_mess_list[curr_soc].vict_found = fread_action(fl, nr);
soc_mess_list[curr_soc].not_found = fread_action(fl, nr);
soc_mess_list[curr_soc].char_auto = fread_action(fl, nr);
soc_mess_list[curr_soc].others_auto = fread_action(fl, nr);
if (CONFIG_NEW_SOCIALS == FALSE)
continue;
soc_mess_list[curr_soc].char_body_found = fread_action(fl, nr);
soc_mess_list[curr_soc].others_body_found = fread_action(fl, nr);
soc_mess_list[curr_soc].vict_body_found = fread_action(fl, nr);
soc_mess_list[curr_soc].char_obj_found = fread_action(fl, nr);
soc_mess_list[curr_soc].others_obj_found = fread_action(fl, nr);
}
/* close file & set top */
fclose(fl);
assert(curr_soc <= top_of_socialt);
top_of_socialt = curr_soc;
}
/* this function adds in the loaded socials and assigns them a command # */
void create_command_list(void)
{
int i, j, k;
struct social_messg temp;
extern struct command_info cmd_info[];
/* free up old command list */
if (complete_cmd_info)
free_command_list();
/* re check the sort on the socials */
for (j = 0; j < top_of_socialt; j++) {
k = j;
for (i = j + 1; i <= top_of_socialt; i++)
if (str_cmp(soc_mess_list[i].sort_as, soc_mess_list[k].sort_as) < 0)
k = i;
if (j != k) {
temp = soc_mess_list[j];
soc_mess_list[j] = soc_mess_list[k];
soc_mess_list[k] = temp;
}
}
/* count the commands in the command list */
i = 0;
while(*cmd_info[i].command != '\n') i++;
i++;
CREATE(complete_cmd_info, struct command_info, top_of_socialt + i + 2);
/* this loop sorts the socials and commands together into one big list */
i = 0;
j = 0;
k = 0;
while ((*cmd_info[i].command != '\n') || (j <= top_of_socialt)) {
if ((i < RESERVE_CMDS) || (j > top_of_socialt) ||
(str_cmp(cmd_info[i].sort_as, soc_mess_list[j].sort_as) < 1))
complete_cmd_info[k++] = cmd_info[i++];
else {
soc_mess_list[j].act_nr = k;
complete_cmd_info[k].command = soc_mess_list[j].command;
complete_cmd_info[k].sort_as = soc_mess_list[j].sort_as;
complete_cmd_info[k].minimum_position = soc_mess_list[j].min_char_position;
complete_cmd_info[k].command_pointer = do_action;
complete_cmd_info[k].minimum_level = soc_mess_list[j++].min_level_char;
complete_cmd_info[k++].subcmd = 0;
}
}
complete_cmd_info[k].command = strdup("\n");
complete_cmd_info[k].sort_as = strdup("zzzzzzz");
complete_cmd_info[k].minimum_position = 0;
complete_cmd_info[k].command_pointer = 0;
complete_cmd_info[k].minimum_level = 0;
complete_cmd_info[k].subcmd = 0;
log("Command info rebuilt, %d total commands.", k);
}
void free_command_list(void)
{
int i;
for (i = 0;*complete_cmd_info[i].command !='\n';i++);
free((char *)complete_cmd_info[i].command); /* special case, the terminator */
free((char *)complete_cmd_info[i].sort_as);
free(complete_cmd_info);
complete_cmd_info = NULL;
}
char *fread_action(FILE *fl, int nr)
{
char buf[MAX_STRING_LENGTH];
fgets(buf, MAX_STRING_LENGTH, fl);
if (feof(fl)) {
log("SYSERR: fread_action: unexpected EOF near action #%d", nr);
exit(1);
}
if (*buf == '#')
return (NULL);
buf[strlen(buf) - 1] = '\0';
return (strdup(buf));
}
void free_social_messages(void)
{
struct social_messg *mess;
int i;
for (i = 0;i <= top_of_socialt;i++) {
mess = &soc_mess_list[i];
free_action(mess);
}
free(soc_mess_list);
}
void free_action(struct social_messg *mess) {
if (mess->command) free(mess->command);
if (mess->sort_as) free(mess->sort_as);
if (mess->char_no_arg) free(mess->char_no_arg);
if (mess->others_no_arg) free(mess->others_no_arg);
if (mess->char_found) free(mess->char_found);
if (mess->others_found) free(mess->others_found);
if (mess->vict_found) free(mess->vict_found);
if (mess->char_body_found) free(mess->char_body_found);
if (mess->others_body_found) free(mess->others_body_found);
if (mess->vict_body_found) free(mess->vict_body_found);
if (mess->not_found) free(mess->not_found);
if (mess->char_auto) free(mess->char_auto);
if (mess->others_auto) free(mess->others_auto);
if (mess->char_obj_found) free(mess->char_obj_found);
if (mess->others_obj_found) free(mess->others_obj_found);
memset(mess, 0, sizeof(struct social_messg));
}
int find_action(int cmd)
{
int bot, top, mid;
bot = 0;
top = top_of_socialt;
if (top < 0)
return (-1);
for (;;) {
mid = (bot + top) / 2;
if (soc_mess_list[mid].act_nr == cmd)
return (mid);
if (bot >= top)
return (-1);
if (soc_mess_list[mid].act_nr > cmd)
top = --mid;
else
bot = ++mid;
}
}
ACMD(do_gmote)
{
int act_nr, length;
char arg[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
struct social_messg *action;
struct char_data *vict = NULL;
half_chop(argument, buf, arg);
if(subcmd)
for (length = strlen(buf), cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++)
if (!strncmp(complete_cmd_info[cmd].command, buf, length))
break;
if ((act_nr = find_action(cmd)) < 0) {
send_to_char(ch, "That's not a social!\r\n");
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF)) {
send_to_char(ch, "The walls seem to absorb your actions.\r\n");
return;
}
action = &soc_mess_list[act_nr];
if (!action->char_found)
*arg = '\0';
if (!*arg) {
if(!action->others_no_arg || !*action->others_no_arg) {
send_to_char(ch, "Who are you going to do that to?\r\n");
return;
}
snprintf(buf, sizeof(buf), "Gossip: %s", action->others_no_arg);
} else if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD))) {
send_to_char(ch, "%s\r\n", action->not_found);
return;
} else if (vict == ch) {
if(!action->others_auto || !*action->others_auto) {
send_to_char(ch, "%s\r\n", action->char_auto);
return;
}
snprintf(buf, sizeof(buf), "Gossip: %s", action->others_auto);
} else {
if (GET_POS(vict) < action->min_victim_position) {
act("$N is not in a proper position for that.",
FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
return;
}
snprintf(buf, sizeof(buf), "Gossip: %s", action->others_found);
}
act(buf, FALSE, ch, 0, vict, TO_GMOTE);
}

4173
src/act.wizard.c Normal file

File diff suppressed because it is too large Load diff

830
src/aedit.c Normal file
View file

@ -0,0 +1,830 @@
/*
* File: aedit.c
* Comment: OLC for MUDs -- this one edits socials
* by Michael Scott <scottm@workcomm.net> -- 06/10/96
* for use with OasisOLC
* ftpable from ftp.circlemud.org:/pub/CircleMUD/contrib/code
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "interpreter.h"
#include "handler.h"
#include "comm.h"
#include "utils.h"
#include "db.h"
#include "oasis.h"
#include "screen.h"
#include "constants.h"
#include "genolc.h"
/* external functs */
int sort_command_helper(const void *a, const void *b);
void sort_commands(void); /* aedit patch -- M. Scott */
void create_command_list(void);
/* function protos */
ACMD(do_astat);
int aedit_find_command(const char *txt);
/*
* Utils and exported functions.
*/
/*------------------------------------------------------------------------*\
Utils and exported functions.
\*------------------------------------------------------------------------*/
ACMD(do_oasis_aedit)
{
char arg[MAX_INPUT_LENGTH];
struct descriptor_data *d;
int i;
if (CONFIG_NEW_SOCIALS == 0) {
send_to_char(ch, "Socials cannot be edited at the moment.\r\n");
return;
}
if (GET_OLC_ZONE(ch) != AEDIT_PERMISSION && GET_LEVEL(ch) < LVL_GOD) {
send_to_char(ch, "You don't have access to editing socials.\r\n");
return;
}
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_AEDIT) {
send_to_char(ch, "Sorry, only one can edit socials at a time.\r\n");
return;
}
one_argument(argument, arg);
if (!*arg) {
send_to_char(ch, "Please specify a social to edit.\r\n");
return;
}
d = ch->desc;
if (!str_cmp("save", arg)) {
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE, "OLC: %s saves socials.", GET_NAME(ch));
send_to_char(ch, "Writing social file..\r\n");
aedit_save_to_disk(d);
send_to_char(ch, "Done.\r\n");
return;
}
/*
* Give descriptor an OLC structure.
*/
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: do_oasis: Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
OLC_NUM(d) = 0;
OLC_STORAGE(d) = strdup(arg);
for (OLC_ZNUM(d) = 0; (OLC_ZNUM(d) <= top_of_socialt); OLC_ZNUM(d)++)
if (is_abbrev(OLC_STORAGE(d), soc_mess_list[OLC_ZNUM(d)].command))
break;
if (OLC_ZNUM(d) > top_of_socialt) {
if ((i = aedit_find_command(OLC_STORAGE(d))) != -1) {
send_to_char(ch, "The '%s' command already exists (%s).\r\n", OLC_STORAGE(d), complete_cmd_info[i].command);
cleanup_olc(d, CLEANUP_ALL);
return;
}
send_to_char(ch, "Do you wish to add the '%s' action? ", OLC_STORAGE(d));
OLC_MODE(d) = AEDIT_CONFIRM_ADD;
} else {
send_to_char(ch, "Do you wish to edit the '%s' action? ", soc_mess_list[OLC_ZNUM(d)].command);
OLC_MODE(d) = AEDIT_CONFIRM_EDIT;
}
STATE(d) = CON_AEDIT;
act("$n starts using OLC.", TRUE, d->character, 0, 0, TO_ROOM);
SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing actions.", GET_NAME(ch));
}
void aedit_setup_new(struct descriptor_data *d) {
CREATE(OLC_ACTION(d), struct social_messg, 1);
OLC_ACTION(d)->command = strdup(OLC_STORAGE(d));
OLC_ACTION(d)->sort_as = strdup(OLC_STORAGE(d));
OLC_ACTION(d)->hide = 0;
OLC_ACTION(d)->min_victim_position = POS_STANDING;
OLC_ACTION(d)->min_char_position = POS_STANDING;
OLC_ACTION(d)->min_level_char = 0;
OLC_ACTION(d)->char_no_arg = strdup("This action is unfinished.");
OLC_ACTION(d)->others_no_arg = strdup("This action is unfinished.");
OLC_ACTION(d)->char_found = NULL;
OLC_ACTION(d)->others_found = NULL;
OLC_ACTION(d)->vict_found = NULL;
OLC_ACTION(d)->not_found = NULL;
OLC_ACTION(d)->char_auto = NULL;
OLC_ACTION(d)->others_auto = NULL;
OLC_ACTION(d)->char_body_found = NULL;
OLC_ACTION(d)->others_body_found = NULL;
OLC_ACTION(d)->vict_body_found = NULL;
OLC_ACTION(d)->char_obj_found = NULL;
OLC_ACTION(d)->others_obj_found = NULL;
aedit_disp_menu(d);
OLC_VAL(d) = 0;
}
/*------------------------------------------------------------------------*/
void aedit_setup_existing(struct descriptor_data *d, int real_num) {
CREATE(OLC_ACTION(d), struct social_messg, 1);
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)->hide = soc_mess_list[real_num].hide;
OLC_ACTION(d)->min_victim_position = soc_mess_list[real_num].min_victim_position;
OLC_ACTION(d)->min_char_position = soc_mess_list[real_num].min_char_position;
OLC_ACTION(d)->min_level_char = soc_mess_list[real_num].min_level_char;
if (soc_mess_list[real_num].char_no_arg)
OLC_ACTION(d)->char_no_arg = strdup(soc_mess_list[real_num].char_no_arg);
if (soc_mess_list[real_num].others_no_arg)
OLC_ACTION(d)->others_no_arg = strdup(soc_mess_list[real_num].others_no_arg);
if (soc_mess_list[real_num].char_found)
OLC_ACTION(d)->char_found = strdup(soc_mess_list[real_num].char_found);
if (soc_mess_list[real_num].others_found)
OLC_ACTION(d)->others_found = strdup(soc_mess_list[real_num].others_found);
if (soc_mess_list[real_num].vict_found)
OLC_ACTION(d)->vict_found = strdup(soc_mess_list[real_num].vict_found);
if (soc_mess_list[real_num].not_found)
OLC_ACTION(d)->not_found = strdup(soc_mess_list[real_num].not_found);
if (soc_mess_list[real_num].char_auto)
OLC_ACTION(d)->char_auto = strdup(soc_mess_list[real_num].char_auto);
if (soc_mess_list[real_num].others_auto)
OLC_ACTION(d)->others_auto = strdup(soc_mess_list[real_num].others_auto);
if (soc_mess_list[real_num].char_body_found)
OLC_ACTION(d)->char_body_found = strdup(soc_mess_list[real_num].char_body_found);
if (soc_mess_list[real_num].others_body_found)
OLC_ACTION(d)->others_body_found = strdup(soc_mess_list[real_num].others_body_found);
if (soc_mess_list[real_num].vict_body_found)
OLC_ACTION(d)->vict_body_found = strdup(soc_mess_list[real_num].vict_body_found);
if (soc_mess_list[real_num].char_obj_found)
OLC_ACTION(d)->char_obj_found = strdup(soc_mess_list[real_num].char_obj_found);
if (soc_mess_list[real_num].others_obj_found)
OLC_ACTION(d)->others_obj_found = strdup(soc_mess_list[real_num].others_obj_found);
OLC_VAL(d) = 0;
aedit_disp_menu(d);
}
void aedit_save_internally(struct descriptor_data *d) {
struct social_messg *new_soc_mess_list = NULL;
int i;
/* add a new social into the list */
if (OLC_ZNUM(d) > top_of_socialt) {
CREATE(new_soc_mess_list, struct social_messg, top_of_socialt + 2);
for (i = 0; i <= top_of_socialt; i++)
new_soc_mess_list[i] = soc_mess_list[i];
new_soc_mess_list[++top_of_socialt] = *OLC_ACTION(d);
free(soc_mess_list);
soc_mess_list = new_soc_mess_list;
}
/* pass the editted action back to the list - no need to add */
else {
i = aedit_find_command(OLC_ACTION(d)->command);
OLC_ACTION(d)->act_nr = soc_mess_list[OLC_ZNUM(d)].act_nr;
/* why did i do this..? hrm */
free_action(soc_mess_list + OLC_ZNUM(d));
soc_mess_list[OLC_ZNUM(d)] = *OLC_ACTION(d);
}
create_command_list();
sort_commands();
add_to_save_list(AEDIT_PERMISSION, SL_ACTION);
aedit_save_to_disk(d); /* autosave by Rumble */
}
/*------------------------------------------------------------------------*/
void aedit_save_to_disk(struct descriptor_data *d) {
FILE *fp;
int i;
if (!(fp = fopen(SOCMESS_FILE_NEW, "w+"))) {
char error[MAX_STRING_LENGTH];
snprintf(error, sizeof(error), "Can't open socials file '%s'", SOCMESS_FILE);
perror(error);
exit(1);
}
for (i = 0; i <= top_of_socialt; i++) {
fprintf(fp, "~%s %s %d %d %d %d\n",
soc_mess_list[i].command,
soc_mess_list[i].sort_as,
soc_mess_list[i].hide,
soc_mess_list[i].min_char_position,
soc_mess_list[i].min_victim_position,
soc_mess_list[i].min_level_char);
fprintf(fp, "%s\n%s\n%s\n%s\n",
((soc_mess_list[i].char_no_arg)?soc_mess_list[i].char_no_arg:"#"),
((soc_mess_list[i].others_no_arg)?soc_mess_list[i].others_no_arg:"#"),
((soc_mess_list[i].char_found)?soc_mess_list[i].char_found:"#"),
((soc_mess_list[i].others_found)?soc_mess_list[i].others_found:"#"));
fprintf(fp, "%s\n%s\n%s\n%s\n",
((soc_mess_list[i].vict_found)?soc_mess_list[i].vict_found:"#"),
((soc_mess_list[i].not_found)?soc_mess_list[i].not_found:"#"),
((soc_mess_list[i].char_auto)?soc_mess_list[i].char_auto:"#"),
((soc_mess_list[i].others_auto)?soc_mess_list[i].others_auto:"#"));
fprintf(fp, "%s\n%s\n%s\n",
((soc_mess_list[i].char_body_found)?soc_mess_list[i].char_body_found:"#"),
((soc_mess_list[i].others_body_found)?soc_mess_list[i].others_body_found:"#"),
((soc_mess_list[i].vict_body_found)?soc_mess_list[i].vict_body_found:"#"));
fprintf(fp, "%s\n%s\n\n",
((soc_mess_list[i].char_obj_found)?soc_mess_list[i].char_obj_found:"#"),
((soc_mess_list[i].others_obj_found)?soc_mess_list[i].others_obj_found:"#"));
}
fprintf(fp, "$\n");
fclose(fp);
remove_from_save_list(AEDIT_PERMISSION, SL_ACTION);
}
/*------------------------------------------------------------------------*/
/* Menu functions */
/* the main menu */
void aedit_disp_menu(struct descriptor_data * d) {
struct social_messg *action = OLC_ACTION(d);
struct char_data *ch = d->character;
get_char_colors(ch);
write_to_output(d,
"%s-- Action editor\r\n"
"%sn%s) Command : %s%-15.15s%s %s1%s) Sort as Command : %s%-15.15s%s\r\n"
"%s2%s) Min Position[CH]: %s%-8.8s %s3%s) Min Position [VT]: %s%-8.8s\r\n"
"%s4%s) Min Level [CH]: %s%-3d %s5%s) Show if Invisible: %s%s\r\n"
"%sa%s) Char [NO ARG]: %s%s\r\n"
"%sb%s) Others [NO ARG]: %s%s\r\n"
"%sc%s) Char [NOT FOUND]: %s%s\r\n"
"%sd%s) Char [ARG SELF]: %s%s\r\n"
"%se%s) Others[ARG SELF]: %s%s\r\n"
"%sf%s) Char [VICT]: %s%s\r\n"
"%sg%s) Others [VICT]: %s%s\r\n"
"%sh%s) Victim [VICT]: %s%s\r\n"
"%si%s) Char [BODY PRT]: %s%s\r\n"
"%sj%s) Others[BODY PRT]: %s%s\r\n"
"%sk%s) Victim[BODY PRT]: %s%s\r\n"
"%sl%s) Char [OBJ]: %s%s\r\n"
"%sm%s) Others [OBJ]: %s%s\r\n"
"%sq%s) Quit\r\n"
"Enter Choice:",
nrm, grn, nrm,
yel, action->command, nrm,
grn, nrm,
yel, action->sort_as, nrm,
grn, nrm,
cyn, position_types[action->min_char_position],
grn, nrm,
cyn, position_types[action->min_victim_position],
grn, nrm,
cyn, action->min_level_char,
grn, nrm,
cyn, (action->hide?"HIDDEN":"NOT HIDDEN"),
grn, nrm, cyn,
action->char_no_arg ? action->char_no_arg : "<Null>",
grn, nrm, cyn,
action->others_no_arg ? action->others_no_arg : "<Null>",
grn, nrm, cyn,
action->not_found ? action->not_found : "<Null>",
grn, nrm, cyn,
action->char_auto ? action->char_auto : "<Null>",
grn, nrm, cyn,
action->others_auto ? action->others_auto : "<Null>",
grn, nrm, cyn,
action->char_found ? action->char_found : "<Null>",
grn, nrm, cyn,
action->others_found ? action->others_found : "<Null>",
grn, nrm, cyn,
action->vict_found ? action->vict_found : "<Null>",
grn, nrm, cyn,
action->char_body_found ? action->char_body_found : "<Null>",
grn, nrm, cyn,
action->others_body_found ? action->others_body_found : "<Null>",
grn, nrm, cyn,
action->vict_body_found ? action->vict_body_found : "<Null>",
grn, nrm, cyn,
action->char_obj_found ? action->char_obj_found : "<Null>",
grn, nrm, cyn,
action->others_obj_found ? action->others_obj_found : "<Null>",
grn, nrm);
OLC_MODE(d) = AEDIT_MAIN_MENU;
}
/*
* The main loop
*/
void aedit_parse(struct descriptor_data * d, char *arg) {
int i;
switch (OLC_MODE(d)) {
case AEDIT_CONFIRM_SAVESTRING:
switch (*arg) {
case 'y': case 'Y':
aedit_save_internally(d);
mudlog (CMP, LVL_IMPL, TRUE, "OLC: %s edits action %s",
GET_NAME(d->character), OLC_ACTION(d)->command);
/* do not free the strings.. just the structure */
cleanup_olc(d, CLEANUP_STRUCTS);
write_to_output(d, "Action saved to disk.\r\n");
break;
case 'n': case 'N':
/* free everything up, including strings etc */
cleanup_olc(d, CLEANUP_ALL);
break;
default:
write_to_output(d, "Invalid choice!\r\n"
"Do you wish to save this action internally? ");
break;
}
return; /* end of AEDIT_CONFIRM_SAVESTRING */
case AEDIT_CONFIRM_EDIT:
switch (*arg) {
case 'y': case 'Y':
aedit_setup_existing(d, OLC_ZNUM(d));
break;
case 'q': case 'Q':
cleanup_olc(d, CLEANUP_ALL);
break;
case 'n': case 'N':
OLC_ZNUM(d)++;
for (;(OLC_ZNUM(d) <= top_of_socialt); OLC_ZNUM(d)++)
if (is_abbrev(OLC_STORAGE(d), soc_mess_list[OLC_ZNUM(d)].command))
break;
if (OLC_ZNUM(d) > top_of_socialt) {
if (aedit_find_command(OLC_STORAGE(d)) != -1) {
cleanup_olc(d, CLEANUP_ALL);
break;
}
write_to_output(d, "Do you wish to add the '%s' action? ",
OLC_STORAGE(d));
OLC_MODE(d) = AEDIT_CONFIRM_ADD;
} else {
write_to_output(d, "Do you wish to edit the '%s' action? ",
soc_mess_list[OLC_ZNUM(d)].command);
OLC_MODE(d) = AEDIT_CONFIRM_EDIT;
}
break;
default:
write_to_output(d, "Invalid choice!\r\n"
"Do you wish to edit the '%s' action? ",
soc_mess_list[OLC_ZNUM(d)].command);
break;
}
return;
case AEDIT_CONFIRM_ADD:
switch (*arg) {
case 'y': case 'Y':
aedit_setup_new(d);
break;
case 'n': case 'N': case 'q': case 'Q':
cleanup_olc(d, CLEANUP_ALL);
break;
default:
write_to_output(d, "Invalid choice!\r\n"
"Do you wish to add the '%s' action? ",
OLC_STORAGE(d));
break;
}
return;
case AEDIT_MAIN_MENU:
switch (*arg) {
case 'q': case 'Q':
if (OLC_VAL(d)) { /* Something was modified */
write_to_output(d, "Do you wish to save this action internally? ");
OLC_MODE(d) = AEDIT_CONFIRM_SAVESTRING;
}
else cleanup_olc(d, CLEANUP_ALL);
break;
case 'n':
write_to_output(d, "Enter action name: ");
OLC_MODE(d) = AEDIT_ACTION_NAME;
return;
case '1':
write_to_output(d, "Enter sort info for this action (for the command listing): ");
OLC_MODE(d) = AEDIT_SORT_AS;
return;
case '2':
write_to_output(d, "Enter the minimum position the Character has to be in to activate social:\r\n");
for (i=POS_DEAD;i<=POS_STANDING;i++)
write_to_output(d, " %d) %s\r\n", i, position_types[i]);
write_to_output(d, "Enter choice: ");
OLC_MODE(d) = AEDIT_MIN_CHAR_POS;
return;
case '3':
write_to_output(d, "Enter the minimum position the Victim has to be in to activate social:\r\n");
for (i=POS_DEAD;i<=POS_STANDING;i++)
write_to_output(d, " %d) %s\r\n", i, position_types[i]);
write_to_output(d, "Enter choice: ");
OLC_MODE(d) = AEDIT_MIN_VICT_POS;
return;
case '4':
write_to_output(d, "Enter new minimum level for social: ");
OLC_MODE(d) = AEDIT_MIN_CHAR_LEVEL;
return;
case '5':
OLC_ACTION(d)->hide = !OLC_ACTION(d)->hide;
aedit_disp_menu(d);
OLC_VAL(d) = 1;
break;
case 'a': case 'A':
write_to_output(d, "Enter social shown to the Character when there is no argument supplied.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->char_no_arg)?OLC_ACTION(d)->char_no_arg:"NULL"));
OLC_MODE(d) = AEDIT_NOVICT_CHAR;
return;
case 'b': case 'B':
write_to_output(d, "Enter social shown to Others when there is no argument supplied.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->others_no_arg)?OLC_ACTION(d)->others_no_arg:"NULL"));
OLC_MODE(d) = AEDIT_NOVICT_OTHERS;
return;
case 'c': case 'C':
write_to_output(d, "Enter text shown to the Character when his victim isnt found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->not_found)?OLC_ACTION(d)->not_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_NOT_FOUND;
return;
case 'd': case 'D':
write_to_output(d, "Enter social shown to the Character when it is its own victim.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->char_auto)?OLC_ACTION(d)->char_auto:"NULL"));
OLC_MODE(d) = AEDIT_SELF_CHAR;
return;
case 'e': case 'E':
write_to_output(d, "Enter social shown to Others when the Char is its own victim.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->others_auto)?OLC_ACTION(d)->others_auto:"NULL"));
OLC_MODE(d) = AEDIT_SELF_OTHERS;
return;
case 'f': case 'F':
write_to_output(d, "Enter normal social shown to the Character when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->char_found)?OLC_ACTION(d)->char_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_CHAR_FOUND;
return;
case 'g': case 'G':
write_to_output(d, "Enter normal social shown to Others when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->others_found)?OLC_ACTION(d)->others_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_OTHERS_FOUND;
return;
case 'h': case 'H':
write_to_output(d, "Enter normal social shown to the Victim when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->vict_found)?OLC_ACTION(d)->vict_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_VICT_FOUND;
return;
case 'i': case 'I':
write_to_output(d, "Enter 'body part' social shown to the Character when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->char_body_found)?OLC_ACTION(d)->char_body_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_CHAR_BODY_FOUND;
return;
case 'j': case 'J':
write_to_output(d, "Enter 'body part' social shown to Others when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->others_body_found)?OLC_ACTION(d)->others_body_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_OTHERS_BODY_FOUND;
return;
case 'k': case 'K':
write_to_output(d, "Enter 'body part' social shown to the Victim when the victim is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->vict_body_found)?OLC_ACTION(d)->vict_body_found:"NULL"));
OLC_MODE(d) = AEDIT_VICT_VICT_BODY_FOUND;
return;
case 'l': case 'L':
write_to_output(d, "Enter 'object' social shown to the Character when the object is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->char_obj_found)?OLC_ACTION(d)->char_obj_found:"NULL"));
OLC_MODE(d) = AEDIT_OBJ_CHAR_FOUND;
return;
case 'm': case 'M':
write_to_output(d, "Enter 'object' social shown to the Room when the object is found.\r\n"
"[OLD]: %s\r\n"
"[NEW]: ",
((OLC_ACTION(d)->others_obj_found)?OLC_ACTION(d)->others_obj_found:"NULL"));
OLC_MODE(d) = AEDIT_OBJ_OTHERS_FOUND;
return;
default:
aedit_disp_menu(d);
break;
}
return;
case AEDIT_ACTION_NAME:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->command)
free(OLC_ACTION(d)->command);
OLC_ACTION(d)->command = strdup(arg);
break;
case AEDIT_SORT_AS:
if (!*arg || strchr(arg,' ')) {
aedit_disp_menu(d);
return;
}
if (OLC_ACTION(d)->sort_as) {
free(OLC_ACTION(d)->sort_as);
OLC_ACTION(d)->sort_as = strdup(arg);
}
break;
case AEDIT_MIN_CHAR_POS:
case AEDIT_MIN_VICT_POS:
if (!*arg) {
aedit_disp_menu(d);
return;
}
i = atoi(arg);
if ((i < POS_DEAD) && (i > POS_STANDING)) {
aedit_disp_menu(d);
return;
}
if (OLC_MODE(d) == AEDIT_MIN_CHAR_POS)
OLC_ACTION(d)->min_char_position = i;
else
OLC_ACTION(d)->min_victim_position = i;
break;
case AEDIT_MIN_CHAR_LEVEL:
if (!*arg) {
aedit_disp_menu(d);
return;
}
i = atoi(arg);
if ((i < 0) && (i > LVL_IMPL)) {
aedit_disp_menu(d);
return;
}
OLC_ACTION(d)->min_level_char = i;
break;
case AEDIT_NOVICT_CHAR:
if (OLC_ACTION(d)->char_no_arg)
free(OLC_ACTION(d)->char_no_arg);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->char_no_arg = strdup(arg);
} else
OLC_ACTION(d)->char_no_arg = NULL;
break;
case AEDIT_NOVICT_OTHERS:
if (OLC_ACTION(d)->others_no_arg)
free(OLC_ACTION(d)->others_no_arg);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->others_no_arg = strdup(arg);
} else
OLC_ACTION(d)->others_no_arg = NULL;
break;
case AEDIT_VICT_CHAR_FOUND:
if (OLC_ACTION(d)->char_found)
free(OLC_ACTION(d)->char_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->char_found = strdup(arg);
} else
OLC_ACTION(d)->char_found = NULL;
break;
case AEDIT_VICT_OTHERS_FOUND:
if (OLC_ACTION(d)->others_found)
free(OLC_ACTION(d)->others_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->others_found = strdup(arg);
} else
OLC_ACTION(d)->others_found = NULL;
break;
case AEDIT_VICT_VICT_FOUND:
if (OLC_ACTION(d)->vict_found)
free(OLC_ACTION(d)->vict_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->vict_found = strdup(arg);
} else
OLC_ACTION(d)->vict_found = NULL;
break;
case AEDIT_VICT_NOT_FOUND:
if (OLC_ACTION(d)->not_found)
free(OLC_ACTION(d)->not_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->not_found = strdup(arg);
} else
OLC_ACTION(d)->not_found = NULL;
break;
case AEDIT_SELF_CHAR:
if (OLC_ACTION(d)->char_auto)
free(OLC_ACTION(d)->char_auto);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->char_auto = strdup(arg);
} else
OLC_ACTION(d)->char_auto = NULL;
break;
case AEDIT_SELF_OTHERS:
if (OLC_ACTION(d)->others_auto)
free(OLC_ACTION(d)->others_auto);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->others_auto = strdup(arg);
} else
OLC_ACTION(d)->others_auto = NULL;
break;
case AEDIT_VICT_CHAR_BODY_FOUND:
if (OLC_ACTION(d)->char_body_found)
free(OLC_ACTION(d)->char_body_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->char_body_found = strdup(arg);
} else
OLC_ACTION(d)->char_body_found = NULL;
break;
case AEDIT_VICT_OTHERS_BODY_FOUND:
if (OLC_ACTION(d)->others_body_found)
free(OLC_ACTION(d)->others_body_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->others_body_found = strdup(arg);
} else
OLC_ACTION(d)->others_body_found = NULL;
break;
case AEDIT_VICT_VICT_BODY_FOUND:
if (OLC_ACTION(d)->vict_body_found)
free(OLC_ACTION(d)->vict_body_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->vict_body_found = strdup(arg);
} else
OLC_ACTION(d)->vict_body_found = NULL;
break;
case AEDIT_OBJ_CHAR_FOUND:
if (OLC_ACTION(d)->char_obj_found)
free(OLC_ACTION(d)->char_obj_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->char_obj_found = strdup(arg);
} else
OLC_ACTION(d)->char_obj_found = NULL;
break;
case AEDIT_OBJ_OTHERS_FOUND:
if (OLC_ACTION(d)->others_obj_found)
free(OLC_ACTION(d)->others_obj_found);
if (*arg) {
delete_doubledollar(arg);
OLC_ACTION(d)->others_obj_found = strdup(arg);
} else
OLC_ACTION(d)->others_obj_found = NULL;
break;
default:
/* we should never get here */
break;
}
OLC_VAL(d) = 1;
aedit_disp_menu(d);
}
ACMD(do_astat)
{
int i, real = FALSE;
char arg[MAX_INPUT_LENGTH];
if (IS_NPC(ch))
return;
one_argument(argument, arg);
if(!*arg) {
send_to_char(ch, "Astat which social?\r\n");
return;
}
for (i = 0; i <= top_of_socialt; i++) {
if (is_abbrev(arg, soc_mess_list[i].command)) {
real = TRUE;
break;
}
}
if (!real) {
send_to_char(ch, "No such social.\r\n");
return;
}
get_char_colors(ch);
send_to_char(ch,
"n) Command : %s%-15.15s%s 1) Sort as Command : %s%-15.15s%s\r\n"
"2) Min Position[CH]: %s%-8.8s%s 3) Min Position[VT]: %s%-8.8s%s\r\n"
"4) Min Level [CH]: %s%-3d%s 5) Show if Invis : %s%s%s\r\n"
"a) Char [NO ARG]: %s%s%s\r\n"
"b) Others [NO ARG]: %s%s%s\r\n"
"c) Char [NOT FOUND]: %s%s%s\r\n"
"d) Char [ARG SELF]: %s%s%s\r\n"
"e) Others[ARG SELF]: %s%s%s\r\n"
"f) Char [VICT]: %s%s%s\r\n"
"g) Others [VICT]: %s%s%s\r\n"
"h) Victim [VICT]: %s%s%s\r\n"
"i) Char [BODY PRT]: %s%s%s\r\n"
"j) Others[BODY PRT]: %s%s%s\r\n"
"k) Victim[BODY PRT]: %s%s%s\r\n"
"l) Char [OBJ]: %s%s%s\r\n"
"m) Others [OBJ]: %s%s%s\r\n",
yel, soc_mess_list[i].command, nrm,
yel, soc_mess_list[i].sort_as, nrm,
cyn, position_types[soc_mess_list[i].min_char_position], nrm,
cyn, position_types[soc_mess_list[i].min_victim_position], nrm,
cyn, soc_mess_list[i].min_level_char, nrm,
cyn, (soc_mess_list[i].hide ? "HIDDEN" : "NOT HIDDEN"), nrm,
cyn, soc_mess_list[i].char_no_arg ? soc_mess_list[i].char_no_arg : "", nrm,
cyn, soc_mess_list[i].others_no_arg ? soc_mess_list[i].others_no_arg : "", nrm,
cyn, soc_mess_list[i].not_found ? soc_mess_list[i].not_found : "", nrm,
cyn, soc_mess_list[i].char_auto ? soc_mess_list[i].char_auto : "", nrm,
cyn, soc_mess_list[i].others_auto ? soc_mess_list[i].others_auto : "", nrm,
cyn, soc_mess_list[i].char_found ? soc_mess_list[i].char_found : "", nrm,
cyn, soc_mess_list[i].others_found ? soc_mess_list[i].others_found : "", nrm,
cyn, soc_mess_list[i].vict_found ? soc_mess_list[i].vict_found : "", nrm,
cyn, soc_mess_list[i].char_body_found ? soc_mess_list[i].char_body_found : "", nrm,
cyn, soc_mess_list[i].others_body_found ? soc_mess_list[i].others_body_found : "", nrm,
cyn, soc_mess_list[i].vict_body_found ? soc_mess_list[i].vict_body_found : "", nrm,
cyn, soc_mess_list[i].char_obj_found ? soc_mess_list[i].char_obj_found : "", nrm,
cyn, soc_mess_list[i].others_obj_found ? soc_mess_list[i].others_obj_found : "", nrm);
}
int aedit_find_command(const char *txt)
{
int cmd;
for (cmd = 1; *complete_cmd_info[cmd].command != '\n'; cmd++)
if (!strncmp(complete_cmd_info[cmd].sort_as, txt, strlen(txt)) ||
!strcmp(complete_cmd_info[cmd].command, txt))
return (cmd);
return (-1);
}

128
src/alias.c Normal file
View file

@ -0,0 +1,128 @@
/* ***********************************************************************
* File: alias.c A utility to CircleMUD *
* Usage: writing/reading player's aliases. *
* *
* Code done by Jeremy Hess and Chad Thompson *
* Modifed by George Greer for inclusion into CircleMUD bpl15. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
*********************************************************************** */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "interpreter.h"
#include "db.h"
void write_aliases(struct char_data *ch);
void read_aliases(struct char_data *ch);
void delete_aliases(const char *charname);
void write_aliases(struct char_data *ch)
{
FILE *file;
char fn[MAX_STRING_LENGTH];
struct alias_data *temp;
get_filename(fn, sizeof(fn), ALIAS_FILE, GET_NAME(ch));
remove(fn);
if (GET_ALIASES(ch) == NULL)
return;
if ((file = fopen(fn, "w")) == NULL) {
log("SYSERR: Couldn't save aliases for %s in '%s'.", GET_NAME(ch), fn);
perror("SYSERR: write_aliases");
return;
}
for (temp = GET_ALIASES(ch); temp; temp = temp->next) {
int aliaslen = strlen(temp->alias);
int repllen = strlen(temp->replacement) - 1;
fprintf(file, "%d\n%s\n" /* Alias */
"%d\n%s\n" /* Replacement */
"%d\n", /* Type */
aliaslen, temp->alias,
repllen, temp->replacement + 1,
temp->type);
}
fclose(file);
}
void read_aliases(struct char_data *ch)
{
FILE *file;
char xbuf[MAX_STRING_LENGTH];
struct alias_data *t2, *prev = NULL;
int length;
get_filename(xbuf, sizeof(xbuf), ALIAS_FILE, GET_NAME(ch));
if ((file = fopen(xbuf, "r")) == NULL) {
if (errno != ENOENT) {
log("SYSERR: Couldn't open alias file '%s' for %s.", xbuf, GET_NAME(ch));
perror("SYSERR: read_aliases");
}
return;
}
CREATE(GET_ALIASES(ch), struct alias_data, 1);
t2 = GET_ALIASES(ch);
for (;;) {
/* Read the aliased command. */
if (fscanf(file, "%d\n", &length) != 1)
goto read_alias_error;
fgets(xbuf, length + 1, file);
t2->alias = strdup(xbuf);
/* Build the replacement. */
if (fscanf(file, "%d\n", &length) != 1)
goto read_alias_error;
*xbuf = ' '; /* Doesn't need terminated, fgets() will. */
fgets(xbuf + 1, length + 1, file);
t2->replacement = strdup(xbuf);
/* Figure out the alias type. */
if (fscanf(file, "%d\n", &length) != 1)
goto read_alias_error;
t2->type = length;
if (feof(file))
break;
CREATE(t2->next, struct alias_data, 1);
prev = t2;
t2 = t2->next;
};
fclose(file);
return;
read_alias_error:
if (t2->alias)
free(t2->alias);
free(t2);
if (prev)
prev->next = NULL;
fclose(file);
}
void delete_aliases(const char *charname)
{
char filename[PATH_MAX];
if (!get_filename(filename, sizeof(filename), ALIAS_FILE, charname))
return;
if (remove(filename) < 0 && errno != ENOENT)
log("SYSERR: deleting alias file %s: %s", filename, strerror(errno));
}

331
src/ban.c Normal file
View file

@ -0,0 +1,331 @@
/* ************************************************************************
* File: ban.c Part of CircleMUD *
* Usage: banning/unbanning/checking sites and player names *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
/* local globals */
struct ban_list_element *ban_list = NULL;
/* local functions */
void load_banned(void);
int isbanned(char *hostname);
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[] = {
"no",
"new",
"select",
"all",
"ERROR"
};
void load_banned(void)
{
FILE *fl;
int i, date;
char site_name[BANNED_SITE_LENGTH + 1], ban_type[100];
char name[MAX_NAME_LENGTH + 1];
struct ban_list_element *next_node;
ban_list = 0;
if (!(fl = fopen(BAN_FILE, "r"))) {
if (errno != ENOENT) {
log("SYSERR: Unable to open banfile '%s': %s", BAN_FILE, strerror(errno));
} else
log(" Ban file '%s' doesn't exist.", BAN_FILE);
return;
}
while (fscanf(fl, " %s %s %d %s ", ban_type, site_name, &date, name) == 4) {
CREATE(next_node, struct ban_list_element, 1);
strncpy(next_node->site, site_name, BANNED_SITE_LENGTH); /* strncpy: OK (n_n->site:BANNED_SITE_LENGTH+1) */
next_node->site[BANNED_SITE_LENGTH] = '\0';
strncpy(next_node->name, name, MAX_NAME_LENGTH); /* strncpy: OK (n_n->name:MAX_NAME_LENGTH+1) */
next_node->name[MAX_NAME_LENGTH] = '\0';
next_node->date = date;
for (i = BAN_NOT; i <= BAN_ALL; i++)
if (!strcmp(ban_type, ban_types[i]))
next_node->type = i;
next_node->next = ban_list;
ban_list = next_node;
}
fclose(fl);
}
int isbanned(char *hostname)
{
int i;
struct ban_list_element *banned_node;
char *nextchar;
if (!hostname || !*hostname)
return (0);
i = 0;
for (nextchar = hostname; *nextchar; nextchar++)
*nextchar = LOWER(*nextchar);
for (banned_node = ban_list; banned_node; banned_node = banned_node->next)
if (strstr(hostname, banned_node->site)) /* if hostname is a substring */
i = MAX(i, banned_node->type);
return (i);
}
void _write_one_node(FILE *fp, struct ban_list_element *node)
{
if (node) {
_write_one_node(fp, node->next);
fprintf(fp, "%s %s %ld %s\n", ban_types[node->type],
node->site, (long) node->date, node->name);
}
}
void write_ban_list(void)
{
FILE *fl;
if (!(fl = fopen(BAN_FILE, "w"))) {
perror("SYSERR: Unable to open '" BAN_FILE "' for writing");
return;
}
_write_one_node(fl, ban_list);/* recursively write from end to start */
fclose(fl);
return;
}
#define BAN_LIST_FORMAT "%-25.25s %-8.8s %-10.10s %-16.16s\r\n"
ACMD(do_ban)
{
char flag[MAX_INPUT_LENGTH], site[MAX_INPUT_LENGTH], *nextchar;
char timestr[16];
int i;
struct ban_list_element *ban_node;
if (!*argument) {
if (!ban_list) {
send_to_char(ch, "No sites are banned.\r\n");
return;
}
send_to_char(ch, BAN_LIST_FORMAT,
"Banned Site Name",
"Ban Type",
"Banned On",
"Banned By");
send_to_char(ch, BAN_LIST_FORMAT,
"---------------------------------",
"---------------------------------",
"---------------------------------",
"---------------------------------");
for (ban_node = ban_list; ban_node; ban_node = ban_node->next) {
if (ban_node->date) {
strlcpy(timestr, asctime(localtime(&(ban_node->date))), 10);
timestr[10] = '\0';
} else
strcpy(timestr, "Unknown"); /* strcpy: OK (strlen("Unknown") < 16) */
send_to_char(ch, BAN_LIST_FORMAT, ban_node->site, ban_types[ban_node->type], timestr, ban_node->name);
}
return;
}
two_arguments(argument, flag, site);
if (!*site || !*flag) {
send_to_char(ch, "Usage: ban {all | select | new} site_name\r\n");
return;
}
if (!(!str_cmp(flag, "select") || !str_cmp(flag, "all") || !str_cmp(flag, "new"))) {
send_to_char(ch, "Flag must be ALL, SELECT, or NEW.\r\n");
return;
}
for (ban_node = ban_list; ban_node; ban_node = ban_node->next) {
if (!str_cmp(ban_node->site, site)) {
send_to_char(ch, "That site has already been banned -- unban it to change the ban type.\r\n");
return;
}
}
CREATE(ban_node, struct ban_list_element, 1);
strncpy(ban_node->site, site, BANNED_SITE_LENGTH); /* strncpy: OK (b_n->site:BANNED_SITE_LENGTH+1) */
for (nextchar = ban_node->site; *nextchar; nextchar++)
*nextchar = LOWER(*nextchar);
ban_node->site[BANNED_SITE_LENGTH] = '\0';
strncpy(ban_node->name, GET_NAME(ch), MAX_NAME_LENGTH); /* strncpy: OK (b_n->size:MAX_NAME_LENGTH+1) */
ban_node->name[MAX_NAME_LENGTH] = '\0';
ban_node->date = time(0);
for (i = BAN_NEW; i <= BAN_ALL; i++)
if (!str_cmp(flag, ban_types[i]))
ban_node->type = i;
ban_node->next = ban_list;
ban_list = ban_node;
mudlog(NRM, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE, "%s has banned %s for %s players.",
GET_NAME(ch), site, ban_types[ban_node->type]);
send_to_char(ch, "Site banned.\r\n");
write_ban_list();
}
#undef BAN_LIST_FORMAT
ACMD(do_unban)
{
char site[MAX_INPUT_LENGTH];
struct ban_list_element *ban_node, *temp;
int found = 0;
one_argument(argument, site);
if (!*site) {
send_to_char(ch, "A site to unban might help.\r\n");
return;
}
ban_node = ban_list;
while (ban_node && !found) {
if (!str_cmp(ban_node->site, site))
found = 1;
else
ban_node = ban_node->next;
}
if (!found) {
send_to_char(ch, "That site is not currently banned.\r\n");
return;
}
REMOVE_FROM_LIST(ban_node, ban_list, next);
send_to_char(ch, "Site unbanned.\r\n");
mudlog(NRM, MAX(LVL_GOD, GET_INVIS_LEV(ch)), TRUE, "%s removed the %s-player ban on %s.",
GET_NAME(ch), ban_types[ban_node->type], ban_node->site);
free(ban_node);
write_ban_list();
}
/**************************************************************************
* Code to check for invalid names (i.e., profanity, etc.) *
* Written by Sharon P. Goza *
**************************************************************************/
#define MAX_INVALID_NAMES 200
char *invalid_list[MAX_INVALID_NAMES];
int num_invalid = 0;
int Valid_Name(char *newname)
{
int i, wovels = 0;
struct descriptor_data *dt;
char tempname[MAX_INPUT_LENGTH];
/*
* Make sure someone isn't trying to create this same name. We want to
* do a 'str_cmp' so people can't do 'Bob' and 'BoB'. The creating login
* will not have a character name yet and other people sitting at the
* prompt won't have characters yet.
*
* New, unindexed characters (i.e., characters who are in the process of creating)
* will have an idnum of -1, set by clear_char() in db.c. If someone is creating a
* character by the same name as the one we are checking, then the name is invalid,
* to prevent character duping.
* THIS SHOULD FIX THE 'invalid name' if disconnected from OLC-bug - WELCOR 9/00
*/
for (dt = descriptor_list; dt; dt = dt->next)
if (dt->character && GET_NAME(dt->character) && !str_cmp(GET_NAME(dt->character), newname))
if (GET_IDNUM(dt->character) == -1)
return (IS_PLAYING(dt));
/* count wovels */
for (i = 0; newname[i]; i++) {
if (strchr("aeiouyAEIOUY", newname[i]))
wovels++;
}
/* return invalid if no wovels */
if (!wovels)
return (0);
/* return valid if list doesn't exist */
if (!invalid_list || num_invalid < 1)
return (1);
/* change to lowercase */
strlcpy(tempname, newname, sizeof(tempname));
for (i = 0; tempname[i]; i++)
tempname[i] = LOWER(tempname[i]);
/* Does the desired name contain a string in the invalid list? */
for (i = 0; i < num_invalid; i++)
if (strstr(tempname, invalid_list[i]))
return (0);
return (1);
}
/* What's with the wacky capitalization in here? */
void Free_Invalid_List(void)
{
int invl;
for (invl = 0; invl < num_invalid; invl++)
free(invalid_list[invl]);
num_invalid = 0;
}
void Read_Invalid_List(void)
{
FILE *fp;
char temp[256];
if (!(fp = fopen(XNAME_FILE, "r"))) {
perror("SYSERR: Unable to open '" XNAME_FILE "' for reading");
return;
}
num_invalid = 0;
while (get_line(fp, temp) && num_invalid < MAX_INVALID_NAMES)
invalid_list[num_invalid++] = strdup(temp);
if (num_invalid >= MAX_INVALID_NAMES) {
log("SYSERR: Too many invalid names; change MAX_INVALID_NAMES in ban.c");
exit(1);
}
fclose(fp);
}

553
src/boards.c Normal file
View file

@ -0,0 +1,553 @@
/* ************************************************************************
* File: boards.c Part of CircleMUD *
* Usage: handling of multiple bulletin boards *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
/* FEATURES & INSTALLATION INSTRUCTIONS ***********************************
This board code has many improvements over the infamously buggy standard
Diku board code. Features include:
- 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.
- Safe removal of messages while other messages are being written.
- Does not allow messages to be removed by someone of a level less than
the poster's level.
TO ADD A NEW BOARD, simply follow our easy 4-step program:
1 - Create a new board object in the object files
2 - Increase the NUM_OF_BOARDS constant in boards.h
3 - Add a new line to the board_info array below. The fields, in order, are:
Board's virtual number.
Min level one must be to look at this board or read messages on it.
Min level one must be to post a message to the board.
Min level one must be to remove other people's messages from this
board (but you can always remove your own message).
Filename of this board, in quotes.
Last field must always be 0.
4 - In spec_assign.c, find the section which assigns the special procedure
gen_board to the other bulletin boards, and add your new one in a
similar fashion.
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "boards.h"
#include "interpreter.h"
#include "handler.h"
#include "improved-edit.h"
/* Board appearance order. */
#define NEWEST_AT_TOP FALSE
/*
format: vnum, read lvl, write lvl, remove lvl, filename, 0 at end
Be sure to also change NUM_OF_BOARDS in board.h
*/
struct board_info_type board_info[NUM_OF_BOARDS] = {
{3099, 0, 0, LVL_GOD, LIB_ETC "board.mortal", 0},
{3098, LVL_IMMORT, LVL_IMMORT, LVL_GRGOD, LIB_ETC "board.immortal", 0},
{3097, LVL_IMMORT, LVL_FREEZE, LVL_IMPL, LIB_ETC "board.freeze", 0},
{3096, 0, 0, LVL_IMMORT, LIB_ETC "board.social", 0},
{1226, 0, 0, LVL_IMPL, LIB_ETC "board.builder", 0},
{1227, 0, 0, LVL_IMPL, LIB_ETC "board.staff", 0},
{1228, 0, 0, LVL_IMPL, LIB_ETC "board.advertising", 0},
};
/* local functions */
SPECIAL(gen_board);
int find_slot(void);
int find_board(struct char_data *ch);
void init_boards(void);
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];
int find_slot(void)
{
int i;
for (i = 0; i < INDEX_SIZE; i++)
if (!msg_storage_taken[i]) {
msg_storage_taken[i] = 1;
return (i);
}
return (-1);
}
/* search the room ch is standing in to find which board he's looking at */
int find_board(struct char_data *ch)
{
struct obj_data *obj;
int i;
for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content)
for (i = 0; i < NUM_OF_BOARDS; i++)
if (BOARD_RNUM(i) == GET_OBJ_RNUM(obj))
return (i);
if (GET_LEVEL(ch) >= LVL_IMMORT)
for (obj = ch->carrying; obj; obj = obj->next_content)
for (i = 0; i < NUM_OF_BOARDS; i++)
if (BOARD_RNUM(i) == GET_OBJ_RNUM(obj))
return (i);
return (-1);
}
void init_boards(void)
{
int i, j, fatal_error = 0;
for (i = 0; i < INDEX_SIZE; i++) {
msg_storage[i] = 0;
msg_storage_taken[i] = 0;
}
for (i = 0; i < NUM_OF_BOARDS; i++) {
if ((BOARD_RNUM(i) = real_object(BOARD_VNUM(i))) == NOTHING) {
log("SYSERR: Fatal board error: board vnum %d does not exist!",
BOARD_VNUM(i));
fatal_error = 1;
}
num_of_msgs[i] = 0;
for (j = 0; j < MAX_BOARD_MESSAGES; j++) {
memset((char *) &(msg_index[i][j]), 0, sizeof(struct board_msginfo));
msg_index[i][j].slot_num = -1;
}
Board_load_board(i);
}
// if (fatal_error)
// exit(1);
}
SPECIAL(gen_board)
{
int board_type;
static int loaded = 0;
struct obj_data *board = (struct obj_data *)me;
if (!loaded) {
init_boards();
loaded = 1;
}
if (!ch->desc)
return (0);
ACMD_READ = find_command("read");
ACMD_WRITE = find_command("write");
ACMD_REMOVE = find_command("remove");
ACMD_LOOK = find_command("look");
ACMD_EXAMINE = find_command("examine");
if (cmd != ACMD_WRITE && cmd != ACMD_LOOK && cmd != ACMD_EXAMINE &&
cmd != ACMD_READ && cmd != ACMD_REMOVE)
return (0);
if ((board_type = find_board(ch)) == -1) {
log("SYSERR: degenerate board! (what the hell...)");
return (0);
}
if (cmd == ACMD_WRITE)
return (Board_write_message(board_type, ch, argument, board));
else if (cmd == ACMD_LOOK || cmd == ACMD_EXAMINE)
return (Board_show_board(board_type, ch, argument, board));
else if (cmd == ACMD_READ)
return (Board_display_msg(board_type, ch, argument, board));
else if (cmd == ACMD_REMOVE)
return (Board_remove_msg(board_type, ch, argument, board));
else
return (0);
}
int Board_write_message(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
char *tmstr;
time_t ct;
char buf[MAX_INPUT_LENGTH], buf2[MAX_NAME_LENGTH + 3];
if (GET_LEVEL(ch) < WRITE_LVL(board_type)) {
send_to_char(ch, "You are not holy enough to write on this board.\r\n");
return (1);
}
if (num_of_msgs[board_type] >= MAX_BOARD_MESSAGES) {
send_to_char(ch, "The board is full.\r\n");
return (1);
}
if ((NEW_MSG_INDEX(board_type).slot_num = find_slot()) == -1) {
send_to_char(ch, "The board is malfunctioning - sorry.\r\n");
log("SYSERR: Board: failed to find empty slot on write.");
return (1);
}
/* skip blanks */
skip_spaces(&arg);
delete_doubledollar(arg);
/* JE 27 Oct 95 - Truncate headline at 80 chars if it's longer than that */
arg[80] = '\0';
if (!*arg) {
send_to_char(ch, "We must have a headline!\r\n");
return (1);
}
ct = time(0);
tmstr = (char *) asctime(localtime(&ct));
*(tmstr + strlen(tmstr) - 1) = '\0';
snprintf(buf2, sizeof(buf2), "(%s)", GET_NAME(ch));
snprintf(buf, sizeof(buf), "%6.10s %-12s :: %s", tmstr, buf2, arg);
NEW_MSG_INDEX(board_type).heading = strdup(buf);
NEW_MSG_INDEX(board_type).level = GET_LEVEL(ch);
send_to_char(ch, "Write your message.\r\n");
send_editor_help(ch->desc);
act("$n starts to write a message.", TRUE, ch, 0, 0, TO_ROOM);
string_write(ch->desc, &(msg_storage[NEW_MSG_INDEX(board_type).slot_num]),
MAX_MESSAGE_LENGTH, board_type + BOARD_MAGIC, NULL);
num_of_msgs[board_type]++;
return (1);
}
int Board_show_board(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
int i;
char tmp[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];
if (!ch->desc)
return (0);
one_argument(arg, tmp);
if (!*tmp || !isname(tmp, board->name))
return (0);
if (GET_LEVEL(ch) < READ_LVL(board_type)) {
send_to_char(ch, "You try but fail to understand the holy words.\r\n");
return (1);
}
act("$n studies the board.", TRUE, ch, 0, 0, TO_ROOM);
if (!num_of_msgs[board_type])
send_to_char(ch, "This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\nThe board is empty.\r\n");
else {
size_t len = 0;
int nlen;
len = snprintf(buf, sizeof(buf),
"This is a bulletin board. Usage: READ/REMOVE <messg #>, WRITE <header>.\r\n"
"You will need to look at the board to save your message.\r\n"
"There are %d messages on the board.\r\n",
num_of_msgs[board_type]);
#if NEWEST_AT_TOP
for (i = num_of_msgs[board_type] - 1; i >= 0; i--) {
if (!MSG_HEADING(board_type, i))
goto fubar;
nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", num_of_msgs[board_type] - i, MSG_HEADING(board_type, i));
if (len + nlen >= sizeof(buf) || nlen < 0)
break;
len += nlen;
}
#else
for (i = 0; i < num_of_msgs[board_type]; i++) {
if (!MSG_HEADING(board_type, i))
goto fubar;
nlen = snprintf(buf + len, sizeof(buf) - len, "%-2d : %s\r\n", i + 1, MSG_HEADING(board_type, i));
if (len + nlen >= sizeof(buf) || nlen < 0)
break;
len += nlen;
}
#endif
page_string(ch->desc, buf, TRUE);
}
return (1);
fubar:
log("SYSERR: Board %d is fubar'd.", board_type);
send_to_char(ch, "Sorry, the board isn't working.\r\n");
return (1);
}
int Board_display_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
char number[MAX_INPUT_LENGTH], buffer[MAX_STRING_LENGTH];
int msg, ind;
one_argument(arg, number);
if (!*number)
return (0);
if (isname(number, board->name)) /* so "read board" works */
return (Board_show_board(board_type, ch, arg, board));
if (!is_number(number)) /* read 2.mail, look 2.sword */
return (0);
if (!(msg = atoi(number)))
return (0);
if (GET_LEVEL(ch) < READ_LVL(board_type)) {
send_to_char(ch, "You try but fail to understand the holy words.\r\n");
return (1);
}
if (!num_of_msgs[board_type]) {
send_to_char(ch, "The board is empty!\r\n");
return (1);
}
if (msg < 1 || msg > num_of_msgs[board_type]) {
send_to_char(ch, "That message exists only in your imagination.\r\n");
return (1);
}
#if NEWEST_AT_TOP
ind = num_of_msgs[board_type] - msg;
#else
ind = msg - 1;
#endif
if (MSG_SLOTNUM(board_type, ind) < 0 ||
MSG_SLOTNUM(board_type, ind) >= INDEX_SIZE) {
send_to_char(ch, "Sorry, the board is not working.\r\n");
log("SYSERR: Board is screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch)));
return (1);
}
if (!(MSG_HEADING(board_type, ind))) {
send_to_char(ch, "That message appears to be screwed up.\r\n");
return (1);
}
if (!(msg_storage[MSG_SLOTNUM(board_type, ind)])) {
send_to_char(ch, "That message seems to be empty.\r\n");
return (1);
}
snprintf(buffer, sizeof(buffer), "Message %d : %s\r\n\r\n%s\r\n", msg,
MSG_HEADING(board_type, ind),
msg_storage[MSG_SLOTNUM(board_type, ind)]);
page_string(ch->desc, buffer, TRUE);
return (1);
}
int Board_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
int ind, msg, slot_num;
char number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
struct descriptor_data *d;
one_argument(arg, number);
if (!*number || !is_number(number))
return (0);
if (!(msg = atoi(number)))
return (0);
if (!num_of_msgs[board_type]) {
send_to_char(ch, "The board is empty!\r\n");
return (1);
}
if (msg < 1 || msg > num_of_msgs[board_type]) {
send_to_char(ch, "That message exists only in your imagination.\r\n");
return (1);
}
#if NEWEST_AT_TOP
ind = num_of_msgs[board_type] - msg;
#else
ind = msg - 1;
#endif
if (!MSG_HEADING(board_type, ind)) {
send_to_char(ch, "That message appears to be screwed up.\r\n");
return (1);
}
snprintf(buf, sizeof(buf), "(%s)", GET_NAME(ch));
if (GET_LEVEL(ch) < REMOVE_LVL(board_type) &&
!(strstr(MSG_HEADING(board_type, ind), buf))) {
send_to_char(ch, "You are not holy enough to remove other people's messages.\r\n");
return (1);
}
if (GET_LEVEL(ch) < MSG_LEVEL(board_type, ind)) {
send_to_char(ch, "You can't remove a message holier than yourself.\r\n");
return (1);
}
slot_num = MSG_SLOTNUM(board_type, ind);
if (slot_num < 0 || slot_num >= INDEX_SIZE) {
send_to_char(ch, "That message is majorly screwed up.\r\n");
log("SYSERR: The board is seriously screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch)));
return (1);
}
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_PLAYING && d->str == &(msg_storage[slot_num])) {
send_to_char(ch, "At least wait until the author is finished before removing it!\r\n");
return (1);
}
if (msg_storage[slot_num])
free(msg_storage[slot_num]);
msg_storage[slot_num] = 0;
msg_storage_taken[slot_num] = 0;
if (MSG_HEADING(board_type, ind))
free(MSG_HEADING(board_type, ind));
for (; ind < num_of_msgs[board_type] - 1; ind++) {
MSG_HEADING(board_type, ind) = MSG_HEADING(board_type, ind + 1);
MSG_SLOTNUM(board_type, ind) = MSG_SLOTNUM(board_type, ind + 1);
MSG_LEVEL(board_type, ind) = MSG_LEVEL(board_type, ind + 1);
}
num_of_msgs[board_type]--;
send_to_char(ch, "Message removed.\r\n");
snprintf(buf, sizeof(buf), "$n just removed message %d.", msg);
act(buf, FALSE, ch, 0, 0, TO_ROOM);
Board_save_board(board_type);
return (1);
}
void Board_save_board(int board_type)
{
FILE *fl;
int i;
char *tmp1, *tmp2 = NULL;
if (!num_of_msgs[board_type]) {
remove(FILENAME(board_type));
return;
}
if (!(fl = fopen(FILENAME(board_type), "wb"))) {
perror("SYSERR: Error writing board");
return;
}
fwrite(&(num_of_msgs[board_type]), sizeof(int), 1, fl);
for (i = 0; i < num_of_msgs[board_type]; i++) {
if ((tmp1 = MSG_HEADING(board_type, i)) != NULL)
msg_index[board_type][i].heading_len = strlen(tmp1) + 1;
else
msg_index[board_type][i].heading_len = 0;
if (MSG_SLOTNUM(board_type, i) < 0 ||
MSG_SLOTNUM(board_type, i) >= INDEX_SIZE ||
(!(tmp2 = msg_storage[MSG_SLOTNUM(board_type, i)])))
msg_index[board_type][i].message_len = 0;
else
msg_index[board_type][i].message_len = strlen(tmp2) + 1;
fwrite(&(msg_index[board_type][i]), sizeof(struct board_msginfo), 1, fl);
if (tmp1)
fwrite(tmp1, sizeof(char), msg_index[board_type][i].heading_len, fl);
if (tmp2)
fwrite(tmp2, sizeof(char), msg_index[board_type][i].message_len, fl);
}
fclose(fl);
}
void Board_load_board(int board_type)
{
FILE *fl;
int i, len1, len2;
char *tmp1, *tmp2;
if (!(fl = fopen(FILENAME(board_type), "rb"))) {
if (errno != ENOENT)
perror("SYSERR: Error reading board");
return;
}
fread(&(num_of_msgs[board_type]), sizeof(int), 1, fl);
if (num_of_msgs[board_type] < 1 || num_of_msgs[board_type] > MAX_BOARD_MESSAGES) {
log("SYSERR: Board file %d corrupt. Resetting.", board_type);
Board_reset_board(board_type);
return;
}
for (i = 0; i < num_of_msgs[board_type]; i++) {
fread(&(msg_index[board_type][i]), sizeof(struct board_msginfo), 1, fl);
if ((len1 = msg_index[board_type][i].heading_len) <= 0) {
log("SYSERR: Board file %d corrupt! Resetting.", board_type);
Board_reset_board(board_type);
return;
}
CREATE(tmp1, char, len1);
fread(tmp1, sizeof(char), len1, fl);
MSG_HEADING(board_type, i) = tmp1;
if ((MSG_SLOTNUM(board_type, i) = find_slot()) == -1) {
log("SYSERR: Out of slots booting board %d! Resetting...", board_type);
Board_reset_board(board_type);
return;
}
if ((len2 = msg_index[board_type][i].message_len) > 0) {
CREATE(tmp2, char, len2);
fread(tmp2, sizeof(char), len2, fl);
msg_storage[MSG_SLOTNUM(board_type, i)] = tmp2;
} else
msg_storage[MSG_SLOTNUM(board_type, i)] = NULL;
}
fclose(fl);
}
/* When shutting down, clear all boards. */
void Board_clear_all(void)
{
int i;
for (i = 0; i < NUM_OF_BOARDS; i++)
Board_clear_board(i);
}
/* Clear the in-memory structures. */
void Board_clear_board(int board_type)
{
int i;
for (i = 0; i < MAX_BOARD_MESSAGES; i++) {
if (MSG_HEADING(board_type, i))
free(MSG_HEADING(board_type, i));
if (msg_storage[MSG_SLOTNUM(board_type, i)])
free(msg_storage[MSG_SLOTNUM(board_type, i)]);
msg_storage_taken[MSG_SLOTNUM(board_type, i)] = 0;
memset((char *)&(msg_index[board_type][i]),0,sizeof(struct board_msginfo));
msg_index[board_type][i].slot_num = -1;
}
num_of_msgs[board_type] = 0;
}
/* Destroy the on-disk and in-memory board. */
void Board_reset_board(int board_type)
{
Board_clear_board(board_type);
remove(FILENAME(board_type));
}

56
src/boards.h Normal file
View file

@ -0,0 +1,56 @@
/* ************************************************************************
* File: boards.h Part of CircleMUD *
* Usage: header file for bulletin boards *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#define NUM_OF_BOARDS 10 /* change if needed! */
#define MAX_BOARD_MESSAGES 60 /* arbitrary -- change if needed */
#define MAX_MESSAGE_LENGTH 4096 /* arbitrary -- change if needed */
#define INDEX_SIZE ((NUM_OF_BOARDS*MAX_BOARD_MESSAGES) + 5)
#define BOARD_MAGIC 1048575 /* arbitrary number - see modify.c */
struct board_msginfo {
int slot_num; /* pos of message in "master index" */
char *heading; /* pointer to message's heading */
int level; /* level of poster */
int heading_len; /* size of header (for file write) */
int message_len; /* size of message text (for file write) */
};
struct board_info_type {
obj_vnum vnum; /* vnum of this board */
int read_lvl; /* min level to read messages on this board */
int write_lvl; /* min level to write messages on this board */
int remove_lvl; /* min level to remove messages from this board */
char filename[50]; /* file to save this board to */
obj_rnum rnum; /* rnum of this board */
};
#define BOARD_VNUM(i) (board_info[i].vnum)
#define READ_LVL(i) (board_info[i].read_lvl)
#define WRITE_LVL(i) (board_info[i].write_lvl)
#define REMOVE_LVL(i) (board_info[i].remove_lvl)
#define FILENAME(i) (board_info[i].filename)
#define BOARD_RNUM(i) (board_info[i].rnum)
#define NEW_MSG_INDEX(i) (msg_index[i][num_of_msgs[i]])
#define MSG_HEADING(i, j) (msg_index[i][j].heading)
#define MSG_SLOTNUM(i, j) (msg_index[i][j].slot_num)
#define MSG_LEVEL(i, j) (msg_index[i][j].level)
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_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board);
int Board_write_message(int board_type, struct char_data *ch, char *arg, struct obj_data *board);
void Board_save_board(int board_type);
void Board_load_board(int board_type);
void Board_reset_board(int board_type);
void Board_clear_board(int board_type);
void Board_clear_all(void);

782
src/bsd-snprintf.c Normal file
View file

@ -0,0 +1,782 @@
/*
* This file taken from openbsd-compat of OpenSSH 3.1. It is only used
* if your operating system does not provide snprintf() or vsnprintf().
*
* --- 8< --- OpenSSH LICENSE --- 8< ---
* Remaining components of the software are provided under a standard
* 2-term BSD licence with the following names as copyright holders:
*
* Markus Friedl
* Theo de Raadt
* Niels Provos
* Dug Song
* Aaron Campbell
* Damien Miller
* Kevin Steves
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --- 8< --- OpenSSH LICENSE --- 8< ---
*/
/**************************************************************
* Original:
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
* A bombproof version of doprnt (dopr) included.
* Sigh. This sort of thing is always nasty do deal with. Note that
* the version here does not include floating point...
*
* snprintf() is used instead of sprintf() as it does limit checks
* for string length. This covers a nasty loophole.
*
* The other functions are there to prevent NULL pointers from
* causing nast effects.
*
* More Recently:
* Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43
* This was ugly. It is still ugly. I opted out of floating point
* numbers, but the formatter understands just about everything
* from the normal C string format, at least as far as I can tell from
* the Solaris 2.5 printf(3S) man page.
*
* Brandon Long <blong@fiction.net> 10/22/97 for mutt 0.87.1
* Ok, added some minimal floating point support, which means this
* probably requires libm on most operating systems. Don't yet
* support the exponent (e,E) and sigfig (g,G). Also, fmtint()
* was pretty badly broken, it just wasn't being exercised in ways
* which showed it, so that's been fixed. Also, formated the code
* to mutt conventions, and removed dead code left over from the
* original. Also, there is now a builtin-test, just compile with:
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
* and run snprintf for results.
*
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
* The PGP code was using unsigned hexadecimal formats.
* Unfortunately, unsigned formats simply didn't work.
*
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
* The original code assumed that both snprintf() and vsnprintf() were
* missing. Some systems only have snprintf() but not vsnprintf(), so
* the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
*
* Ben Lindstrom <mouring@eviladmin.org> 09/27/00 for OpenSSH
* Welcome to the world of %lld and %qd support. With other
* long long support. This is needed for sftp-server to work
* right.
*
* Ben Lindstrom <mouring@eviladmin.org> 02/12/01 for OpenSSH
* Removed all hint of VARARGS stuff and banished it to the void,
* and did a bit of KNF style work to make things a bit more
* acceptable. Consider stealing from mutt or enlightenment.
**************************************************************/
# include "conf.h"
# include "sysdep.h"
# define MAX(a, b) ((a) < (b) ? (b) : (a))
#if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#endif
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
static void
dopr(char *buffer, size_t maxlen, const char *format, va_list args);
static void
fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags,
int min, int max);
static void
fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base,
int min, int max, int flags);
static void
fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue,
int min, int max, int flags);
static void
dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
/*
* dopr(): poor man's version of doprintf
*/
/* format read states */
#define DP_S_DEFAULT 0
#define DP_S_FLAGS 1
#define DP_S_MIN 2
#define DP_S_DOT 3
#define DP_S_MAX 4
#define DP_S_MOD 5
#define DP_S_CONV 6
#define DP_S_DONE 7
/* format flags - Bits */
#define DP_F_MINUS (1 << 0)
#define DP_F_PLUS (1 << 1)
#define DP_F_SPACE (1 << 2)
#define DP_F_NUM (1 << 3)
#define DP_F_ZERO (1 << 4)
#define DP_F_UP (1 << 5)
#define DP_F_UNSIGNED (1 << 6)
/* Conversion Flags */
#define DP_C_SHORT 1
#define DP_C_LONG 2
#define DP_C_LDOUBLE 3
#define DP_C_LONG_LONG 4
#define char_to_int(p) (p - '0')
#define abs_val(p) (p < 0 ? -p : p)
static void
dopr(char *buffer, size_t maxlen, const char *format, va_list args)
{
char *strvalue;
char ch;
long value;
long double fvalue;
int min = 0;
int max = -1;
int state = DP_S_DEFAULT;
int flags = 0;
int cflags = 0;
size_t currlen = 0;
ch = *format++;
while (state != DP_S_DONE) {
if ((ch == '\0') || (currlen >= maxlen))
state = DP_S_DONE;
switch(state) {
case DP_S_DEFAULT:
if (ch == '%')
state = DP_S_FLAGS;
else
dopr_outch(buffer, &currlen, maxlen, ch);
ch = *format++;
break;
case DP_S_FLAGS:
switch (ch) {
case '-':
flags |= DP_F_MINUS;
ch = *format++;
break;
case '+':
flags |= DP_F_PLUS;
ch = *format++;
break;
case ' ':
flags |= DP_F_SPACE;
ch = *format++;
break;
case '#':
flags |= DP_F_NUM;
ch = *format++;
break;
case '0':
flags |= DP_F_ZERO;
ch = *format++;
break;
default:
state = DP_S_MIN;
break;
}
break;
case DP_S_MIN:
if (isdigit((unsigned char)ch)) {
min = 10*min + char_to_int (ch);
ch = *format++;
} else if (ch == '*') {
min = va_arg (args, int);
ch = *format++;
state = DP_S_DOT;
} else
state = DP_S_DOT;
break;
case DP_S_DOT:
if (ch == '.') {
state = DP_S_MAX;
ch = *format++;
} else
state = DP_S_MOD;
break;
case DP_S_MAX:
if (isdigit((unsigned char)ch)) {
if (max < 0)
max = 0;
max = 10*max + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
max = va_arg (args, int);
ch = *format++;
state = DP_S_MOD;
} else
state = DP_S_MOD;
break;
case DP_S_MOD:
switch (ch) {
case 'h':
cflags = DP_C_SHORT;
ch = *format++;
break;
case 'l':
cflags = DP_C_LONG;
ch = *format++;
if (ch == 'l') {
cflags = DP_C_LONG_LONG;
ch = *format++;
}
break;
case 'q':
cflags = DP_C_LONG_LONG;
ch = *format++;
break;
case 'L':
cflags = DP_C_LDOUBLE;
ch = *format++;
break;
default:
break;
}
state = DP_S_CONV;
break;
case DP_S_CONV:
switch (ch) {
case 'd':
case 'i':
if (cflags == DP_C_SHORT)
value = va_arg(args, int);
else if (cflags == DP_C_LONG)
value = va_arg(args, long int);
else if (cflags == DP_C_LONG_LONG)
value = va_arg (args, long long);
else
value = va_arg (args, int);
fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
break;
case 'o':
flags |= DP_F_UNSIGNED;
if (cflags == DP_C_SHORT)
value = va_arg(args, unsigned int);
else if (cflags == DP_C_LONG)
value = va_arg(args, unsigned long int);
else if (cflags == DP_C_LONG_LONG)
value = va_arg(args, unsigned long long);
else
value = va_arg(args, unsigned int);
fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags);
break;
case 'u':
flags |= DP_F_UNSIGNED;
if (cflags == DP_C_SHORT)
value = va_arg(args, unsigned int);
else if (cflags == DP_C_LONG)
value = va_arg(args, unsigned long int);
else if (cflags == DP_C_LONG_LONG)
value = va_arg(args, unsigned long long);
else
value = va_arg(args, unsigned int);
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
break;
case 'X':
flags |= DP_F_UP;
case 'x':
flags |= DP_F_UNSIGNED;
if (cflags == DP_C_SHORT)
value = va_arg(args, unsigned int);
else if (cflags == DP_C_LONG)
value = va_arg(args, unsigned long int);
else if (cflags == DP_C_LONG_LONG)
value = va_arg(args, unsigned long long);
else
value = va_arg(args, unsigned int);
fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags);
break;
case 'f':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, long double);
else
fvalue = va_arg(args, double);
/* um, floating point? */
fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags);
break;
case 'E':
flags |= DP_F_UP;
case 'e':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, long double);
else
fvalue = va_arg(args, double);
break;
case 'G':
flags |= DP_F_UP;
case 'g':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, long double);
else
fvalue = va_arg(args, double);
break;
case 'c':
dopr_outch(buffer, &currlen, maxlen, va_arg(args, int));
break;
case 's':
strvalue = va_arg(args, char *);
if (max < 0)
max = maxlen; /* ie, no max */
fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max);
break;
case 'p':
strvalue = va_arg(args, void *);
fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
break;
case 'n':
if (cflags == DP_C_SHORT) {
short int *num;
num = va_arg(args, short int *);
*num = currlen;
} else if (cflags == DP_C_LONG) {
long int *num;
num = va_arg(args, long int *);
*num = currlen;
} else if (cflags == DP_C_LONG_LONG) {
long long *num;
num = va_arg(args, long long *);
*num = currlen;
} else {
int *num;
num = va_arg(args, int *);
*num = currlen;
}
break;
case '%':
dopr_outch(buffer, &currlen, maxlen, ch);
break;
case 'w': /* not supported yet, treat as next char */
ch = *format++;
break;
default: /* Unknown, skip */
break;
}
ch = *format++;
state = DP_S_DEFAULT;
flags = cflags = min = 0;
max = -1;
break;
case DP_S_DONE:
break;
default: /* hmm? */
break; /* some picky compilers need this */
}
}
if (currlen < maxlen - 1)
buffer[currlen] = '\0';
else
buffer[maxlen - 1] = '\0';
}
static void
fmtstr(char *buffer, size_t *currlen, size_t maxlen,
char *value, int flags, int min, int max)
{
int padlen, strln; /* amount to pad */
int cnt = 0;
if (value == 0)
value = "<NULL>";
for (strln = 0; value[strln]; ++strln); /* strlen */
padlen = min - strln;
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justify */
while ((padlen > 0) && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
++cnt;
}
while (*value && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, *value++);
++cnt;
}
while ((padlen < 0) && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
++cnt;
}
}
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
static void
fmtint(char *buffer, size_t *currlen, size_t maxlen,
long value, int base, int min, int max, int flags)
{
unsigned long uvalue;
char convert[20];
int signvalue = 0;
int place = 0;
int spadlen = 0; /* amount to space pad */
int zpadlen = 0; /* amount to zero pad */
int caps = 0;
if (max < 0)
max = 0;
uvalue = value;
if (!(flags & DP_F_UNSIGNED)) {
if (value < 0) {
signvalue = '-';
uvalue = -value;
} else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
signvalue = '+';
else if (flags & DP_F_SPACE)
signvalue = ' ';
}
if (flags & DP_F_UP)
caps = 1; /* Should characters be upper case? */
do {
convert[place++] =
(caps? "0123456789ABCDEF":"0123456789abcdef")
[uvalue % (unsigned)base];
uvalue = (uvalue / (unsigned)base );
} while (uvalue && (place < 20));
if (place == 20)
place--;
convert[place] = 0;
zpadlen = max - place;
spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
if (zpadlen < 0)
zpadlen = 0;
if (spadlen < 0)
spadlen = 0;
if (flags & DP_F_ZERO) {
zpadlen = MAX(zpadlen, spadlen);
spadlen = 0;
}
if (flags & DP_F_MINUS)
spadlen = -spadlen; /* Left Justifty */
/* Spaces */
while (spadlen > 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
--spadlen;
}
/* Sign */
if (signvalue)
dopr_outch(buffer, currlen, maxlen, signvalue);
/* Zeros */
if (zpadlen > 0) {
while (zpadlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
}
/* Digits */
while (place > 0)
dopr_outch(buffer, currlen, maxlen, convert[--place]);
/* Left Justified spaces */
while (spadlen < 0) {
dopr_outch (buffer, currlen, maxlen, ' ');
++spadlen;
}
}
static long double
pow10(int exp)
{
long double result = 1;
while (exp) {
result *= 10;
exp--;
}
return result;
}
static long
round(long double value)
{
long intpart = value;
value -= intpart;
if (value >= 0.5)
intpart++;
return intpart;
}
static void
fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue,
int min, int max, int flags)
{
char iconvert[20];
char fconvert[20];
int signvalue = 0;
int iplace = 0;
int fplace = 0;
int padlen = 0; /* amount to pad */
int zpadlen = 0;
int caps = 0;
long intpart;
long fracpart;
long double ufvalue;
/*
* AIX manpage says the default is 0, but Solaris says the default
* is 6, and sprintf on AIX defaults to 6
*/
if (max < 0)
max = 6;
ufvalue = abs_val(fvalue);
if (fvalue < 0)
signvalue = '-';
else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
signvalue = '+';
else if (flags & DP_F_SPACE)
signvalue = ' ';
intpart = ufvalue;
/*
* Sorry, we only support 9 digits past the decimal because of our
* conversion method
*/
if (max > 9)
max = 9;
/* We "cheat" by converting the fractional part to integer by
* multiplying by a factor of 10
*/
fracpart = round((pow10 (max)) * (ufvalue - intpart));
if (fracpart >= pow10 (max)) {
intpart++;
fracpart -= pow10 (max);
}
/* Convert integer part */
do {
iconvert[iplace++] =
(caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
} while(intpart && (iplace < 20));
if (iplace == 20)
iplace--;
iconvert[iplace] = 0;
/* Convert fractional part */
do {
fconvert[fplace++] =
(caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while(fracpart && (fplace < 20));
if (fplace == 20)
fplace--;
fconvert[fplace] = 0;
/* -1 for decimal point, another -1 if we are printing a sign */
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
zpadlen = max - fplace;
if (zpadlen < 0)
zpadlen = 0;
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justifty */
if ((flags & DP_F_ZERO) && (padlen > 0)) {
if (signvalue) {
dopr_outch(buffer, currlen, maxlen, signvalue);
--padlen;
signvalue = 0;
}
while (padlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--padlen;
}
}
while (padlen > 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
}
if (signvalue)
dopr_outch(buffer, currlen, maxlen, signvalue);
while (iplace > 0)
dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
/*
* Decimal point. This should probably use locale to find the correct
* char to print out.
*/
dopr_outch(buffer, currlen, maxlen, '.');
while (fplace > 0)
dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
while (zpadlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
while (padlen < 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
}
}
static void
dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
{
if (*currlen < maxlen)
buffer[(*currlen)++] = c;
}
#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_VSNPRINTF
int
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
str[0] = 0;
dopr(str, count, fmt, args);
return(strlen(str));
}
#endif /* !HAVE_VSNPRINTF */
#ifndef HAVE_SNPRINTF
int
snprintf(char *str,size_t count,const char *fmt,...)
{
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(str, count, fmt, ap);
va_end(ap);
return(strlen(str));
}
#ifdef TEST_SNPRINTF
int
main(void)
{
#define LONG_STRING 1024
char buf1[LONG_STRING];
char buf2[LONG_STRING];
char *fp_fmt[] = {
"%-1.5f",
"%1.5f",
"%123.9f",
"%10.5f",
"% 10.5f",
"%+22.9f",
"%+4.9f",
"%01.3f",
"%4f",
"%3.1f",
"%3.2f",
NULL
};
double fp_nums[] = {
-1.5,
134.21,
91340.2,
341.1234,
0203.9,
0.96,
0.996,
0.9996,
1.996,
4.136,
0
};
char *int_fmt[] = {
"%-1.5d",
"%1.5d",
"%123.9d",
"%5.5d",
"%10.5d",
"% 10.5d",
"%+22.33d",
"%01.3d",
"%4d",
"%lld",
"%qd",
NULL
};
long long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 9999999 };
int x, y;
int fail = 0;
int num = 0;
printf("Testing snprintf format codes against system sprintf...\n");
for (x = 0; fp_fmt[x] != NULL ; x++) {
for (y = 0; fp_nums[y] != 0 ; y++) {
snprintf(buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
sprintf (buf2, fp_fmt[x], fp_nums[y]);
if (strcmp (buf1, buf2)) {
printf("snprintf doesn't match Format: %s\n\t"
"snprintf = %s\n\tsprintf = %s\n",
fp_fmt[x], buf1, buf2);
fail++;
}
num++;
}
}
for (x = 0; int_fmt[x] != NULL ; x++) {
for (y = 0; int_nums[y] != 0 ; y++) {
snprintf(buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
sprintf(buf2, int_fmt[x], int_nums[y]);
if (strcmp (buf1, buf2)) {
printf("snprintf doesn't match Format: %s\n\t"
"snprintf = %s\n\tsprintf = %s\n",
int_fmt[x], buf1, buf2);
fail++;
}
num++;
}
}
printf("%d tests failed out of %d.\n", fail, num);
return(0);
}
#endif /* SNPRINTF_TEST */
#endif /* !HAVE_SNPRINTF */

52
src/bsd-snprintf.h Normal file
View file

@ -0,0 +1,52 @@
/*
* This file taken from openbsd-compat of OpenSSH 3.1:
*
* --- 8< --- OpenSSH LICENSE --- 8< ---
* Remaining components of the software are provided under a standard
* 2-term BSD licence with the following names as copyright holders:
*
* Markus Friedl
* Theo de Raadt
* Niels Provos
* Dug Song
* Aaron Campbell
* Damien Miller
* Kevin Steves
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --- 8< --- OpenSSH LICENSE --- 8< ---
*/
/* $Id: bsd-snprintf.h,v 1.1 2002/04/16 02:22:12 greerga Exp $ */
#ifndef _BSD_SNPRINTF_H
#define _BSD_SNPRINTF_H
#ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t count, const char *fmt, ...);
#endif /* !HAVE_SNPRINTF */
#ifndef HAVE_VSNPRINTF
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif /* !HAVE_SNPRINTF */
#endif /* _BSD_SNPRINTF_H */

517
src/build_circlemud.com Executable file
View file

@ -0,0 +1,517 @@
$!
$! BUILD_CIRCLEMUD.COM
$! Written By: Robert Alan Byer
$! byer@mail.ourservers.net
$!
$! This script checks the file names and then compiles and links CircleMUD for
$! OpenVMS using DEC C and the DEC C TCP/IP socket routines.
$!
$! The script accepts the following parameters.
$!
$! P1 ALL Build Everything.
$! CIRCLE Just Build [-.BIN]CIRCLE.EXE.
$! UTILS Just Build The CircleMUD Utilities.
$!
$! P2 DEBUG Build With Debugger Information.
$! NODEBUG Build Withoug Debugger Information.
$!
$! The default is "ALL" and "NODEBUG".
$!
$! Check To Make Sure We Have Valid Command Line Parameters.
$!
$ GOSUB CHECK_OPTIONS
$!
$! Check To See If We Are On An AXP Machine.
$!
$ IF (F$GETSYI("CPU").LT.128)
$ THEN
$!
$! We Are On A VAX Machine So Tell The User.
$!
$ WRITE SYS$OUTPUT "Compiling On A VAX Machine."
$!
$! Else, We Are On An AXP Machine.
$!
$ ELSE
$!
$! We Are On A AXP Machine So Tell The User.
$!
$ WRITE SYS$OUTPUT "Compiling On A AXP Machine."
$!
$! End Of The Machine Check.
$!
$ ENDIF
$!
$! Check The CONF.H File.
$!
$ GOSUB CHECK_CONF_FILE
$!
$! Check Filenames.
$!
$ GOSUB CHECK_FILE_NAMES
$!
$! Check To See What We Are To Do.
$!
$ IF (BUILDALL.EQS."TRUE")
$ THEN
$!
$! Since Nothing Special Was Specified, Build Everything.
$!
$ GOSUB BUILD_CIRCLE
$ GOSUB BUILD_UTILS
$!
$! Else...
$!
$ ELSE
$!
$! Build Just What The User Wants Us To Build.
$!
$ GOSUB BUILD_'BUILDALL'
$!
$! Time To End The Build Check.
$!
$ ENDIF
$!
$! Time To EXIT.
$!
$ EXIT
$!
$! Build [-.BIN]CIRCLE.EXE
$!
$ BUILD_CIRCLE:
$!
$! Tell The User What We Are Doing.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "Compiling [-.BIN]CIRCLE.EXE"
$ WRITE SYS$OUTPUT ""
$!
$! Define The CIRCLE.EXE Files That Are Necessary.
$!
$ CIRCLE_FILES = "ACT_COMM,ACT_INFORMATIVE,ACT_ITEM,ACT_MOVEMENT," + -
"ACT_OFFENSIVE,ACT_OTHER,ACT_SOCIAL,ACT_WIZARD," + -
"ALIAS,BAN,BOARDS,CASTLE,CLASS,COMM,CONFIG," + -
"CONSTANTS,DB,FIGHT,GRAPH,HANDLER,HOUSE," + -
"INTERPRETER,LIMITS,MAGIC,MAIL,MOBACT,MODIFY," + -
"OBJSAVE,OLC,PLAYERS,RANDOM,SHOP,SPEC_ASSIGN," + -
"SPEC_PROCS,SPELLS,SPELL_PARSER,UTILS,WEATHER"
$!
$! Define A File Counter And Set It To "0".
$!
$ CIRCLE_FILE_COUNTER = 0
$!
$! Top Of The File Loop.
$!
$ NEXT_CIRCLE_FILE:
$!
$! O.K, Extract The File Name From The File List.
$!
$ CIRCLE_FILE_NAME = F$ELEMENT(CIRCLE_FILE_COUNTER,",",CIRCLE_FILES)
$!
$! Check To See If We Are At The End Of The File List.
$!
$ IF (CIRCLE_FILE_NAME.EQS.",") THEN GOTO CIRCLE_FILE_DONE
$!
$! Increment The Counter.
$!
$ CIRCLE_FILE_COUNTER = CIRCLE_FILE_COUNTER + 1
$!
$! Create The Source File Name.
$!
$ CIRCLE_SOURCE_FILE = "SYS$DISK:[]" + CIRCLE_FILE_NAME + ".C"
$!
$! Create The Object File Name.
$!
$ CIRCLE_OBJECT_FILE = "SYS$DISK:[]" + CIRCLE_FILE_NAME + ".OBJ"
$!
$! Check To See If The File We Want To Compile Actually Exists.
$!
$ IF (F$SEARCH(CIRCLE_SOURCE_FILE).EQS."")
$ THEN
$!
$! Tell The User That The File Dosen't Exist.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "The File ",CIRCLE_SOURCE_FILE," Dosen't Exist."
$ WRITE SYS$OUTPUT ""
$!
$! Exit The Build.
$!
$ EXIT
$!
$! End The File Check.
$!
$ ENDIF
$!
$! Tell The User What We Are Compiling.
$!
$ WRITE SYS$OUTPUT " ",CIRCLE_SOURCE_FILE
$!
$! Compile The File.
$!
$ CC/PREFIX=ALL/'OPTIMIZE'/'DEBUGGER'/DEFINE=("DECC=1") -
/OBJECT='CIRCLE_OBJECT_FILE' 'CIRCLE_SOURCE_FILE'
$!
$! Go Back And Do It Again.
$!
$ GOTO NEXT_CIRCLE_FILE
$!
$! All Done Compiling.
$!
$ CIRCLE_FILE_DONE:
$!
$! Tell The User We Are Linking [-.BIN]CIRCLE.EXE
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "Linking [-.BIN]CIRCLE.EXE"
$ WRITE SYS$OUTPUT ""
$!
$! Link [-.BIN]CIRCLE.EXE
$!
$ LINK/'DEBUGGER'/'TRACEBACK'/EXE=[-.BIN]CIRCLE.EXE -
COMM.OBJ,ACT_COMM.OBJ,ACT_INFORMATIVE.OBJ,ACT_ITEM.OBJ, -
ACT_MOVEMENT.OBJ,ACT_OFFENSIVE.OBJ,ACT_OTHER.OBJ, -
ACT_SOCIAL.OBJ,ACT_WIZARD.OBJ,ALIAS.OBJ,BAN.OBJ,BOARDS.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,OBJSAVE.OBJ,PLAYERS.OBJ,OLC.OBJ, -
RANDOM.OBJ,SHOP.OBJ,SPEC_ASSIGN.OBJ,SPEC_PROCS.OBJ,SPELLS.OBJ, -
SPELL_PARSER.OBJ,UTILS.OBJ,WEATHER.OBJ$!
$! That's It, Time To Return From Where We Came From.
$!
$ RETURN
$!
$! Build The CircleMUD Utilities.
$!
$ BUILD_UTILS:
$!
$! Tell The User What We Are Doing.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "Building CircleMUD Utilities."
$ WRITE SYS$OUTPUT ""
$!
$! Define The Source Files That Are Necessary.
$!
$ UTIL_FILES = "ASCIIPASSWD,LISTRENT,PLRTOASCII,SHOPCONV,SPLIT," + -
"WLD2HTML"
$!
$! Define A File Counter And Set It To "0".
$!
$ UTIL_FILE_COUNTER = 0
$!
$! Top Of The File Loop.
$!
$ NEXT_UTIL_FILE:
$!
$! O.K, Extract The File Name From The File List.
$!
$ UTIL_FILE_NAME = F$ELEMENT(UTIL_FILE_COUNTER,",",UTIL_FILES)
$!
$! Check To See If We Are At The End Of The File List.
$!
$ IF (UTIL_FILE_NAME.EQS.",") THEN GOTO UTIL_FILE_DONE
$!
$! Increment The Counter.
$!
$ UTIL_FILE_COUNTER = UTIL_FILE_COUNTER + 1
$!
$! Create The Source File Name.
$!
$ UTIL_SOURCE_FILE = "SYS$DISK:[.UTIL]" + UTIL_FILE_NAME + ".C"
$!
$! Create The Object File Name.
$!
$ UTIL_OBJECT_FILE = "SYS$DISK:[.UTIL]" + UTIL_FILE_NAME + ".OBJ"
$!
$! Check To See If The File We Want To Compile Actually Exists.
$!
$ IF (F$SEARCH(UTIL_SOURCE_FILE).EQS."")
$ THEN
$!
$! Tell The User That The File Dosen't Exist.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "The File ",UTIL_SOURCE_FILE," Dosen't Exist."
$ WRITE SYS$OUTPUT ""
$!
$! Exit The Build.
$!
$ EXIT
$ ENDIF
$!
$! Tell The User What We Are Building.
$!
$ WRITE SYS$OUTPUT "Building SYS$DISK:[-.BIN]",UTIL_FILE_NAME,".EXE"
$!
$! Compile The File.
$!
$ CC/PREFIX=ALL/STANDARD=ANSI89/'OPTIMIZE'/'DEBUGGER'/DEFINE=("DECC=1") -
/INCLUDE=SYS$DISK:[]/OBJECT='UTIL_OBJECT_FILE' 'UTIL_SOURCE_FILE'
$!
$! Link The File.
$!
$ LINK/'DEBUGGER'/'TRACEBACK'/EXE=[-.BIN]'UTIL_FILE_NAME'.EXE -
'UTIL_OBJECT_FILE'
$!
$! Go Back And Do It Again.
$!
$ GOTO NEXT_UTIL_FILE
$!
$! All Done Compiling.
$!
$ UTIL_FILE_DONE:
$!
$! That's It, Time To Return From Where We Came From.
$!
$ RETURN
$!
$! Check The User's Options.
$!
$ CHECK_OPTIONS:
$!
$! Check To See If We Are To "Just Build Everything".
$!
$ IF ((P1.EQS."").OR.(P1.EQS."ALL"))
$ THEN
$!
$! P1 Is "ALL", So Build Everything.
$!
$ BUILDALL = "TRUE"
$!
$! Else....
$!
$ ELSE
$!
$! Check To See If P1 Has A Valid Arguement.
$!
$ IF (P1.EQS."CIRCLE").OR.(P1.EQS."UTILS")
$ THEN
$!
$! A Valid Arguement.
$!
$ BUILDALL = P1
$!
$! Else...
$!
$ ELSE
$!
$! Tell The User We Don't Know What They Want.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
$ WRITE SYS$OUTPUT " CIRCLE : Just Build [-.BIN]CIRCLE.EXE."
$ WRITE SYS$OUTPUT " UTILS : Just Build The CircleMUD Utilities."
$ WRITE SYS$OUTPUT ""
$!
$! Time To EXIT.
$!
$ EXIT
$ ENDIF
$ ENDIF
$!
$! Check To See If We Are To Compile Without Debugger Information.
$!
$ IF ((P2.EQS."").OR.(P2.EQS."NODEBUG"))
$ THEN
$!
$! P2 Is Either Blank Or "NODEBUG" So Compile Without Debugger Information.
$!
$ DEBUGGER = "NODEBUG"
$ OPTIMIZE = "OPTIMIZE"
$ TRACEBACK = "NOTRACEBACK"
$!
$! Tell The User What They Selected.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
$ ELSE
$!
$! Check To See If We Are To Compile With Debugger Information.
$!
$ IF (P2.EQS."DEBUG")
$ THEN
$!
$! Compile With Debugger Information.
$!
$ DEBUGGER = "DEBUG"
$ OPTIMIZE = "NOOPTIMIZE"
$ TRACEBACK = "TRACEBACK"
$!
$! Tell The User What They Selected.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
$!
$! Else...
$!
$ ELSE
$!
$! Tell The User Entered An Invalid Option..
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
$ WRITE SYS$OUTPUT ""
$!
$! Time To EXIT.
$!
$ EXIT
$ ENDIF
$ ENDIF
$!
$! Time To Return To Where We Were.
$!
$ RETURN
$!
$! Subroutine To Check CONF.H File.
$!
$ CHECK_CONF_FILE:
$!
$! Tell The User We Are Checking CONF.H File.
$!
$ WRITE SYS$OUTPUT "Checking The CONF.H File."
$!
$! Check To See If The CONF.H File Exists.
$!
$ IF (F$SEARCH("SYS$DISK:[]CONF.H").EQS."")
$ THEN
$!
$! The File Dosen't Exist So Check To See If The CONF.H_VMS File Exists.
$!
$ IF (F$SEARCH("SYS$DISK:[]CONF.H_VMS").NES."")
$ THEN
$!
$! Copy CONF.H_VMS To CONF.H.
$!
$ COPY SYS$DISK:[]CONF.H_VMS SYS$DISK:[]CONF.H
$!
$! Else....
$!
$ ELSE
$!
$! Check To See If The CONF_H.VMS File Exists.
$!
$ IF (F$SEARCH("SYS$DISK:[]CONF_H.VMS").NES."")
$ THEN
$!
$! Copy CONF_H.VMS To CONF.H.
$!
$ COPY SYS$DISK:[]CONF_H.VMS SYS$DISK:[]CONF.H
$!
$! Else...
$!
$ ELSE
$!
$! The CONF.H_VMS And The CONF_H.VMS File Dosen't Exist, So Tell The User.
$!
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "The file CONF.H_VMS or CONF_H.VMS dosen't exist. This file is"
$ WRITE SYS$OUTPUT "necessary to compile CircleMUD and is distributed"
$ WRITE SYS$OUTPUT "with the source code."
$ WRITE SYS$OUTPUT ""
$ WRITE SYS$OUTPUT "Since the CONF.H_VMS or CONF_H.VMS file is distributed with the"
$ WRITE SYS$OUTPUT "source files I recomend that you unpack the files"
$ WRITE SYS$OUTPUT "again or get a new source distribution."
$ WRITE SYS$OUTPUT ""
$!
$! Since We Can't Compile Without This File, Just EXIT.
$!
$ EXIT
$!
$! Time To End The CONF_H.VMS File Check.
$!
$ ENDIF
$!
$! Time To End The CONF.H_VMS File Check.
$!
$ ENDIF
$!
$! End The CONF.H Check.
$!
$ ENDIF
$!
$! Time To Return To Where We Were.
$!
$ RETURN
$!
$! Subroutine To Check File Names.
$!
$ CHECK_FILE_NAMES:
$!
$! Tell The User We Are Checking File Names.
$!
$ WRITE SYS$OUTPUT "Checking File Names."
$!
$! Define The File Names We Need To Check On.
$!
$ CHECK_FOR = "ACT.COMM_C,ACT.INFORMATIVE_C,ACT.ITEM_C,ACT.MOVEMENT_C," + -
"ACT.OFFENSIVE_C,ACT.OTHER_C,ACT.SOCIAL_C,ACT.WIZARD_C"
$!
$! Define What The File Names Need To Be.
$!
$ SHOULD_BE = "ACT_COMM.C,ACT_INFORMATIVE.C,ACT_ITEM.C,ACT_MOVEMENT.C," + -
"ACT_OFFENSIVE.C,ACT_OTHER.C,ACT_SOCIAL.C,ACT_WIZARD.C"
$!
$! Define A File Counter And Set It To "0".
$!
$ FILE_COUNTER = 0
$!
$! Top Of The File Loop.
$!
$ CHECK_NEXT_FILE:
$!
$! O.K, Extract The File Name We Are Looking For From The List.
$!
$ LOOKING_FOR = F$ELEMENT(FILE_COUNTER,",",CHECK_FOR)
$!
$! Extract The File Name It SHOULD Be From The List.
$!
$ RENAME_TO = F$ELEMENT(FILE_COUNTER,",",SHOULD_BE)
$!
$! Check To See If We Are At The End Of The File List.
$!
$ IF (LOOKING_FOR.EQS.",") THEN GOTO CHECK_FILES_DONE
$!
$! Increment The Counter.
$!
$ FILE_COUNTER = FILE_COUNTER + 1
$!
$! Check To See If The File We Are Checking For Exists.
$!
$ IF (F$SEARCH(LOOKING_FOR).EQS."")
$ THEN
$!
$! The File Dosen't Exist, Check For The Next File.
$!
$ GOTO CHECK_NEXT_FILE
$!
$! Else...
$!
$ ELSE
$!
$! The File Exists And Needs To Be Fixed.
$!
$ RENAME 'LOOKING_FOR' 'RENAME_TO'
$!
$! End The File Check.
$!
$ ENDIF
$!
$! Go Back And Do It Again.
$!
$ GOTO CHECK_NEXT_FILE
$!
$! All Done With Checking File Names.
$!
$ CHECK_FILES_DONE:
$!
$! Time To Return To Where We Were.
$!
$ RETURN

925
src/castle.c Normal file
View file

@ -0,0 +1,925 @@
/* ************************************************************************
* File: castle.c Part of CircleMUD *
* Usage: Special procedures for King's Castle area *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Special procedures for Kings Castle by Pjotr (d90-pem@nada.kth.se) *
* Coded by Sapowox (d90-jkr@nada.kth.se) *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
/* 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 (On Alex and Alfa) is 80 (That is rooms and mobs have numbers
in the 8000 series... */
#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));
/**********************************************************************\
|* Special procedures for Kings Castle by Pjotr (d90-pem@nada.kth.se) *|
|* Coded by Sapowox (d90-jkr@nada.kth.se) *|
\**********************************************************************/
SPECIAL(CastleGuard);
SPECIAL(James);
SPECIAL(cleaning);
SPECIAL(DicknDavid);
SPECIAL(tim);
SPECIAL(tom);
SPECIAL(king_welmar);
SPECIAL(training_master);
SPECIAL(peter);
SPECIAL(jerry);
SPECIAL(guild);
ACMD(do_gen_door);
ACMD(do_follow);
/*
* Assign castle special procedures.
*
* NOTE: The mobile number isn't fully specified. It's only an offset
* from the zone's base.
*/
void castle_mob_spec(mob_vnum mobnum, SPECIAL(*specproc))
{
mob_vnum vmv = castle_virtual(mobnum);
mob_rnum rmr = NOBODY;
if (vmv != NOBODY)
rmr = real_mobile(vmv);
if (rmr == NOBODY) {
if (!mini_mud)
log("SYSERR: assign_kings_castle(): can't find mob #%d.", vmv);
} else
mob_index[rmr].func = specproc;
}
mob_vnum castle_virtual(mob_vnum offset)
{
zone_rnum zon;
if ((zon = real_zone(Z_KINGS_C)) == NOWHERE)
return NOBODY;
return zone_table[zon].bot + offset;
}
room_rnum castle_real_room(room_vnum roomoffset)
{
zone_rnum zon;
if ((zon = real_zone(Z_KINGS_C)) == NOWHERE)
return NOWHERE;
return real_room(zone_table[zon].bot + roomoffset);
}
/*
* Routine: assign_kings_castle
*
* Used to assign function pointers to all mobiles in the Kings Castle.
* Called from spec_assign.c.
*/
void assign_kings_castle(void)
{
castle_mob_spec(0, CastleGuard); /* Gwydion */
/* Added the previous line -- Furry */
castle_mob_spec(1, king_welmar); /* Our dear friend, the King */
castle_mob_spec(3, CastleGuard); /* Jim */
castle_mob_spec(4, CastleGuard); /* Brian */
castle_mob_spec(5, CastleGuard); /* Mick */
castle_mob_spec(6, CastleGuard); /* Matt */
castle_mob_spec(7, CastleGuard); /* Jochem */
castle_mob_spec(8, CastleGuard); /* Anne */
castle_mob_spec(9, CastleGuard); /* Andrew */
castle_mob_spec(10, CastleGuard); /* Bertram */
castle_mob_spec(11, CastleGuard); /* Jeanette */
castle_mob_spec(12, peter); /* Peter */
castle_mob_spec(13, training_master); /* The training master */
castle_mob_spec(16, James); /* James the Butler */
castle_mob_spec(17, cleaning); /* Ze Cleaning Fomen */
castle_mob_spec(20, tim); /* Tim, Tom's twin */
castle_mob_spec(21, tom); /* Tom, Tim's twin */
castle_mob_spec(24, DicknDavid); /* Dick, guard of the
* Treasury */
castle_mob_spec(25, DicknDavid); /* David, Dicks brother */
castle_mob_spec(26, jerry); /* Jerry, the Gambler */
castle_mob_spec(27, CastleGuard); /* Michael */
castle_mob_spec(28, CastleGuard); /* Hans */
castle_mob_spec(29, CastleGuard); /* Boris */
}
/*
* Routine: member_of_staff
*
* Used to see if a character is a member of the castle staff.
* Used mainly by BANZAI:ng NPC:s.
*/
int member_of_staff(struct char_data *chChar)
{
int ch_num;
if (!IS_NPC(chChar))
return (FALSE);
ch_num = GET_MOB_VNUM(chChar);
if (ch_num == castle_virtual(1))
return (TRUE);
if (ch_num > castle_virtual(2) && ch_num < castle_virtual(15))
return (TRUE);
if (ch_num > castle_virtual(15) && ch_num < castle_virtual(18))
return (TRUE);
if (ch_num > castle_virtual(18) && ch_num < castle_virtual(30))
return (TRUE);
return (FALSE);
}
/*
* 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.
*/
int member_of_royal_guard(struct char_data *chChar)
{
int ch_num;
if (!chChar || !IS_NPC(chChar))
return (FALSE);
ch_num = GET_MOB_VNUM(chChar);
if (ch_num == castle_virtual(3) || ch_num == castle_virtual(6))
return (TRUE);
if (ch_num > castle_virtual(7) && ch_num < castle_virtual(12))
return (TRUE);
if (ch_num > castle_virtual(23) && ch_num < castle_virtual(26))
return (TRUE);
return (FALSE);
}
/*
* Function: find_npc_by_name
*
* Returns a pointer to an npc by the given name.
* Used by Tim and Tom
*/
struct char_data *find_npc_by_name(struct char_data *chAtChar,
const char *pszName, int iLen)
{
struct char_data *ch;
for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room)
if (IS_NPC(ch) && !strncmp(pszName, ch->player.short_descr, iLen))
return (ch);
return (NULL);
}
/*
* Function: find_guard
*
* Returns the pointer to a guard on duty.
* Used by Peter the Captain of the Royal Guard
*/
struct char_data *find_guard(struct char_data *chAtChar)
{
struct char_data *ch;
for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room)
if (!FIGHTING(ch) && member_of_royal_guard(ch))
return (ch);
return (NULL);
}
/*
* 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 characters and King Welmar...
*/
struct char_data *get_victim(struct char_data *chAtChar)
{
struct char_data *ch;
int iNum_bad_guys = 0, iVictim;
for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room)
if (FIGHTING(ch) && member_of_staff(FIGHTING(ch)))
iNum_bad_guys++;
if (!iNum_bad_guys)
return (NULL);
iVictim = rand_number(0, iNum_bad_guys); /* How nice, we give them a chance */
if (!iVictim)
return (NULL);
iNum_bad_guys = 0;
for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room) {
if (FIGHTING(ch) == NULL)
continue;
if (!member_of_staff(FIGHTING(ch)))
continue;
if (++iNum_bad_guys != iVictim)
continue;
return (ch);
}
return (NULL);
}
/*
* Function: banzaii
*
* Makes a character banzaii on attackers of the castle staff.
* Used by Guards, Tim, Tom, Dick, David, Peter, Master, King and Guards.
*/
int banzaii(struct char_data *ch)
{
struct char_data *chOpponent;
if (!AWAKE(ch) || GET_POS(ch) == POS_FIGHTING || !(chOpponent = get_victim(ch)))
return (FALSE);
act("$n roars: 'Protect the Kingdom of Great King Welmar! BANZAIIII!!!'",
FALSE, ch, 0, 0, TO_ROOM);
hit(ch, chOpponent, TYPE_UNDEFINED);
return (TRUE);
}
/*
* Function: 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)
{
struct char_data *ch_bad_guy;
for (ch_bad_guy = world[IN_ROOM(ch_hero)].people;
ch_bad_guy && (FIGHTING(ch_bad_guy) != ch_victim);
ch_bad_guy = ch_bad_guy->next_in_room);
/* NO WAY I'll rescue the one I'm fighting! */
if (!ch_bad_guy || ch_bad_guy == ch_hero)
return (FALSE);
act("You bravely rescue $N.\r\n", FALSE, ch_hero, 0, ch_victim, TO_CHAR);
act("You are rescued by $N, your loyal friend!\r\n",
FALSE, ch_victim, 0, ch_hero, TO_CHAR);
act("$n heroically rescues $N.", FALSE, ch_hero, 0, ch_victim, TO_NOTVICT);
if (FIGHTING(ch_bad_guy))
stop_fighting(ch_bad_guy);
if (FIGHTING(ch_hero))
stop_fighting(ch_hero);
set_fighting(ch_hero, ch_bad_guy);
set_fighting(ch_bad_guy, ch_hero);
return (TRUE);
}
/*
* Procedure to block a person trying to enter a room.
* Used by Tim/Tom at Kings bedroom and Dick/David at treasury.
*/
int block_way(struct char_data *ch, int cmd, char *arg, room_vnum iIn_room,
int iProhibited_direction)
{
if (cmd != ++iProhibited_direction)
return (FALSE);
if (ch->player.short_descr && !strncmp(ch->player.short_descr, "King Welmar", 11))
return (FALSE);
if (IN_ROOM(ch) != real_room(iIn_room))
return (FALSE);
if (!member_of_staff(ch))
act("The guard roars at $n and pushes $m back.", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "The guard roars: 'Entrance is Prohibited!', and pushes you back.\r\n");
return (TRUE);
}
/*
* Routine to check if an object is trash...
* Used by James the Butler and the Cleaning Lady.
*/
int is_trash(struct obj_data *i)
{
if (!OBJWEAR_FLAGGED(i, ITEM_WEAR_TAKE))
return (FALSE);
if (GET_OBJ_TYPE(i) == ITEM_DRINKCON || GET_OBJ_COST(i) <= 10)
return (TRUE);
return (FALSE);
}
/*
* Function: fry_victim
*
* Finds a suitabe victim, and cast some _NASTY_ spell on him.
* Used by King Welmar
*/
void fry_victim(struct char_data *ch)
{
struct char_data *tch;
if (ch->points.mana < 10)
return;
/* Find someone suitable to fry ! */
if (!(tch = get_victim(ch)))
return;
switch (rand_number(0, 8)) {
case 1:
case 2:
case 3:
send_to_char(ch, "You raise your hand in a dramatical gesture.\r\n");
act("$n raises $s hand in a dramatical gesture.", 1, ch, 0, 0, TO_ROOM);
cast_spell(ch, tch, 0, SPELL_COLOR_SPRAY);
break;
case 4:
case 5:
send_to_char(ch, "You concentrate and mumble to yourself.\r\n");
act("$n concentrates, and mumbles to $mself.", 1, ch, 0, 0, TO_ROOM);
cast_spell(ch, tch, 0, SPELL_HARM);
break;
case 6:
case 7:
act("You look deeply into the eyes of $N.", 1, ch, 0, tch, TO_CHAR);
act("$n looks deeply into the eyes of $N.", 1, ch, 0, tch, TO_NOTVICT);
act("You see an ill-boding flame in the eye of $n.", 1, ch, 0, tch, TO_VICT);
cast_spell(ch, tch, 0, SPELL_FIREBALL);
break;
default:
if (!rand_number(0, 1))
cast_spell(ch, ch, 0, SPELL_HEAL);
break;
}
ch->points.mana -= 10;
return;
}
/*
* Function: king_welmar
*
* Control the actions and movements of the King.
* Used by King Welmar.
*/
SPECIAL(king_welmar)
{
char actbuf[MAX_INPUT_LENGTH];
const char *monolog[] = {
"$n proclaims 'Primus in regnis Geticis coronam'.",
"$n proclaims 'regiam gessi, subiique regis'.",
"$n proclaims 'munus et mores colui sereno'.",
"$n proclaims 'principe dignos'."
};
const char bedroom_path[] = "s33004o1c1S.";
const char throne_path[] = "W3o3cG52211rg.";
const char monolog_path[] = "ABCDPPPP.";
static const char *path;
static int path_index;
static bool move = FALSE;
if (!move) {
if (time_info.hours == 8 && IN_ROOM(ch) == castle_real_room(51)) {
move = TRUE;
path = throne_path;
path_index = 0;
} else if (time_info.hours == 21 && IN_ROOM(ch) == castle_real_room(17)) {
move = TRUE;
path = bedroom_path;
path_index = 0;
} else if (time_info.hours == 12 && IN_ROOM(ch) == castle_real_room(17)) {
move = TRUE;
path = monolog_path;
path_index = 0;
}
}
if (cmd || (GET_POS(ch) < POS_SLEEPING) ||
(GET_POS(ch) == POS_SLEEPING && !move))
return (FALSE);
if (GET_POS(ch) == POS_FIGHTING) {
fry_victim(ch);
return (FALSE);
} else if (banzaii(ch))
return (FALSE);
if (!move)
return (FALSE);
switch (path[path_index]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
perform_move(ch, path[path_index] - '0', 1);
break;
case 'A':
case 'B':
case 'C':
case 'D':
act(monolog[path[path_index] - 'A'], FALSE, ch, 0, 0, TO_ROOM);
break;
case 'P':
break;
case 'W':
GET_POS(ch) = POS_STANDING;
act("$n awakens and stands up.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'S':
GET_POS(ch) = POS_SLEEPING;
act("$n lies down on $s beautiful bed and instantly falls asleep.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'r':
GET_POS(ch) = POS_SITTING;
act("$n sits down on $s great throne.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 's':
GET_POS(ch) = POS_STANDING;
act("$n stands up.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'G':
act("$n says 'Good morning, trusted friends.'", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'g':
act("$n says 'Good morning, dear subjects.'", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'o':
do_gen_door(ch, strcpy(actbuf, "door"), 0, SCMD_UNLOCK); /* strcpy: OK */
do_gen_door(ch, strcpy(actbuf, "door"), 0, SCMD_OPEN); /* strcpy: OK */
break;
case 'c':
do_gen_door(ch, strcpy(actbuf, "door"), 0, SCMD_CLOSE); /* strcpy: OK */
do_gen_door(ch, strcpy(actbuf, "door"), 0, SCMD_LOCK); /* strcpy: OK */
break;
case '.':
move = FALSE;
break;
}
path_index++;
return (FALSE);
}
/*
* Function: training_master
*
* Acts actions to the training room, if his students are present.
* Also allowes warrior-class to practice.
* Used by the Training Master.
*/
SPECIAL(training_master)
{
struct char_data *pupil1, *pupil2 = NULL, *tch;
if (!AWAKE(ch) || (GET_POS(ch) == POS_FIGHTING))
return (FALSE);
if (cmd)
return (FALSE);
if (banzaii(ch) || rand_number(0, 2))
return (FALSE);
if (!(pupil1 = find_npc_by_name(ch, "Brian", 5)))
return (FALSE);
if (!(pupil2 = find_npc_by_name(ch, "Mick", 4)))
return (FALSE);
if (FIGHTING(pupil1) || FIGHTING(pupil2))
return (FALSE);
if (rand_number(0, 1)) {
tch = pupil1;
pupil1 = pupil2;
pupil2 = tch;
}
switch (rand_number(0, 7)) {
case 0:
act("$n hits $N on $s head with a powerful blow.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("You hit $N on $s head with a powerful blow.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("$n hits you on your head with a powerful blow.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
case 1:
act("$n hits $N in $s chest with a thrust.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("You manage to thrust $N in the chest.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("$n manages to thrust you in your chest.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
case 2:
send_to_char(ch, "You command your pupils to bow.\r\n");
act("$n commands $s pupils to bow.", FALSE, ch, 0, 0, TO_ROOM);
act("$n bows before $N.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("$N bows before $n.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("You bow before $N, who returns your gesture.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("You bow before $n, who returns your gesture.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
case 3:
act("$N yells at $n, as he fumbles and drops $s sword.", FALSE, pupil1, 0, ch, TO_NOTVICT);
act("$n quickly picks up $s weapon.", FALSE, pupil1, 0, 0, TO_ROOM);
act("$N yells at you, as you fumble, losing your weapon.", FALSE, pupil1, 0, ch, TO_CHAR);
send_to_char(pupil1, "You quickly pick up your weapon again.\r\n");
act("You yell at $n, as he fumbles, losing $s weapon.", FALSE, pupil1, 0, ch, TO_VICT);
break;
case 4:
act("$N tricks $n, and slashes him across the back.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("$N tricks you, and slashes you across your back.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("You trick $n, and quickly slash him across $s back.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
case 5:
act("$n lunges a blow at $N but $N parries skillfully.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("You lunge a blow at $N but $E parries skillfully.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("$n lunges a blow at you, but you skillfully parry it.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
case 6:
act("$n clumsily tries to kick $N, but misses.", FALSE, pupil1, 0, pupil2, TO_NOTVICT);
act("You clumsily miss $N with your poor excuse for a kick.", FALSE, pupil1, 0, pupil2, TO_CHAR);
act("$n fails an unusually clumsy attempt at kicking you.", FALSE, pupil1, 0, pupil2, TO_VICT);
break;
default:
send_to_char(ch, "You show your pupils an advanced technique.\r\n");
act("$n shows $s pupils an advanced technique.", FALSE, ch, 0, 0, TO_ROOM);
break;
}
return (FALSE);
}
SPECIAL(tom)
{
return castle_twin_proc(ch, cmd, argument, 48, "Tim");
}
SPECIAL(tim)
{
return castle_twin_proc(ch, cmd, argument, 49, "Tom");
}
/*
* Common routine for the Castle Twins.
*/
int castle_twin_proc(struct char_data *ch, int cmd, char *arg, int ctlnum, const char *twinname)
{
struct char_data *king, *twin;
if (!AWAKE(ch))
return (FALSE);
if (cmd)
return block_way(ch, cmd, arg, castle_virtual(ctlnum), 1);
if ((king = find_npc_by_name(ch, "King Welmar", 11)) != NULL) {
char actbuf[MAX_INPUT_LENGTH];
if (!ch->master)
do_follow(ch, strcpy(actbuf, "King Welmar"), 0, 0); /* strcpy: OK */
if (FIGHTING(king))
do_npc_rescue(ch, king);
}
if ((twin = find_npc_by_name(ch, twinname, strlen(twinname))) != NULL)
if (FIGHTING(twin) && 2 * GET_HIT(twin) < GET_HIT(ch))
do_npc_rescue(ch, twin);
if (GET_POS(ch) != POS_FIGHTING)
banzaii(ch);
return (FALSE);
}
/*
* Routine for James the Butler.
* Complains if he finds any trash...
*
* This doesn't make sure he _can_ carry it...
*/
SPECIAL(James)
{
return castle_cleaner(ch, cmd, TRUE);
}
/*
* Common code for James and the Cleaning Woman.
*/
int castle_cleaner(struct char_data *ch, int cmd, int gripe)
{
struct obj_data *i;
if (cmd || !AWAKE(ch) || GET_POS(ch) == POS_FIGHTING)
return (FALSE);
for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
if (!is_trash(i))
continue;
if (gripe) {
act("$n says: 'My oh my! I ought to fire that lazy cleaning woman!'",
FALSE, ch, 0, 0, TO_ROOM);
act("$n picks up a piece of trash.", FALSE, ch, 0, 0, TO_ROOM);
}
obj_from_room(i);
obj_to_char(i, ch);
return (TRUE);
}
return (FALSE);
}
/*
* Routine for the Cleaning Woman.
* Picks up any trash she finds...
*/
SPECIAL(cleaning)
{
return castle_cleaner(ch, cmd, FALSE);
}
/*
* Routine: CastleGuard
*
* Standard routine for ordinary castle guards.
*/
SPECIAL(CastleGuard)
{
if (cmd || !AWAKE(ch) || (GET_POS(ch) == POS_FIGHTING))
return (FALSE);
return (banzaii(ch));
}
/*
* Routine: DicknDave
*
* Routine for the guards Dick and David.
*/
SPECIAL(DicknDavid)
{
if (!AWAKE(ch))
return (FALSE);
if (!cmd && GET_POS(ch) != POS_FIGHTING)
banzaii(ch);
return (block_way(ch, cmd, argument, castle_virtual(36), 1));
}
/*
* Routine: peter
* Routine for Captain of the Guards.
*/
SPECIAL(peter)
{
struct char_data *ch_guard = NULL;
if (cmd || !AWAKE(ch) || GET_POS(ch) == POS_FIGHTING)
return (FALSE);
if (banzaii(ch))
return (FALSE);
if (!(rand_number(0, 3)) && (ch_guard = find_guard(ch)))
switch (rand_number(0, 5)) {
case 0:
act("$N comes sharply into attention as $n inspects $M.",
FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("$N comes sharply into attention as you inspect $M.",
FALSE, ch, 0, ch_guard, TO_CHAR);
act("You go sharply into attention as $n inspects you.",
FALSE, ch, 0, ch_guard, TO_VICT);
break;
case 1:
act("$N looks very small, as $n roars at $M.",
FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("$N looks very small as you roar at $M.",
FALSE, ch, 0, ch_guard, TO_CHAR);
act("You feel very small as $N roars at you.",
FALSE, ch, 0, ch_guard, TO_VICT);
break;
case 2:
act("$n gives $N some Royal directions.",
FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("You give $N some Royal directions.",
FALSE, ch, 0, ch_guard, TO_CHAR);
act("$n gives you some Royal directions.",
FALSE, ch, 0, ch_guard, TO_VICT);
break;
case 3:
act("$n looks at you.", FALSE, ch, 0, ch_guard, TO_VICT);
act("$n looks at $N.", FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("$n growls: 'Those boots need polishing!'",
FALSE, ch, 0, ch_guard, TO_ROOM);
act("You growl at $N.", FALSE, ch, 0, ch_guard, TO_CHAR);
break;
case 4:
act("$n looks at you.", FALSE, ch, 0, ch_guard, TO_VICT);
act("$n looks at $N.", FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("$n growls: 'Straighten that collar!'",
FALSE, ch, 0, ch_guard, TO_ROOM);
act("You growl at $N.", FALSE, ch, 0, ch_guard, TO_CHAR);
break;
default:
act("$n looks at you.", FALSE, ch, 0, ch_guard, TO_VICT);
act("$n looks at $N.", FALSE, ch, 0, ch_guard, TO_NOTVICT);
act("$n growls: 'That chain mail looks rusty! CLEAN IT !!!'",
FALSE, ch, 0, ch_guard, TO_ROOM);
act("You growl at $N.", FALSE, ch, 0, ch_guard, TO_CHAR);
break;
}
return (FALSE);
}
/*
* Procedure for Jerry and Michael in x08 of King's Castle.
* Code by Sapowox modified by Pjotr.(Original code from Master)
*/
SPECIAL(jerry)
{
struct char_data *gambler1, *gambler2 = NULL, *tch;
if (!AWAKE(ch) || (GET_POS(ch) == POS_FIGHTING))
return (FALSE);
if (cmd)
return (FALSE);
if (banzaii(ch) || rand_number(0, 2))
return (FALSE);
if (!(gambler1 = ch))
return (FALSE);
if (!(gambler2 = find_npc_by_name(ch, "Michael", 7)))
return (FALSE);
if (FIGHTING(gambler1) || FIGHTING(gambler2))
return (FALSE);
if (rand_number(0, 1)) {
tch = gambler1;
gambler1 = gambler2;
gambler2 = tch;
}
switch (rand_number(0, 5)) {
case 0:
act("$n rolls the dice and cheers loudly at the result.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You roll the dice and cheer. GREAT!",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n cheers loudly as $e rolls the dice.",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
case 1:
act("$n curses the Goddess of Luck roundly as he sees $N's roll.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You curse the Goddess of Luck as $N rolls.",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n swears angrily. You are in luck!",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
case 2:
act("$n sighs loudly and gives $N some gold.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You sigh loudly at the pain of having to give $N some gold.",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n sighs loudly as $e gives you your rightful win.",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
case 3:
act("$n smiles remorsefully as $N's roll tops $s.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You smile sadly as you see that $N beats you. Again.",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n smiles remorsefully as your roll tops $s.",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
case 4:
act("$n excitedly follows the dice with $s eyes.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You excitedly follow the dice with your eyes.",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n excitedly follows the dice with $s eyes.",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
default:
act("$n says 'Well, my luck has to change soon', as he shakes the dice.",
FALSE, gambler1, 0, gambler2, TO_NOTVICT);
act("You say 'Well, my luck has to change soon' and shake the dice.",
FALSE, gambler1, 0, gambler2, TO_CHAR);
act("$n says 'Well, my luck has to change soon', as he shakes the dice.",
FALSE, gambler1, 0, gambler2, TO_VICT);
break;
}
return (FALSE);
}

1709
src/cedit.c Normal file

File diff suppressed because it is too large Load diff

2183
src/class.c Normal file

File diff suppressed because it is too large Load diff

2889
src/comm.c Normal file

File diff suppressed because it is too large Load diff

51
src/comm.h Normal file
View file

@ -0,0 +1,51 @@
/* ************************************************************************
* File: comm.h Part of CircleMUD *
* Usage: header file: prototypes of public communication functions *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#define NUM_RESERVED_DESCS 8
#define COPYOVER_FILE "copyover.dat"
/* comm.c */
size_t send_to_char(struct char_data *ch, const char *messg, ...) __attribute__ ((format (printf, 2, 3)));
void send_to_all(const char *messg, ...) __attribute__ ((format (printf, 1, 2)));
void send_to_room(room_rnum room, const char *messg, ...) __attribute__ ((format (printf, 2, 3)));
void send_to_outdoor(const char *messg, ...) __attribute__ ((format (printf, 1, 2)));
void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...) __attribute__ ((format (printf, 3, 4)));
void close_socket(struct descriptor_data *d);
void perform_act(const char *orig, struct char_data *ch,
struct obj_data *obj, const void *vict_obj, const struct char_data *to);
void 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 */
#define LOG_MESSG 512 /* log to message history */
/* I/O functions */
void write_to_q(const char *txt, struct txt_q *queue, int aliased);
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 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);

104
src/conf.h.amiga Normal file
View file

@ -0,0 +1,104 @@
/* CircleMUD for Amiga conf.h file - manually created (N. Franceschi 26 Jul 1996)
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */
#undef CIRCLE_WINDOWS
#define AMIGA 1
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
/* #undef HAVE_SYS_WAIT_H */
/* Define to `int' if <sys/types.h> doesn't define. */
/*#define pid_t int*/
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have 'struct in_addr' */
#define HAVE_STRUCT_IN_ADDR 1
/* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT
/* Define to `int' if <sys/socket.h> doesn't define. */
#define socklen_t int
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if you have the crypt function. */
#undef CIRCLE_CRYPT
/* Define if you have the random function. */
#undef HAVE_RANDOM
/* Define if you have the <arpa/telnet.h> header file. */
#define HAVE_ARPA_TELNET_H 1
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <net/errno.h> header file. */
/* #undef HAVE_NET_ERRNO_H */
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <sys/fcntl.h> header file. */
#define HAVE_SYS_FCNTL_H 1
/* Define if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the crypt library (-lcrypt). */
/* #undef HAVE_LIBCRYPT */
/* Define if you have the malloc library (-lmalloc). */
/* #undef HAVE_LIBMALLOC */
/* Define if you have the nsl library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Define if your compiler does not prototype remove(). */
/* #undef NEED_REMOVE_PROTO */
/* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */

78
src/conf.h.arc Normal file
View file

@ -0,0 +1,78 @@
/* CircleMUD for ACORN conf.h file - manually created (G. Duncan 13 June 98)
#define CIRCLE_ACORN
/* Define to empty if the keyword does not work. */
/*#define const*/
/* Define to `int' if <sys/types.h> doesn't define. */
/*#define pid_t int*/
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/*#define size_t*/
/* Define if you have 'struct in_addr' */
#define HAVE_STRUCT_IN_ADDR 1
/* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT
/* Define to `int' if <sys/socket.h> doesn't define. */
#define socklen_t int
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H
#define HAVE_MEMORY_H
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H
#define HAVE_UNISTD_H
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H
#define HAVE_SYS_ERRNO_H
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME
#define HAVE_SYS_TIME_H
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H
/*#define HAVE_SYS_FCNTL_H*/
/* Define if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H
#define HAVE_SYS_RESOURCE_H
/* Define if you have <sys/wait.h> that is POSIX. compatible. */
#define HAVE_SYS_WAIT_H
#define HAVE_NETINET_IN_H
#define HAVE_NETDB_H
#define HAVE_SIGNAL_H
#define HAVE_SYS_UIO_H
#define HAVE_SYS_STAT_H
#define NEED_GETTIMEOFDAY_PROTO
/* Define if your compiler does not prototype remove(). */
/* #undef NEED_REMOVE_PROTO */
/* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */

332
src/conf.h.in Normal file
View file

@ -0,0 +1,332 @@
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if we're compiling CircleMUD under any type of UNIX system. */
#undef CIRCLE_UNIX
/* Define if the system is capable of using crypt() to encrypt. */
#undef CIRCLE_CRYPT
/* Define if we don't have proper support for the system's crypt(). */
#undef HAVE_UNSAFE_CRYPT
/* Define is the system has struct in_addr. */
#undef HAVE_STRUCT_IN_ADDR
/* Define to `int' if <sys/socket.h> doesn't define. */
#undef socklen_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef ssize_t
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the inet_addr function. */
#undef HAVE_INET_ADDR
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the stricmp function. */
#undef HAVE_STRICMP
/* Define if you have the strlcpy function. */
#undef HAVE_STRLCPY
/* Define if you have the strncasecmp function. */
#undef HAVE_STRNCASECMP
/* Define if you have the strnicmp function. */
#undef HAVE_STRNICMP
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define if you have the <arpa/telnet.h> header file. */
#undef HAVE_ARPA_TELNET_H
/* Define if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
/* Define if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <mcheck.h> header file. */
#undef HAVE_MCHECK_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <net/errno.h> header file. */
#undef HAVE_NET_ERRNO_H
/* Define if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <sys/fcntl.h> header file. */
#undef HAVE_SYS_FCNTL_H
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <sys/uio.h> header file. */
#undef HAVE_SYS_UIO_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the malloc library (-lmalloc). */
#undef HAVE_LIBMALLOC
/* Check for a prototype to accept. */
#undef NEED_ACCEPT_PROTO
/* Check for a prototype to atoi. */
#undef NEED_ATOI_PROTO
/* Check for a prototype to atol. */
#undef NEED_ATOL_PROTO
/* Check for a prototype to bind. */
#undef NEED_BIND_PROTO
/* Check for a prototype to bzero. */
#undef NEED_BZERO_PROTO
/* Check for a prototype to chdir. */
#undef NEED_CHDIR_PROTO
/* Check for a prototype to close. */
#undef NEED_CLOSE_PROTO
/* Check for a prototype to crypt. */
#undef NEED_CRYPT_PROTO
/* Check for a prototype to fclose. */
#undef NEED_FCLOSE_PROTO
/* Check for a prototype to fcntl. */
#undef NEED_FCNTL_PROTO
/* Check for a prototype to fflush. */
#undef NEED_FFLUSH_PROTO
/* Check for a prototype to fprintf. */
#undef NEED_FPRINTF_PROTO
/* Check for a prototype to fputc. */
#undef NEED_FPUTC_PROTO
/* Check for a prototype to fputs. */
#undef NEED_FPUTS_PROTO
/* Check for a prototype to fread. */
#undef NEED_FREAD_PROTO
/* Check for a prototype to fscanf. */
#undef NEED_FSCANF_PROTO
/* Check for a prototype to fseek. */
#undef NEED_FSEEK_PROTO
/* Check for a prototype to fwrite. */
#undef NEED_FWRITE_PROTO
/* Check for a prototype to getpeername. */
#undef NEED_GETPEERNAME_PROTO
/* Check for a prototype to getpid. */
#undef NEED_GETPID_PROTO
/* Check for a prototype to getrlimit. */
#undef NEED_GETRLIMIT_PROTO
/* Check for a prototype to getsockname. */
#undef NEED_GETSOCKNAME_PROTO
/* Check for a prototype to gettimeofday. */
#undef NEED_GETTIMEOFDAY_PROTO
/* Check for a prototype to htonl. */
#undef NEED_HTONL_PROTO
/* Check for a prototype to htons. */
#undef NEED_HTONS_PROTO
/* Check for a prototype to inet_addr. */
#undef NEED_INET_ADDR_PROTO
/* Check for a prototype to inet_aton. */
#undef NEED_INET_ATON_PROTO
/* Check for a prototype to inet_ntoa. */
#undef NEED_INET_NTOA_PROTO
/* Check for a prototype to listen. */
#undef NEED_LISTEN_PROTO
/* Check for a prototype to ntohl. */
#undef NEED_NTOHL_PROTO
/* Check for a prototype to perror. */
#undef NEED_PERROR_PROTO
/* Check for a prototype to printf. */
#undef NEED_PRINTF_PROTO
/* Check for a prototype to qsort. */
#undef NEED_QSORT_PROTO
/* Check for a prototype to read. */
#undef NEED_READ_PROTO
/* Check for a prototype to remove. */
#undef NEED_REMOVE_PROTO
/* Check for a prototype to rewind. */
#undef NEED_REWIND_PROTO
/* Check for a prototype to select. */
#undef NEED_SELECT_PROTO
/* Check for a prototype to setitimer. */
#undef NEED_SETITIMER_PROTO
/* Check for a prototype to setrlimit. */
#undef NEED_SETRLIMIT_PROTO
/* Check for a prototype to setsockopt. */
#undef NEED_SETSOCKOPT_PROTO
/* Check for a prototype to snprintf. */
#undef NEED_SNPRINTF_PROTO
/* Check for a prototype to socket. */
#undef NEED_SOCKET_PROTO
/* Check for a prototype to sprintf. */
#undef NEED_SPRINTF_PROTO
/* Check for a prototype to sscanf. */
#undef NEED_SSCANF_PROTO
/* Check for a prototype to strcasecmp. */
#undef NEED_STRCASECMP_PROTO
/* Check for a prototype to strdup. */
#undef NEED_STRDUP_PROTO
/* Check for a prototype to strerror. */
#undef NEED_STRERROR_PROTO
/* Check for a prototype to stricmp. */
#undef NEED_STRICMP_PROTO
/* Check for a prototype to strlcpy. */
#undef NEED_STRLCPY_PROTO
/* Check for a prototype to strncasecmp. */
#undef NEED_STRNCASECMP_PROTO
/* Check for a prototype to strnicmp. */
#undef NEED_STRNICMP_PROTO
/* Check for a prototype to system. */
#undef NEED_SYSTEM_PROTO
/* Check for a prototype to time. */
#undef NEED_TIME_PROTO
/* Check for a prototype to unlink. */
#undef NEED_UNLINK_PROTO
/* Check for a prototype to vsnprintf. */
#undef NEED_VSNPRINTF_PROTO
/* Check for a prototype to write. */
#undef NEED_WRITE_PROTO

255
src/conf.h.mac Normal file
View file

@ -0,0 +1,255 @@
/* src/conf.h.in. Generated automatically from configure.in by autoheader. */
#define CIRCLE_MACINTOSH 1
#define HAVE_SYS_ERRNO_H 1
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define to `int' if <sys/socket.h> doesn't define. */
#define socklen_t int
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME
/* Define if we're compiling CircleMUD under any type of UNIX system */
#undef CIRCLE_UNIX
/* Define if the system is capable of using crypt() to encrypt */
#undef CIRCLE_CRYPT
/* Define to `int' if <sys/types.h> doesn't define. */
#undef ssize_t
/* Define if you have the <arpa/telnet.h> header file. */
#undef HAVE_ARPA_TELNET_H
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <net/errno.h> header file. */
#undef HAVE_NET_ERRNO_H
/* Define if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1
/* Define if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the <sys/fcntl.h> header file. */
#define HAVE_SYS_FCNTL_H 1
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/uio.h> header file. */
#undef HAVE_SYS_UIO_H
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the malloc library (-lmalloc). */
#undef HAVE_LIBMALLOC
/* Define if your compiler does not prototype accept(). */
#undef NEED_ACCEPT_PROTO
/* Define if your compiler does not prototype atoi(). */
#undef NEED_ATOI_PROTO
/* Define if your compiler does not prototype atol(). */
#undef NEED_ATOL_PROTO
/* Define if your compiler does not prototype bind(). */
#undef NEED_BIND_PROTO
/* Define if your compiler does not prototype bzero(). */
#undef NEED_BZERO_PROTO
/* Define if your compiler does not prototype chdir(). */
#undef NEED_CHDIR_PROTO
/* Define if your compiler does not prototype close(). */
#undef NEED_CLOSE_PROTO
/* Define if your compiler does not prototype crypt(). */
#undef NEED_CRYPT_PROTO
/* Define if your compiler does not prototype fclose(). */
#undef NEED_FCLOSE_PROTO
/* Define if your compiler does not prototype fcntl(). */
#undef NEED_FCNTL_PROTO
/* Define if your compiler does not prototype fflush(). */
#undef NEED_FFLUSH_PROTO
/* Define if your compiler does not prototype fprintf(). */
#undef NEED_FPRINTF_PROTO
/* Define if your compiler does not prototype fputc(). */
#undef NEED_FPUTC_PROTO
/* Define if your compiler does not prototype fputs(). */
#undef NEED_FPUTS_PROTO
/* Define if your compiler does not prototype fread(). */
#undef NEED_FREAD_PROTO
/* Define if your compiler does not prototype fscanf(). */
#undef NEED_FSCANF_PROTO
/* Define if your compiler does not prototype fseek(). */
#undef NEED_FSEEK_PROTO
/* Define if your compiler does not prototype fwrite(). */
#undef NEED_FWRITE_PROTO
/* Define if your compiler does not prototype getpeername(). */
#undef NEED_GETPEERNAME_PROTO
/* Define if your compiler does not prototype getpid(). */
#undef NEED_GETPID_PROTO
/* Define if your compiler does not prototype getrlimit(). */
#undef NEED_GETRLIMIT_PROTO
/* Define if your compiler does not prototype getsockname(). */
#undef NEED_GETSOCKNAME_PROTO
/* Define if your compiler does not prototype gettimeofday(). */
#undef NEED_GETTIMEOFDAY_PROTO
/* Define if your compiler does not prototype htonl(). */
#undef NEED_HTONL_PROTO
/* Define if your compiler does not prototype htons(). */
#undef NEED_HTONS_PROTO
/* Define if your compiler does not prototype listen(). */
#undef NEED_LISTEN_PROTO
/* Define if your compiler does not prototype ntohl(). */
#undef NEED_NTOHL_PROTO
/* Define if your compiler does not prototype perror(). */
#undef NEED_PERROR_PROTO
/* Define if your compiler does not prototype printf(). */
#undef NEED_PRINTF_PROTO
/* Define if your compiler does not prototype qsort(). */
#undef NEED_QSORT_PROTO
/* Define if your compiler does not prototype read(). */
#undef NEED_READ_PROTO
/* Define if your compiler does not prototype rewind(). */
#undef NEED_REWIND_PROTO
/* Define if your compiler does not prototype select(). */
#undef NEED_SELECT_PROTO
/* Define if your compiler does not prototype setitimer(). */
#undef NEED_SETITIMER_PROTO
/* Define if your compiler does not prototype setrlimit(). */
#undef NEED_SETRLIMIT_PROTO
/* Define if your compiler does not prototype setsockopt(). */
#undef NEED_SETSOCKOPT_PROTO
/* Define if your compiler does not prototype socket(). */
#undef NEED_SOCKET_PROTO
/* Define if your compiler does not prototype sprintf(). */
#undef NEED_SPRINTF_PROTO
/* Define if your compiler does not prototype sscanf(). */
#undef NEED_SSCANF_PROTO
/* Define if your compiler does not prototype system(). */
#undef NEED_SYSTEM_PROTO
/* Define if your compiler does not prototype time(). */
#undef NEED_TIME_PROTO
/* Define if your compiler does not prototype unlink(). */
#undef NEED_UNLINK_PROTO
/* Define if your compiler does not prototype write(). */
#undef NEED_WRITE_PROTO
/* Define is your compiler does not prototype fdopen(). */
#define NEED_FDOPEN_PROTO 1
/* Define is your compiler does not prototype inet_ntoa(). */
#define NEED_INET_NTOA_PROTO 1
/* Define if your compiler does not prototype remove(). */
/* #undef NEED_REMOVE_PROTO */
/* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */
/* Define if you have 'struct in_addr' */
#define HAVE_STRUCT_IN_ADDR 1
/* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT

104
src/conf.h.os2 Normal file
View file

@ -0,0 +1,104 @@
/* src/conf.h.os2. Manually written by David Carver. */
/* Define if we are compiling under OS2 */
#define CIRCLE_OS2
/* Define if we're compiling CircleMUD under any type of UNIX system */
/* #undef CIRCLE_UNIX */
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define to `int' if <sys/socket.h> doesn't define. */
#define socklen_t int
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME
/* Define if you have the crypt function. */
#undef CIRCLE_CRYPT
/* Define if you have the random function. (-lbsd) */
#define HAVE_RANDOM 1
/* Define if you have the <arpa/telnet.h> header file. */
#define HAVE_ARPA_TELNET_H
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H
/* Define if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H
/* Define if you have the <net/errno.h> header file. */
#undef HAVE_NET_ERRNO_H
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H
/* Define if you have the <sys/fcntl.h> header file. */
#define HAVE_SYS_FCNTL_H
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H
/* Define if you have the crypt library (-lcrypt). */
#undef HAVE_LIBCRYPT
/* Define if you have the malloc library (-lmalloc). */
#undef HAVE_LIBMALLOC
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the socket library (-lsocket). */
#define HAVE_LIBSOCKET
/* Define if your compiler does not prototype remove(). */
/* #undef NEED_REMOVE_PROTO */
/* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */
/* Define if you have 'struct in_addr' */
#define HAVE_STRUCT_IN_ADDR 1
/* Define if your crypt isn't safe with only 10 characters. */
#undef HAVE_UNSAFE_CRYPT

295
src/conf.h.vms Normal file
View file

@ -0,0 +1,295 @@
/* src/conf.h.in. Generated automatically from cnf/configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#ifdef DECC
# define HAVE_SYS_WAIT_H 1
#endif
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
#define socklen_t unsigned int
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#ifdef __GNUC__
# define TIME_WITH_SYS_TIME 1
#endif
/* Define if you have 'struct in_addr' */
#define HAVE_STRUCT_IN_ADDR 1
/* Define if we're compiling CircleMUD under any type of UNIX system */
/* #undef CIRCLE_UNIX */
/* Define if we're compiling CircleMUD under OpenVMS. */
#define CIRCLE_VMS 1
#define VMS 1
#define __VMS 1
/* Define if the system is capable of using crypt() to encrypt */
/* #undef CIRCLE_CRYPT*/
/* Define if your crypt isn't safe with only 10 characters. */
/* #undef HAVE_UNSAFE_CRYPT */
/* Define to `int' if <sys/types.h> doesn't define. */
#ifdef __GNUC__
# define ssize_t int
#endif
/* Define if you have the inet_addr function. */
/* #undef HAVE_INET_ADDR */
/* Define if you have the inet_aton function. */
/* #undef HAVE_INET_ATON */
/* Define if you have the <arpa/inet.h> header file. */
#ifdef DECC
# define HAVE_ARPA_INET_H 1
#endif
/* Define if you have the <arpa/telnet.h> header file. */
/* #undef HAVE_ARPA_TELNET_H */
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <crypt.h> header file. */
/* #undef HAVE_CRYPT_H */
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#ifdef DECC
# define HAVE_FCNTL_H 1
#endif
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <net/errno.h> header file. */
/* #undef HAVE_NET_ERRNO_H */
/* Define if you have the <netdb.h> header file. */
#ifdef DECC
# define HAVE_NETDB_H 1
#endif
/* Define if you have the <netinet/in.h> header file. */
#ifdef DECC
# define HAVE_NETINET_IN_H 1
#endif
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the <sys/fcntl.h> header file. */
/* #undef HAVE_SYS_FCNTL_H */
/* Define if you have the <sys/resource.h> header file. */
#ifdef DECC
# define HAVE_SYS_RESOURCE_H 1
#endif
/* Define if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
/* Define if you have the <sys/socket.h> header file. */
#ifdef DECC
# define HAVE_SYS_SOCKET_H 1
#endif
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#ifdef __GNUC__
# define HAVE_SYS_TIME_H 1
#endif
/* Define if you have the <sys/types.h> header file. */
#ifdef DECC
# define HAVE_SYS_TYPES_H 1
#endif
/* Define if you have the <sys/uio.h> header file. */
#ifdef DECC
# define HAVE_SYS_UIO_H 1
#endif
/* Define if you have the <unistd.h> header file. */
#ifdef __GNUC__
# define HAVE_UNISTD_H 1
#endif
/* Define if you have the malloc library (-lmalloc). */
/* #undef HAVE_LIBMALLOC */
/* Define if your compiler does not prototype accept(). */
/* #undef NEED_ACCEPT_PROTO */
/* Define if your compiler does not prototype atoi(). */
/* #undef NEED_ATOI_PROTO */
/* Define if your compiler does not prototype atol(). */
/* #undef NEED_ATOL_PROTO */
/* Define if your compiler does not prototype bind(). */
/* #undef NEED_BIND_PROTO */
/* Define if your compiler does not prototype bzero(). */
/* #undef NEED_BZERO_PROTO */
/* Define if your compiler does not prototype chdir(). */
/* #undef NEED_CHDIR_PROTO */
/* Define if your compiler does not prototype close(). */
/* #undef NEED_CLOSE_PROTO */
/* Define if your compiler does not prototype crypt(). */
/* #undef NEED_CRYPT_PROTO */
/* Define if your compiler does not prototype fclose(). */
/* #undef NEED_FCLOSE_PROTO */
/* Define if your compiler does not prototype fcntl(). */
/* #undef NEED_FCNTL_PROTO */
/* Define if your compiler does not prototype fflush(). */
/* #undef NEED_FFLUSH_PROTO */
/* Define if your compiler does not prototype fprintf(). */
/* #undef NEED_FPRINTF_PROTO */
/* Define if your compiler does not prototype fputc(). */
/* #undef NEED_FPUTC_PROTO */
/* Define if your compiler does not prototype fputs(). */
/* #undef NEED_FPUTS_PROTO */
/* Define if your compiler does not prototype fread(). */
/* #undef NEED_FREAD_PROTO */
/* Define if your compiler does not prototype fscanf(). */
/* #undef NEED_FSCANF_PROTO */
/* Define if your compiler does not prototype fseek(). */
/* #undef NEED_FSEEK_PROTO */
/* Define if your compiler does not prototype fwrite(). */
/* #undef NEED_FWRITE_PROTO */
/* Define if your compiler does not prototype getpeername(). */
/* #undef NEED_GETPEERNAME_PROTO */
/* Define if your compiler does not prototype getpid(). */
/* #undef NEED_GETPID_PROTO */
/* Define if your compiler does not prototype getrlimit(). */
/* #undef NEED_GETRLIMIT_PROTO */
/* Define if your compiler does not prototype getsockname(). */
/* #undef NEED_GETSOCKNAME_PROTO */
/* Define if your compiler does not prototype gettimeofday(). */
#ifdef DECC
# define NEED_GETTIMEOFDAY_PROTO 1
#endif
/* Define if your compiler does not prototype htonl(). */
/* #undef NEED_HTONL_PROTO */
/* Define if your compiler does not prototype htons(). */
/* #undef NEED_HTONS_PROTO */
/* Define if your compiler does not prototype inet_addr(). */
/* #undef NEED_INET_ADDR_PROTO */
/* Define if your compiler does not prototype inet_aton(). */
/* #undef NEED_INET_ATON_PROTO */
/* Define if your compiler does not prototype inet_ntoa(). */
/* #undef NEED_INET_NTOA_PROTO */
/* Define if your compiler does not prototype listen(). */
/* #undef NEED_LISTEN_PROTO */
/* Define if your compiler does not prototype ntohl(). */
/* #undef NEED_NTOHL_PROTO */
/* Define if your compiler does not prototype perror(). */
/* #undef NEED_PERROR_PROTO */
/* Define if your compiler does not prototype printf(). */
/* #undef NEED_PRINTF_PROTO */
/* Define if your compiler does not prototype qsort(). */
/* #undef NEED_QSORT_PROTO */
/* Define if your compiler does not prototype read(). */
/* #undef NEED_READ_PROTO */
/* Define if your compiler does not prototype remove(). */
/* #undef NEED_REMOVE_PROTO */
/* Define if your compiler does not prototype rewind(). */
/* #undef NEED_REWIND_PROTO */
/* Define if your compiler does not prototype select(). */
/* #undef NEED_SELECT_PROTO */
/* Define if your compiler does not prototype setitimer(). */
/* #undef NEED_SETITIMER_PROTO */
/* Define if your compiler does not prototype setrlimit(). */
/* #undef NEED_SETRLIMIT_PROTO */
/* Define if your compiler does not prototype setsockopt(). */
/* #undef NEED_SETSOCKOPT_PROTO */
/* Define if your compiler does not prototype socket(). */
/* #undef NEED_SOCKET_PROTO */
/* Define if your compiler does not prototype sprintf(). */
/* #undef NEED_SPRINTF_PROTO */
/* Define if your compiler does not prototype sscanf(). */
/* #undef NEED_SSCANF_PROTO */
/* Define if your compiler does not prototype strerror(). */
/* #undef NEED_STRERROR_PROTO */
/* Define if your compiler does not prototype system(). */
/* #undef NEED_SYSTEM_PROTO */
/* Define if your compiler does not prototype time(). */
/* #undef NEED_TIME_PROTO */
/* Define if your compiler does not prototype unlink(). */
/* #undef NEED_UNLINK_PROTO */
/* Define if your compiler does not prototype write(). */
/* #undef NEED_WRITE_PROTO */

336
src/conf.h.win Normal file
View file

@ -0,0 +1,336 @@
/*
* conf.h.win -- conf.h file for Windows 95/NT compilation; any compiler
* Created by Jeremy Elson, 1 July 1998
*/
#define CIRCLE_WINDOWS
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define to `int' if <sys/types.h> doesn't define. */
#define pid_t int
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if we're compiling CircleMUD under any type of UNIX system. */
#undef CIRCLE_UNIX
/* Define if the system is capable of using crypt() to encrypt. */
#undef CIRCLE_CRYPT
/* Define if we don't have proper support for the system's crypt(). */
#undef HAVE_UNSAFE_CRYPT
/* Define is the system has struct in_addr. */
#define HAVE_STRUCT_IN_ADDR 1
/* Define to `int' if <sys/socket.h> doesn't define. */
#define socklen_t int
/* Define to `int' if <sys/types.h> doesn't define. */
#define ssize_t int
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the inet_addr function. */
#define HAVE_INET_ADDR 1
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the snprintf function. */
#define HAVE_SNPRINTF 1
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the stricmp function. */
#define HAVE_STRICMP 1
/* Define if you have the strlcpy function. */
#undef HAVE_STRLCPY
/* Define if you have the strncasecmp function. */
#undef HAVE_STRNCASECMP
/* Define if you have the strnicmp function. */
#define HAVE_STRNICMP 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the vsnprintf function. */
#define HAVE_VSNPRINTF 1
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define if you have the <arpa/telnet.h> header file. */
#undef HAVE_ARPA_TELNET_H
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <mcheck.h> header file. */
#undef HAVE_MCHECK_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <net/errno.h> header file. */
#undef HAVE_NET_ERRNO_H
/* Define if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <sys/fcntl.h> header file. */
#undef HAVE_SYS_FCNTL_H
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/uio.h> header file. */
#undef HAVE_SYS_UIO_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the malloc library (-lmalloc). */
#undef HAVE_LIBMALLOC
/* Check for a prototype to accept. */
#undef NEED_ACCEPT_PROTO
/* Check for a prototype to atoi. */
#undef NEED_ATOI_PROTO
/* Check for a prototype to atol. */
#undef NEED_ATOL_PROTO
/* Check for a prototype to bind. */
#undef NEED_BIND_PROTO
/* Check for a prototype to bzero. */
#undef NEED_BZERO_PROTO
/* Check for a prototype to chdir. */
#undef NEED_CHDIR_PROTO
/* Check for a prototype to close. */
#undef NEED_CLOSE_PROTO
/* Check for a prototype to crypt. */
#undef NEED_CRYPT_PROTO
/* Check for a prototype to fclose. */
#undef NEED_FCLOSE_PROTO
/* Check for a prototype to fcntl. */
#undef NEED_FCNTL_PROTO
/* Check for a prototype to fflush. */
#undef NEED_FFLUSH_PROTO
/* Check for a prototype to fprintf. */
#undef NEED_FPRINTF_PROTO
/* Check for a prototype to fputc. */
#undef NEED_FPUTC_PROTO
/* Check for a prototype to fputs. */
#undef NEED_FPUTS_PROTO
/* Check for a prototype to fread. */
#undef NEED_FREAD_PROTO
/* Check for a prototype to fscanf. */
#undef NEED_FSCANF_PROTO
/* Check for a prototype to fseek. */
#undef NEED_FSEEK_PROTO
/* Check for a prototype to fwrite. */
#undef NEED_FWRITE_PROTO
/* Check for a prototype to getpeername. */
#undef NEED_GETPEERNAME_PROTO
/* Check for a prototype to getpid. */
#undef NEED_GETPID_PROTO
/* Check for a prototype to getrlimit. */
#undef NEED_GETRLIMIT_PROTO
/* Check for a prototype to getsockname. */
#undef NEED_GETSOCKNAME_PROTO
/* Check for a prototype to gettimeofday. */
#undef NEED_GETTIMEOFDAY_PROTO
/* Check for a prototype to htonl. */
#undef NEED_HTONL_PROTO
/* Check for a prototype to htons. */
#undef NEED_HTONS_PROTO
/* Check for a prototype to inet_addr. */
#undef NEED_INET_ADDR_PROTO
/* Check for a prototype to inet_aton. */
#undef NEED_INET_ATON_PROTO
/* Check for a prototype to inet_ntoa. */
#undef NEED_INET_NTOA_PROTO
/* Check for a prototype to listen. */
#undef NEED_LISTEN_PROTO
/* Check for a prototype to ntohl. */
#undef NEED_NTOHL_PROTO
/* Check for a prototype to perror. */
#undef NEED_PERROR_PROTO
/* Check for a prototype to printf. */
#undef NEED_PRINTF_PROTO
/* Check for a prototype to qsort. */
#undef NEED_QSORT_PROTO
/* Check for a prototype to read. */
#undef NEED_READ_PROTO
/* Check for a prototype to remove. */
#undef NEED_REMOVE_PROTO
/* Check for a prototype to rewind. */
#undef NEED_REWIND_PROTO
/* Check for a prototype to select. */
#undef NEED_SELECT_PROTO
/* Check for a prototype to setitimer. */
#undef NEED_SETITIMER_PROTO
/* Check for a prototype to setrlimit. */
#undef NEED_SETRLIMIT_PROTO
/* Check for a prototype to setsockopt. */
#undef NEED_SETSOCKOPT_PROTO
/* Check for a prototype to snprintf. */
#undef NEED_SNPRINTF_PROTO
/* Check for a prototype to socket. */
#undef NEED_SOCKET_PROTO
/* Check for a prototype to sprintf. */
#undef NEED_SPRINTF_PROTO
/* Check for a prototype to sscanf. */
#undef NEED_SSCANF_PROTO
/* Check for a prototype to strcasecmp. */
#undef NEED_STRCASECMP_PROTO
/* Check for a prototype to strdup. */
#undef NEED_STRDUP_PROTO
/* Check for a prototype to strerror. */
#undef NEED_STRERROR_PROTO
/* Check for a prototype to stricmp. */
#undef NEED_STRICMP_PROTO
/* Check for a prototype to strlcpy. */
#define NEED_STRLCPY_PROTO 1
/* Check for a prototype to strncasecmp. */
#undef NEED_STRNCASECMP_PROTO
/* Check for a prototype to strnicmp. */
#undef NEED_STRNICMP_PROTO
/* Check for a prototype to system. */
#undef NEED_SYSTEM_PROTO
/* Check for a prototype to time. */
#undef NEED_TIME_PROTO
/* Check for a prototype to unlink. */
#undef NEED_UNLINK_PROTO
/* Check for a prototype to vsnprintf. */
#undef NEED_VSNPRINTF_PROTO
/* Check for a prototype to write. */
#undef NEED_WRITE_PROTO

378
src/config.c Normal file
View file

@ -0,0 +1,378 @@
/* ************************************************************************
* File: config.c Part of CircleMUD *
* Usage: Configuration of various aspects of CircleMUD operation *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#define __CONFIG_C__
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "interpreter.h" /* alias_data definition for structs.h */
/*
* Update: The following constants and variables are now the default values
* for backwards compatibility with the new cedit game configurator. If you
* would not like to use the cedit command, you can change the values in
* this file instead. - Mythran
*/
/*
* Below are several constants which you can change to alter certain aspects
* of the way CircleMUD acts. Since this is a .c file, all you have to do
* to change one of the constants (assuming you keep your object files around)
* is change the constant in this file and type 'make'. Make will recompile
* this file and relink; you don't have to wait for the whole thing to
* recompile as you do if you change a header file.
*
* I realize that it would be slightly more efficient to have lots of
* #defines strewn about, so that, for example, the autowiz code isn't
* compiled at all if you don't want to use autowiz. However, the actual
* code for the various options is quite small, as is the computational time
* in checking the option you've selected at run-time, so I've decided the
* convenience of having all your options in this one file outweighs the
* efficency of doing it the other way.
*
*/
/****************************************************************************/
/****************************************************************************/
/* GAME PLAY OPTIONS */
#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, then players will not be allowed to kill, summon, charm, or sleep
* other players, as well as a variety of other "asshole player" protections.
* However, if you decide you want to have an all-out knock-down drag-out
* PK Mud, just set pk_allowed to YES - and anything goes.
*/
int pk_allowed = NO;
/* is playerthieving allowed? */
int pt_allowed = NO;
/* minimum level a player must be to shout/holler/gossip/auction */
int level_can_shout = 1;
/* number of movement points it costs to holler */
int holler_move_cost = 20;
/* how many people can get into a tunnel? The default is two, but there
* is also an alternate message in the case of one person being allowed.
*/
int tunnel_size = 2;
/* exp change limits */
int max_exp_gain = 100000; /* max gainable per kill */
int max_exp_loss = 500000; /* max losable per death */
/* number of tics (usually 75 seconds) before PC/NPC corpses decompose */
int max_npc_corpse_time = 5;
int max_pc_corpse_time = 10;
/* How many ticks before a player is sent to the void or idle-rented. */
int idle_void = 8;
int idle_rent_time = 48;
/* This level and up is immune to idling, LVL_IMPL+1 will disable it. */
int idle_max_level = LVL_GOD;
/* should items in death traps automatically be junked? */
int dts_are_dumps = YES;
/*
* Whether you want items that immortals load to appear on the ground or not.
* It is most likely best to set this to 'YES' so that something else doesn't
* grab the item before the immortal does, but that also means people will be
* able to carry around things like boards. That's not necessarily a bad
* thing, but this will be left at a default of 'NO' for historic reasons.
*/
int load_into_inventory = YES;
/* "okay" etc. */
const char *OK = "Okay.\r\n";
const char *NOPERSON = "No-one by that name here.\r\n";
const char *NOEFFECT = "Nothing seems to happen.\r\n";
/*
* You can define or not define TRACK_THOUGH_DOORS, depending on whether
* or not you want track to find paths which lead through closed or
* hidden doors. A setting of 'NO' means to not go through the doors
* while 'YES' will pass through doors to find the target.
*/
int track_through_doors = YES;
/*
* If you want mortals to level up to immortal once they have enough
* experience, then set this to 0. This is the stock behaviour for
* CircleMUD because it was the stock DikuMud behaviour. Subtracting
* this from LVL_IMMORT gives the top level that people can advance to
* in gain_exp() in limits.c
* For example, to stop people from advancing to LVL_IMMORT, simply set
* immort_level_ok to 1.
*/
int immort_level_ok = 0;
/****************************************************************************/
/****************************************************************************/
/* RENT/CRASHSAVE OPTIONS */
/*
* Should the MUD allow you to 'rent' for free? (i.e. if you just quit,
* your objects are saved at no cost, as in Merc-type MUDs.)
*/
int free_rent = YES;
/* maximum number of items players are allowed to rent */
int max_obj_save = 30;
/* receptionist's surcharge on top of item costs */
int min_rent_cost = 100;
/*
* Should the game automatically save people? (i.e., save player data
* every 4 kills (on average), and Crash-save as defined below. This
* option has an added meaning past bpl13. If auto_save is YES, then
* the 'save' command will be disabled to prevent item duplication via
* game crashes.
*/
int auto_save = YES;
/*
* if auto_save (above) is yes, how often (in minutes) should the MUD
* Crash-save people's objects? Also, this number indicates how often
* the MUD will Crash-save players' houses.
*/
int autosave_time = 5;
/* Lifetime of crashfiles and forced-rent (idlesave) files in days */
int crash_file_timeout = 10;
/* Lifetime of normal rent files in days */
int rent_file_timeout = 30;
/* Do you want to automatically wipe players who've been gone too long? */
int auto_pwipe = NO;
/* Autowipe deletion criteria
This struct holds information used to determine which players to wipe
then the mud boots. The levels must be in ascending order, with a
descending level marking the end of the array. A level -1 entry in the
beginning is the case for players with the PLR_DELETED flag. The
values below match the stock purgeplay.c criteria.
Detailed explanation by array element:
* Element 0, level -1, days 0: Players with PLR_DELETED flag are always wiped
* Element 1, level 0, days 0: Players at level 0 have created a
character, but have never actually entered the game, so always
wipe them.
* Element 2, level 1, days 4: Players at level 1 are wiped if they
haven't logged on in the past 4 days.
* Element 3, level 4, days 7: Players level 2 through 4 are wiped if
they haven't logged on in the past 7 days.
* Element 4, level 10, days 30: Players level 5-10 get 30 days.
* Element 5, level LVL_IMMORT - 1, days 60: All other mortals get
60 days.
* Element 6, level LVL_IMPL, days 90: Immortals get 90 days.
* Element 7: Because -2 is less than LVL_IMPL, this is assumed to
be the end of the criteria. The days entry is not used in this
case.
*/
struct pclean_criteria_data pclean_criteria[] = {
/* LEVEL DAYS */
{ 0 ,0 }, /* level 0 */
{ 1 ,4 },
{ 4 ,7 },
{ 10 ,30 },
{ LVL_IMMORT - 1 ,60 }, /* highest mortal */
{ LVL_IMPL ,90 }, /* all immortals */
{ -1 ,0 } /* no more level checks */
};
/* Do you want players who self-delete to be wiped immediately with no
backup?
*/
int selfdelete_fastwipe = YES;
/****************************************************************************/
/****************************************************************************/
/* ROOM NUMBERS */
/* virtual number of room that mortals should enter at */
room_vnum mortal_start_room = 3001;
/* virtual number of room that immorts should enter at by default */
room_vnum immort_start_room = 1204;
/* virtual number of room that frozen players should enter at */
room_vnum frozen_start_room = 1202;
/*
* virtual numbers of donation rooms. note: you must change code in
* do_drop of act.item.c if you change the number of non-NOWHERE
* donation rooms.
*/
room_vnum donation_room_1 = 3063;
room_vnum donation_room_2 = 5510; /* unused - room for expansion */
room_vnum donation_room_3 = 235; /* unused - room for expansion */
/****************************************************************************/
/****************************************************************************/
/* GAME OPERATION OPTIONS */
/*
* This is the default port on which the game should run if no port is
* given on the command-line. NOTE WELL: If you're using the
* 'autorun' script, the port number there will override this setting.
* Change the PORT= line in autorun instead of (or in addition to)
* changing this.
*/
ush_int DFLT_PORT = 4000;
/*
* IP address to which the MUD should bind. This is only useful if
* you're running Circle on a host that host more than one IP interface,
* and you only want to bind to *one* of them instead of all of them.
* Setting this to NULL (the default) causes Circle to bind to all
* interfaces on the host. Otherwise, specify a numeric IP address in
* dotted quad format, and Circle will only bind to that IP address. (Of
* course, that IP address must be one of your host's interfaces, or it
* won't work.)
*/
const char *DFLT_IP = NULL; /* bind to all interfaces */
/* const char *DFLT_IP = "192.168.1.1"; -- bind only to one interface */
/* default directory to use as data directory */
const char *DFLT_DIR = "lib";
/*
* What file to log messages to (ex: "log/syslog"). Setting this to NULL
* means you want to log to stderr, which was the default in earlier
* versions of Circle. If you specify a file, you don't get messages to
* the screen. (Hint: Try 'tail -f' if you have a UNIX machine.)
*/
const char *LOGNAME = NULL;
/* const char *LOGNAME = "log/syslog"; -- useful for Windows users */
/* maximum number of players allowed before game starts to turn people away */
int max_playing = 300;
/* maximum size of bug, typo and idea files in bytes (to prevent bombing) */
int max_filesize = 50000;
/* maximum number of password attempts before disconnection */
int max_bad_pws = 3;
/*
* Rationale for enabling this, as explained by naved@bird.taponline.com.
*
* Usually, when you select ban a site, it is because one or two people are
* causing troubles while there are still many people from that site who you
* want to still log on. Right now if I want to add a new select ban, I need
* to first add the ban, then SITEOK all the players from that site except for
* the one or two who I don't want logging on. Wouldn't it be more convenient
* to just have to remove the SITEOK flags from those people I want to ban
* rather than what is currently done?
*/
int siteok_everyone = TRUE;
/*
* Some nameservers are very slow and cause the game to lag terribly every
* time someone logs in. The lag is caused by the gethostbyaddr() function
* which is responsible for resolving numeric IP addresses to alphabetic names.
* Sometimes, nameservers can be so slow that the incredible lag caused by
* gethostbyaddr() isn't worth the luxury of having names instead of numbers
* for players' sitenames.
*
* If your nameserver is fast, set the variable below to NO. If your
* nameserver is slow, of it you would simply prefer to have numbers
* instead of names for some other reason, set the variable to YES.
*
* You can experiment with the setting of nameserver_is_slow on-line using
* the SLOWNS command from within the MUD.
*/
int nameserver_is_slow = NO;
/*
* Will changes save automaticaly in OLC ?
*/
int auto_save_olc = 1;
/*
* if you wish to enable Aedit, set this to 1
* This will make the mud look for a file called socials.new,
* which is in a different format than the stock socials file.
*/
int use_new_socials = 1;
const char *MENU =
"\r\n"
"Welcome to CircleMUD!\r\n"
"0) Exit from CircleMUD.\r\n"
"1) Enter the game.\r\n"
"2) Enter description.\r\n"
"3) Read the background story.\r\n"
"4) Change password.\r\n"
"5) Delete this character.\r\n"
"\r\n"
" Make your choice: ";
const char *WELC_MESSG =
"\r\n"
"Welcome to CircleMUD! May your visit here be... Interesting"
"\r\n\r\n";
const char *START_MESSG =
"Welcome. This is your new CircleMUD character! You can now earn gold,\r\n"
"gain experience, find weapons and equipment, and much more -- while\r\n"
"meeting people from around the world!\r\n";
/****************************************************************************/
/****************************************************************************/
/* AUTOWIZ OPTIONS */
/*
* Should the game automatically create a new wizlist/immlist every time
* someone immorts, or is promoted to a higher (or lower) god level?
* NOTE: this only works under UNIX systems.
*/
int use_autowiz = YES;
/* If yes, what is the lowest level which should be on the wizlist? (All
immort levels below the level you specify will go on the immlist instead.) */
int min_wizlist_lev = LVL_GOD;

916
src/constants.c Normal file
View file

@ -0,0 +1,916 @@
/* ************************************************************************
* File: constants.c Part of CircleMUD *
* Usage: Numeric and string contants used by the MUD *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "interpreter.h" /* alias_data */
cpp_extern const char *circlemud_version =
"CircleMUD, version 3.5";
cpp_extern const char *oasisolc_version =
"OasisOLC 2.0.6";
cpp_extern const char *ascii_pfiles_version =
"ASCII Player Files 3.0.1";
/* strings corresponding to ordinals/bitvectors in structs.h */
/* (Note: strings for class definitions in class.c instead of here) */
/* cardinal directions */
const char *dirs[] =
{
"north",
"east",
"south",
"west",
"up",
"down",
"\n"
};
/* ROOM_x */
const char *room_bits[] = {
"DARK",
"DEATH",
"NO_MOB",
"INDOORS",
"PEACEFUL",
"SOUNDPROOF",
"NO_TRACK",
"NO_MAGIC",
"TUNNEL",
"PRIVATE",
"GODROOM",
"HOUSE",
"HCRSH",
"ATRIUM",
"OLC",
"*", /* BFS MARK */
"\n"
};
/* EX_x */
const char *exit_bits[] = {
"DOOR",
"CLOSED",
"LOCKED",
"PICKPROOF",
"\n"
};
/* SECT_ */
const char *sector_types[] = {
"Inside",
"City",
"Field",
"Forest",
"Hills",
"Mountains",
"Water (Swim)",
"Water (No Swim)",
"In Flight",
"Underwater",
"\n"
};
/*
* SEX_x
* Not used in sprinttype() so no \n.
*/
const char *genders[] =
{
"neutral",
"male",
"female",
"\n"
};
/* POS_x */
const char *position_types[] = {
"Dead",
"Mortally wounded",
"Incapacitated",
"Stunned",
"Sleeping",
"Resting",
"Sitting",
"Fighting",
"Standing",
"\n"
};
/* PLR_x */
const char *player_bits[] = {
"KILLER",
"THIEF",
"FROZEN",
"DONTSET",
"WRITING",
"MAILING",
"CSH",
"SITEOK",
"NOSHOUT",
"NOTITLE",
"DELETED",
"LOADRM",
"NO_WIZL",
"NO_DEL",
"INVST",
"CRYO",
"DEAD", /* You should never see this. */
"UNUSED1",
"UNUSED2",
"UNUSED3",
"UNUSED4",
"UNUSED5",
"\n"
};
/* MOB_x */
const char *action_bits[] = {
"SPEC",
"SENTINEL",
"SCAVENGER",
"ISNPC",
"AWARE",
"AGGR",
"STAY-ZONE",
"WIMPY",
"AGGR_EVIL",
"AGGR_GOOD",
"AGGR_NEUTRAL",
"MEMORY",
"HELPER",
"NO_CHARM",
"NO_SUMMN",
"NO_SLEEP",
"NO_BASH",
"NO_BLIND",
"DEAD", /* You should never see this. */
"\n"
};
/* PRF_x */
const char *preference_bits[] = {
"BRIEF",
"COMPACT",
"DEAF",
"NO_TELL",
"D_HP",
"D_MANA",
"D_MOVE",
"AUTOEX",
"NO_HASS",
"QUEST",
"SUMN",
"NO_REP",
"LIGHT",
"C1",
"C2",
"NO_WIZ",
"L1",
"L2",
"NO_AUC",
"NO_GOS",
"NO_GTZ",
"RMFLG",
"D_AUTO",
"CLS",
"BLDWLK",
"AFK",
"UNUSED1",
"UNUSED2",
"UNUSED3",
"UNUSED4",
"UNUSED5",
"\n"
};
/* AFF_x */
const char *affected_bits[] =
{
"BLIND",
"INVIS",
"DET-ALIGN",
"DET-INVIS",
"DET-MAGIC",
"SENSE-LIFE",
"WATWALK",
"SANCT",
"GROUP",
"CURSE",
"INFRA",
"POISON",
"PROT-EVIL",
"PROT-GOOD",
"SLEEP",
"NO_TRACK",
"UNUSED",
"UNUSED",
"SNEAK",
"HIDE",
"UNUSED",
"CHARM",
"\n"
};
/* CON_x */
const char *connected_types[] = {
"Playing",
"Disconnecting",
"Get name",
"Confirm name",
"Get password",
"Get new PW",
"Confirm new PW",
"Select sex",
"Select class",
"Reading MOTD",
"Main Menu",
"Get descript.",
"Changing PW 1",
"Changing PW 2",
"Changing PW 3",
"Self-Delete 1",
"Self-Delete 2",
"Disconnecting",
"Object edit",
"Room edit",
"Zone edit",
"Mobile edit",
"Shop edit",
"Text edit",
"Config edit",
"Social edit",
"Trigger edit",
"Help edit",
"\n"
};
/*
* WEAR_x - for eq list
* Not use in sprinttype() so no \n.
*/
const char *wear_where[] = {
"<used as light> ",
"<worn on finger> ",
"<worn on finger> ",
"<worn around neck> ",
"<worn around neck> ",
"<worn on body> ",
"<worn on head> ",
"<worn on legs> ",
"<worn on feet> ",
"<worn on hands> ",
"<worn on arms> ",
"<worn as shield> ",
"<worn about body> ",
"<worn about waist> ",
"<worn around wrist> ",
"<worn around wrist> ",
"<wielded> ",
"<held> "
};
/* WEAR_x - for stat */
const char *equipment_types[] = {
"Used as light",
"Worn on right finger",
"Worn on left finger",
"First worn around Neck",
"Second worn around Neck",
"Worn on body",
"Worn on head",
"Worn on legs",
"Worn on feet",
"Worn on hands",
"Worn on arms",
"Worn as shield",
"Worn about body",
"Worn around waist",
"Worn around right wrist",
"Worn around left wrist",
"Wielded",
"Held",
"\n"
};
/* ITEM_x (ordinal object types) */
const char *item_types[] = {
"UNDEFINED",
"LIGHT",
"SCROLL",
"WAND",
"STAFF",
"WEAPON",
"FIRE WEAPON",
"MISSILE",
"TREASURE",
"ARMOR",
"POTION",
"WORN",
"OTHER",
"TRASH",
"TRAP",
"CONTAINER",
"NOTE",
"LIQ CONTAINER",
"KEY",
"FOOD",
"MONEY",
"PEN",
"BOAT",
"FOUNTAIN",
"\n"
};
/* ITEM_WEAR_ (wear bitvector) */
const char *wear_bits[] = {
"TAKE",
"FINGER",
"NECK",
"BODY",
"HEAD",
"LEGS",
"FEET",
"HANDS",
"ARMS",
"SHIELD",
"ABOUT",
"WAIST",
"WRIST",
"WIELD",
"HOLD",
"\n"
};
/* ITEM_x (extra bits) */
const char *extra_bits[] = {
"GLOW",
"HUM",
"NO_RENT",
"NO_DONATE",
"NO_INVIS",
"INVISIBLE",
"MAGIC",
"NO_DROP",
"BLESS",
"ANTI_GOOD",
"ANTI_EVIL",
"ANTI_NEUTRAL",
"ANTI_MAGE",
"ANTI_CLERIC",
"ANTI_THIEF",
"ANTI_WARRIOR",
"NO_SELL",
"\n"
};
/* APPLY_x */
const char *apply_types[] = {
"NONE",
"STR",
"DEX",
"INT",
"WIS",
"CON",
"CHA",
"CLASS",
"LEVEL",
"AGE",
"CHAR_WEIGHT",
"CHAR_HEIGHT",
"MAXMANA",
"MAXHIT",
"MAXMOVE",
"GOLD",
"EXP",
"ARMOR",
"HITROLL",
"DAMROLL",
"SAVING_PARA",
"SAVING_ROD",
"SAVING_PETRI",
"SAVING_BREATH",
"SAVING_SPELL",
"\n"
};
/* CONT_x */
const char *container_bits[] = {
"CLOSEABLE",
"PICKPROOF",
"CLOSED",
"LOCKED",
"\n",
};
/* LIQ_x */
const char *drinks[] =
{
"water",
"beer",
"wine",
"ale",
"dark ale",
"whisky",
"lemonade",
"firebreather",
"local speciality",
"slime mold juice",
"milk",
"tea",
"coffee",
"blood",
"salt water",
"clear water",
"\n"
};
/* other constants for liquids ******************************************/
/* one-word alias for each drink */
const char *drinknames[] =
{
"water",
"beer",
"wine",
"ale",
"ale",
"whisky",
"lemonade",
"firebreather",
"local",
"juice",
"milk",
"tea",
"coffee",
"blood",
"salt",
"water",
"\n"
};
/* effect of drinks on hunger, thirst, and drunkenness -- see values.doc */
int drink_aff[][3] = {
{0, 1, 10},
{3, 2, 5},
{5, 2, 5},
{2, 2, 5},
{1, 2, 5},
{6, 1, 4},
{0, 1, 8},
{10, 0, 0},
{3, 3, 3},
{0, 4, -8},
{0, 3, 6},
{0, 1, 6},
{0, 1, 6},
{0, 2, -1},
{0, 1, -2},
{0, 0, 13}
};
/* color of the various drinks */
const char *color_liquid[] =
{
"clear",
"brown",
"clear",
"brown",
"dark",
"golden",
"red",
"green",
"clear",
"light green",
"white",
"brown",
"black",
"red",
"clear",
"crystal clear",
"\n"
};
/*
* level of fullness for drink containers
* Not used in sprinttype() so no \n.
*/
const char *fullness[] =
{
"less than half ",
"about half ",
"more than half ",
""
};
/* str, int, wis, dex, con applies **************************************/
/* [ch] strength apply (all) */
cpp_extern const struct str_app_type str_app[] = {
{-5, -4, 0, 0}, /* str = 0 */
{-5, -4, 3, 1}, /* str = 1 */
{-3, -2, 3, 2},
{-3, -1, 10, 3},
{-2, -1, 25, 4},
{-2, -1, 55, 5}, /* str = 5 */
{-1, 0, 80, 6},
{-1, 0, 90, 7},
{0, 0, 100, 8},
{0, 0, 100, 9},
{0, 0, 115, 10}, /* str = 10 */
{0, 0, 115, 11},
{0, 0, 140, 12},
{0, 0, 140, 13},
{0, 0, 170, 14},
{0, 0, 170, 15}, /* str = 15 */
{0, 1, 195, 16},
{1, 1, 220, 18},
{1, 2, 255, 20}, /* str = 18 */
{3, 7, 640, 40},
{3, 8, 700, 40}, /* str = 20 */
{4, 9, 810, 40},
{4, 10, 970, 40},
{5, 11, 1130, 40},
{6, 12, 1440, 40},
{7, 14, 1750, 40}, /* str = 25 */
{1, 3, 280, 22}, /* str = 18/0 - 18-50 */
{2, 3, 305, 24}, /* str = 18/51 - 18-75 */
{2, 4, 330, 26}, /* str = 18/76 - 18-90 */
{2, 5, 380, 28}, /* str = 18/91 - 18-99 */
{3, 6, 480, 30} /* str = 18/100 */
};
/* [dex] skill apply (thieves only) */
cpp_extern const struct dex_skill_type dex_app_skill[] = {
{-99, -99, -90, -99, -60}, /* dex = 0 */
{-90, -90, -60, -90, -50}, /* dex = 1 */
{-80, -80, -40, -80, -45},
{-70, -70, -30, -70, -40},
{-60, -60, -30, -60, -35},
{-50, -50, -20, -50, -30}, /* dex = 5 */
{-40, -40, -20, -40, -25},
{-30, -30, -15, -30, -20},
{-20, -20, -15, -20, -15},
{-15, -10, -10, -20, -10},
{-10, -5, -10, -15, -5}, /* dex = 10 */
{-5, 0, -5, -10, 0},
{0, 0, 0, -5, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}, /* dex = 15 */
{0, 5, 0, 0, 0},
{5, 10, 0, 5, 5},
{10, 15, 5, 10, 10}, /* dex = 18 */
{15, 20, 10, 15, 15},
{15, 20, 10, 15, 15}, /* dex = 20 */
{20, 25, 10, 15, 20},
{20, 25, 15, 20, 20},
{25, 25, 15, 20, 20},
{25, 30, 15, 25, 25},
{25, 30, 15, 25, 25} /* dex = 25 */
};
/* [dex] apply (all) */
cpp_extern const struct dex_app_type dex_app[] = {
{-7, -7, 6}, /* dex = 0 */
{-6, -6, 5}, /* dex = 1 */
{-4, -4, 5},
{-3, -3, 4},
{-2, -2, 3},
{-1, -1, 2}, /* dex = 5 */
{0, 0, 1},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0}, /* dex = 10 */
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, -1}, /* dex = 15 */
{1, 1, -2},
{2, 2, -3},
{2, 2, -4}, /* dex = 18 */
{3, 3, -4},
{3, 3, -4}, /* dex = 20 */
{4, 4, -5},
{4, 4, -5},
{4, 4, -5},
{5, 5, -6},
{5, 5, -6} /* dex = 25 */
};
/* [con] apply (all) */
cpp_extern const struct con_app_type con_app[] = {
{-4, 20}, /* con = 0 */
{-3, 25}, /* con = 1 */
{-2, 30},
{-2, 35},
{-1, 40},
{-1, 45}, /* con = 5 */
{-1, 50},
{0, 55},
{0, 60},
{0, 65},
{0, 70}, /* con = 10 */
{0, 75},
{0, 80},
{0, 85},
{0, 88},
{1, 90}, /* con = 15 */
{2, 95},
{2, 97},
{3, 99}, /* con = 18 */
{3, 99},
{4, 99}, /* con = 20 */
{5, 99},
{5, 99},
{5, 99},
{6, 99},
{6, 99} /* con = 25 */
};
/* [int] apply (all) */
cpp_extern const struct int_app_type int_app[] = {
{3}, /* int = 0 */
{5}, /* int = 1 */
{7},
{8},
{9},
{10}, /* int = 5 */
{11},
{12},
{13},
{15},
{17}, /* int = 10 */
{19},
{22},
{25},
{30},
{35}, /* int = 15 */
{40},
{45},
{50}, /* int = 18 */
{53},
{55}, /* int = 20 */
{56},
{57},
{58},
{59},
{60} /* int = 25 */
};
/* [wis] apply (all) */
cpp_extern const struct wis_app_type wis_app[] = {
{0}, /* wis = 0 */
{0}, /* wis = 1 */
{0},
{0},
{0},
{0}, /* wis = 5 */
{0},
{0},
{0},
{0},
{0}, /* wis = 10 */
{0},
{2},
{2},
{3},
{3}, /* wis = 15 */
{3},
{4},
{5}, /* wis = 18 */
{6},
{6}, /* wis = 20 */
{6},
{6},
{7},
{7},
{7} /* wis = 25 */
};
const char *npc_class_types[] = {
"Normal",
"Undead",
"\n"
};
int rev_dir[] =
{
2,
3,
0,
1,
5,
4
};
int movement_loss[] =
{
1, /* Inside */
1, /* City */
2, /* Field */
3, /* Forest */
4, /* Hills */
6, /* Mountains */
4, /* Swimming */
1, /* Unswimable */
1, /* Flying */
5 /* Underwater */
};
/* Not used in sprinttype(). */
const char *weekdays[] = {
"the Day of the Moon",
"the Day of the Bull",
"the Day of the Deception",
"the Day of Thunder",
"the Day of Freedom",
"the Day of the Great Gods",
"the Day of the Sun"
};
/* Not used in sprinttype(). */
const char *month_name[] = {
"Month of Winter", /* 0 */
"Month of the Winter Wolf",
"Month of the Frost Giant",
"Month of the Old Forces",
"Month of the Grand Struggle",
"Month of the Spring",
"Month of Nature",
"Month of Futility",
"Month of the Dragon",
"Month of the Sun",
"Month of the Heat",
"Month of the Battle",
"Month of the Dark Shades",
"Month of the Shadows",
"Month of the Long Shadows",
"Month of the Ancient Darkness",
"Month of the Great Evil"
};
/* mob trigger types */
const char *trig_types[] = {
"Global",
"Random",
"Command",
"Speech",
"Act",
"Death",
"Greet",
"Greet-All",
"Entry",
"Receive",
"Fight",
"HitPrcnt",
"Bribe",
"Load",
"Memory",
"Cast",
"Leave",
"Door",
"UNUSED",
"Time",
"\n"
};
/* obj trigger types */
const char *otrig_types[] = {
"Global",
"Random",
"Command",
"UNUSED",
"UNUSED",
"Timer",
"Get",
"Drop",
"Give",
"Wear",
"UNUSED",
"Remove",
"UNUSED",
"Load",
"UNUSED",
"Cast",
"Leave",
"UNUSED",
"Consume",
"Time",
"\n"
};
/* wld trigger types */
const char *wtrig_types[] = {
"Global",
"Random",
"Command",
"Speech",
"UNUSED",
"Zone Reset",
"Enter",
"Drop",
"UNUSED",
"UNUSED",
"UNUSED",
"UNUSED",
"UNUSED",
"UNUSED",
"UNUSED",
"Cast",
"Leave",
"Door",
"UNUSED",
"Time",
"\n"
};
#if defined(CONFIG_OASIS_MPROG)
/*
* Definitions necessary for MobProg support in OasisOLC
*/
const char *mobprog_types[] = {
"INFILE",
"ACT",
"SPEECH",
"RAND",
"FIGHT",
"DEATH",
"HITPRCNT",
"ENTRY",
"GREET",
"ALL_GREET",
"GIVE",
"BRIBE",
"\n"
};
#endif
/* --- End of constants arrays. --- */
/*
* 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.
*/
size_t room_bits_count = sizeof(room_bits) / sizeof(room_bits[0]) - 1,
action_bits_count = sizeof(action_bits) / sizeof(action_bits[0]) - 1,
affected_bits_count = sizeof(affected_bits) / sizeof(affected_bits[0]) - 1,
extra_bits_count = sizeof(extra_bits) / sizeof(extra_bits[0]) - 1,
wear_bits_count = sizeof(wear_bits) / sizeof(wear_bits[0]) - 1;

48
src/constants.h Normal file
View file

@ -0,0 +1,48 @@
extern const char *circlemud_version;
extern const char *oasisolc_version;
extern const char *ascii_pfiles_version;
extern const char *dirs[];
extern const char *room_bits[];
extern const char *exit_bits[];
extern const char *sector_types[];
extern const char *genders[];
extern const char *position_types[];
extern const char *player_bits[];
extern const char *action_bits[];
extern const char *preference_bits[];
extern const char *affected_bits[];
extern const char *connected_types[];
extern const char *wear_where[];
extern const char *equipment_types[];
extern const char *item_types[];
extern const char *wear_bits[];
extern const char *extra_bits[];
extern const char *apply_types[];
extern const char *container_bits[];
extern const char *drinks[];
extern const char *drinknames[];
extern const char *color_liquid[];
extern const char *fullness[];
extern const char *npc_class_types[];
extern const char *weekdays[];
extern const char *month_name[];
extern const struct str_app_type str_app[];
extern const struct dex_skill_type dex_app_skill[];
extern const struct dex_app_type dex_app[];
extern const struct con_app_type con_app[];
extern const struct int_app_type int_app[];
extern const struct wis_app_type wis_app[];
extern int rev_dir[];
extern int movement_loss[];
extern int drink_aff[][3];
extern const char *trig_types[];
extern const char *otrig_types[];
extern const char *wtrig_types[];
#if defined(CONFIG_OASIS_MPROG)
extern const char *mobprog_types[];
#endif
extern size_t room_bits_count;
extern size_t action_bits_count;
extern size_t affected_bits_count;
extern size_t extra_bits_count;
extern size_t wear_bits_count;

271
src/context_help.c Normal file
View file

@ -0,0 +1,271 @@
/*
* The functions below this point is handling the context sensitive help system
* If you add more olc options, be sure to add a case for it here. - Welcor
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "interpreter.h"
#include "oasis.h"
#include "dg_olc.h"
/* Extern functions */
ACMD(do_help);
/* local global */
char *context_help_list[NUM_CONTEXTS];
int find_context(struct descriptor_data *d)
{
switch STATE(d) {
case CON_TRIGEDIT: return find_context_trigedit(d);
case CON_REDIT: return find_context_redit(d);
case CON_MEDIT: return find_context_medit(d);
case CON_OEDIT: return find_context_oedit(d);
case CON_ZEDIT: return find_context_zedit(d);
case CON_SEDIT: return find_context_sedit(d);
default: return NOTHING;
}
}
int find_context_oedit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case OEDIT_MAIN_MENU: return CONTEXT_OEDIT_MAIN_MENU;
case OEDIT_EDIT_NAMELIST: return CONTEXT_OEDIT_EDIT_NAMELIST;
case OEDIT_SHORTDESC: return CONTEXT_OEDIT_SHORTDESC;
case OEDIT_LONGDESC: return CONTEXT_OEDIT_LONGDESC;
case OEDIT_ACTDESC: return CONTEXT_OEDIT_ACTDESC;
case OEDIT_TYPE: return CONTEXT_OEDIT_TYPE;
case OEDIT_EXTRAS: return CONTEXT_OEDIT_EXTRAS;
case OEDIT_WEAR: return CONTEXT_OEDIT_WEAR;
case OEDIT_WEIGHT: return CONTEXT_OEDIT_WEIGHT;
case OEDIT_COST: return CONTEXT_OEDIT_COST;
case OEDIT_COSTPERDAY: return CONTEXT_OEDIT_COSTPERDAY;
case OEDIT_TIMER: return CONTEXT_OEDIT_TIMER;
case OEDIT_VALUE_1: return CONTEXT_OEDIT_VALUE_1;
case OEDIT_VALUE_2: return CONTEXT_OEDIT_VALUE_2;
case OEDIT_VALUE_3: return CONTEXT_OEDIT_VALUE_3;
case OEDIT_VALUE_4: return CONTEXT_OEDIT_VALUE_4;
case OEDIT_APPLY: return CONTEXT_OEDIT_APPLY;
case OEDIT_APPLYMOD: return CONTEXT_OEDIT_APPLYMOD;
case OEDIT_EXTRADESC_KEY: return CONTEXT_OEDIT_EXTRADESC_KEY;
case OEDIT_CONFIRM_SAVEDB: return CONTEXT_OEDIT_CONFIRM_SAVEDB;
case OEDIT_CONFIRM_SAVESTRING: return CONTEXT_OEDIT_CONFIRM_SAVESTRING;
case OEDIT_PROMPT_APPLY: return CONTEXT_OEDIT_PROMPT_APPLY;
case OEDIT_EXTRADESC_DESCRIPTION: return CONTEXT_OEDIT_EXTRADESC_DESCRIPTION;
case OEDIT_EXTRADESC_MENU: return CONTEXT_OEDIT_EXTRADESC_MENU;
case OEDIT_LEVEL: return CONTEXT_OEDIT_LEVEL;
case OEDIT_PERM: return CONTEXT_OEDIT_PERM;
case OLC_SCRIPT_EDIT: return find_context_script_edit(d);
default: return NOTHING;
}
}
int find_context_redit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case REDIT_MAIN_MENU: return CONTEXT_REDIT_MAIN_MENU;
case REDIT_NAME: return CONTEXT_REDIT_NAME;
case REDIT_DESC: return CONTEXT_REDIT_DESC;
case REDIT_FLAGS: return CONTEXT_REDIT_FLAGS;
case REDIT_SECTOR: return CONTEXT_REDIT_SECTOR;
case REDIT_EXIT_MENU: return CONTEXT_REDIT_EXIT_MENU;
case REDIT_CONFIRM_SAVEDB: return CONTEXT_REDIT_CONFIRM_SAVEDB;
case REDIT_CONFIRM_SAVESTRING: return CONTEXT_REDIT_CONFIRM_SAVESTRING;
case REDIT_EXIT_NUMBER: return CONTEXT_REDIT_EXIT_NUMBER;
case REDIT_EXIT_DESCRIPTION: return CONTEXT_REDIT_EXIT_DESCRIPTION;
case REDIT_EXIT_KEYWORD: return CONTEXT_REDIT_EXIT_KEYWORD;
case REDIT_EXIT_KEY: return CONTEXT_REDIT_EXIT_KEY;
case REDIT_EXIT_DOORFLAGS: return CONTEXT_REDIT_EXIT_DOORFLAGS;
case REDIT_EXTRADESC_MENU: return CONTEXT_REDIT_EXTRADESC_MENU;
case REDIT_EXTRADESC_KEY: return CONTEXT_REDIT_EXTRADESC_KEY;
case REDIT_EXTRADESC_DESCRIPTION:return CONTEXT_REDIT_EXTRADESC_DESCRIPTION;
case OLC_SCRIPT_EDIT: return find_context_script_edit(d);
default: return NOTHING;
}
}
int find_context_zedit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case ZEDIT_MAIN_MENU: return CONTEXT_ZEDIT_MAIN_MENU;
case ZEDIT_DELETE_ENTRY: return CONTEXT_ZEDIT_DELETE_ENTRY;
case ZEDIT_NEW_ENTRY: return CONTEXT_ZEDIT_NEW_ENTRY;
case ZEDIT_CHANGE_ENTRY: return CONTEXT_ZEDIT_CHANGE_ENTRY;
case ZEDIT_COMMAND_TYPE: return CONTEXT_ZEDIT_COMMAND_TYPE;
case ZEDIT_IF_FLAG: return CONTEXT_ZEDIT_IF_FLAG;
case ZEDIT_ARG1: return CONTEXT_ZEDIT_ARG1;
case ZEDIT_ARG2: return CONTEXT_ZEDIT_ARG2;
case ZEDIT_ARG3: return CONTEXT_ZEDIT_ARG3;
case ZEDIT_ZONE_NAME: return CONTEXT_ZEDIT_ZONE_NAME;
case ZEDIT_ZONE_LIFE: return CONTEXT_ZEDIT_ZONE_LIFE;
case ZEDIT_ZONE_BOT: return CONTEXT_ZEDIT_ZONE_BOT;
case ZEDIT_ZONE_TOP: return CONTEXT_ZEDIT_ZONE_TOP;
case ZEDIT_ZONE_RESET: return CONTEXT_ZEDIT_ZONE_RESET;
case ZEDIT_CONFIRM_SAVESTRING:return CONTEXT_ZEDIT_CONFIRM_SAVESTRING;
case ZEDIT_SARG1: return CONTEXT_ZEDIT_SARG1;
case ZEDIT_SARG2: return CONTEXT_ZEDIT_SARG2;
default: return NOTHING;
}
}
int find_context_medit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case MEDIT_MAIN_MENU: return CONTEXT_MEDIT_MAIN_MENU;
case MEDIT_ALIAS: return CONTEXT_MEDIT_ALIAS;
case MEDIT_S_DESC: return CONTEXT_MEDIT_S_DESC;
case MEDIT_L_DESC: return CONTEXT_MEDIT_L_DESC;
case MEDIT_D_DESC: return CONTEXT_MEDIT_D_DESC;
case MEDIT_NPC_FLAGS: return CONTEXT_MEDIT_NPC_FLAGS;
case MEDIT_AFF_FLAGS: return CONTEXT_MEDIT_AFF_FLAGS;
case MEDIT_CONFIRM_SAVESTRING:return CONTEXT_MEDIT_CONFIRM_SAVESTRING;
case MEDIT_SEX: return CONTEXT_MEDIT_SEX;
case MEDIT_HITROLL: return CONTEXT_MEDIT_HITROLL;
case MEDIT_DAMROLL: return CONTEXT_MEDIT_DAMROLL;
case MEDIT_NDD: return CONTEXT_MEDIT_NDD;
case MEDIT_SDD: return CONTEXT_MEDIT_SDD;
case MEDIT_NUM_HP_DICE: return CONTEXT_MEDIT_NUM_HP_DICE;
case MEDIT_SIZE_HP_DICE: return CONTEXT_MEDIT_SIZE_HP_DICE;
case MEDIT_ADD_HP: return CONTEXT_MEDIT_ADD_HP;
case MEDIT_AC: return CONTEXT_MEDIT_AC;
case MEDIT_EXP: return CONTEXT_MEDIT_EXP;
case MEDIT_GOLD: return CONTEXT_MEDIT_GOLD;
case MEDIT_POS: return CONTEXT_MEDIT_POS;
case MEDIT_DEFAULT_POS: return CONTEXT_MEDIT_DEFAULT_POS;
case MEDIT_ATTACK: return CONTEXT_MEDIT_ATTACK;
case MEDIT_LEVEL: return CONTEXT_MEDIT_LEVEL;
case MEDIT_ALIGNMENT: return CONTEXT_MEDIT_ALIGNMENT;
case OLC_SCRIPT_EDIT: return find_context_script_edit(d);
default: return NOTHING;
}
}
int find_context_sedit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case SEDIT_MAIN_MENU: return CONTEXT_SEDIT_MAIN_MENU;
case SEDIT_CONFIRM_SAVESTRING:return CONTEXT_SEDIT_CONFIRM_SAVESTRING;
case SEDIT_NOITEM1: return CONTEXT_SEDIT_NOITEM1;
case SEDIT_NOITEM2: return CONTEXT_SEDIT_NOITEM2;
case SEDIT_NOCASH1: return CONTEXT_SEDIT_NOCASH1;
case SEDIT_NOCASH2: return CONTEXT_SEDIT_NOCASH2;
case SEDIT_NOBUY: return CONTEXT_SEDIT_NOBUY;
case SEDIT_BUY: return CONTEXT_SEDIT_BUY;
case SEDIT_SELL: return CONTEXT_SEDIT_SELL;
case SEDIT_PRODUCTS_MENU: return CONTEXT_SEDIT_PRODUCTS_MENU;
case SEDIT_ROOMS_MENU: return CONTEXT_SEDIT_ROOMS_MENU;
case SEDIT_NAMELIST_MENU: return CONTEXT_SEDIT_NAMELIST_MENU;
case SEDIT_NAMELIST: return CONTEXT_SEDIT_NAMELIST;
case SEDIT_OPEN1: return CONTEXT_SEDIT_OPEN1;
case SEDIT_OPEN2: return CONTEXT_SEDIT_OPEN2;
case SEDIT_CLOSE1: return CONTEXT_SEDIT_CLOSE1;
case SEDIT_CLOSE2: return CONTEXT_SEDIT_CLOSE2;
case SEDIT_KEEPER: return CONTEXT_SEDIT_KEEPER;
case SEDIT_BUY_PROFIT: return CONTEXT_SEDIT_BUY_PROFIT;
case SEDIT_SELL_PROFIT: return CONTEXT_SEDIT_SELL_PROFIT;
case SEDIT_TYPE_MENU: return CONTEXT_SEDIT_TYPE_MENU;
case SEDIT_DELETE_TYPE: return CONTEXT_SEDIT_DELETE_TYPE;
case SEDIT_DELETE_PRODUCT: return CONTEXT_SEDIT_DELETE_PRODUCT;
case SEDIT_NEW_PRODUCT: return CONTEXT_SEDIT_NEW_PRODUCT;
case SEDIT_DELETE_ROOM: return CONTEXT_SEDIT_DELETE_ROOM;
case SEDIT_NEW_ROOM: return CONTEXT_SEDIT_NEW_ROOM;
case SEDIT_SHOP_FLAGS: return CONTEXT_SEDIT_SHOP_FLAGS;
case SEDIT_NOTRADE: return CONTEXT_SEDIT_NOTRADE;
default: return NOTHING;
}
}
int find_context_trigedit(struct descriptor_data *d)
{
switch (OLC_MODE(d)) {
case TRIGEDIT_MAIN_MENU: return CONTEXT_TRIGEDIT_MAIN_MENU;
case TRIGEDIT_TRIGTYPE: return CONTEXT_TRIGEDIT_TRIGTYPE;
case TRIGEDIT_CONFIRM_SAVESTRING:return CONTEXT_TRIGEDIT_CONFIRM_SAVESTRING;
case TRIGEDIT_NAME: return CONTEXT_TRIGEDIT_NAME;
case TRIGEDIT_INTENDED: return CONTEXT_TRIGEDIT_INTENDED;
case TRIGEDIT_TYPES: return CONTEXT_TRIGEDIT_TYPES;
case TRIGEDIT_COMMANDS: return CONTEXT_TRIGEDIT_COMMANDS;
case TRIGEDIT_NARG: return CONTEXT_TRIGEDIT_NARG;
case TRIGEDIT_ARGUMENT: return CONTEXT_TRIGEDIT_ARGUMENT;
default: return NOTHING;
}
}
int find_context_script_edit(struct descriptor_data *d)
{
switch (OLC_SCRIPT_EDIT_MODE(d)) {
case SCRIPT_MAIN_MENU: return CONTEXT_SCRIPT_MAIN_MENU;
case SCRIPT_NEW_TRIGGER:return CONTEXT_SCRIPT_NEW_TRIGGER;
case SCRIPT_DEL_TRIGGER:return CONTEXT_SCRIPT_DEL_TRIGGER;
default: return NOTHING;
}
}
char *NO_HELP = "No help available (yet)!\r\n";
#define FIND_HELP_CHAR '*'
int context_help(struct descriptor_data *d, char *arg)
{
int context = NOTHING;
char actbuf[MAX_INPUT_LENGTH], *tmp;
/* skip if context help isn't wanted */
if (strncmp(arg, CONTEXT_HELP_STRING, strlen(CONTEXT_HELP_STRING)))
return FALSE;
tmp = one_argument(arg, actbuf); /* the totally useless 'help' string.. */
skip_spaces(&tmp);
if (!*tmp)
context = find_context(d);
if (context != NOTHING && context < NUM_CONTEXTS && *context_help_list[context]) {
if (*context_help_list[context] == FIND_HELP_CHAR) {
strncpy(actbuf, context_help_list[context]+1, sizeof(actbuf)-1);
do_help(d->character, actbuf, 0, 0);
} else {
write_to_output(d, "\r\n%s\r\n> ", context_help_list[context]);
}
return TRUE;
}
strncpy(actbuf, tmp, sizeof(actbuf)-1);
do_help(d->character, actbuf, 0, 0);
return TRUE;
}
void boot_context_help(void) {
int i, num;
FILE *fl;
char line[READ_SIZE];
fl = fopen(CONTEXT_HELP_FILE, "r");
/* init to 'no help' string */
for (i=0;i < NUM_CONTEXTS;i++)
context_help_list[i] = NO_HELP;
if (!fl) {
log("No context help found : %s", strerror(errno));
return;
}
while (get_line(fl, line)) {
if (sscanf(line, "#%d *", &num) == 1 && num >= 0 && num < NUM_CONTEXTS) /* got a number, now get the text */
context_help_list[num] = fread_string(fl, "Context sensitive help");
}
fclose(fl);
}
void free_context_help(void) {
int i;
for (i = 0; i < NUM_CONTEXTS; i++)
if (context_help_list[i] && context_help_list[i] != NO_HELP)
free(context_help_list[i]);
}

3382
src/db.c Normal file

File diff suppressed because it is too large Load diff

305
src/db.h Normal file
View file

@ -0,0 +1,305 @@
/* ************************************************************************
* File: db.h Part of CircleMUD *
* Usage: header file for database handling *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
/* arbitrary constants used by index_boot() (must be unique) */
#define DB_BOOT_WLD 0
#define DB_BOOT_MOB 1
#define DB_BOOT_OBJ 2
#define DB_BOOT_ZON 3
#define DB_BOOT_SHP 4
#define DB_BOOT_HLP 5
#define DB_BOOT_TRG 6
#if defined(CIRCLE_MACINTOSH)
#define LIB_WORLD ":world:"
#define LIB_TEXT ":text:"
#define LIB_TEXT_HEDIT ":text:hedit:"
#define LIB_MISC ":misc:"
#define LIB_ETC ":etc:"
#define LIB_PLRTEXT ":plrtext:"
#define LIB_PLROBJS ":plrobjs:"
#define LIB_PLRVARS ":plrvars:"
#define LIB_PLRALIAS ":plralias:"
#define LIB_PLRFILES ":plrfiles:"
#define LIB_HOUSE ":house:"
#define SLASH ":"
#elif defined(CIRCLE_AMIGA) || defined(CIRCLE_UNIX) || defined(CIRCLE_WINDOWS) || defined(CIRCLE_ACORN) || defined(CIRCLE_VMS)
#define LIB_WORLD "world/"
#define LIB_TEXT "text/"
#define LIB_TEXT_HEDIT "text/hedit/"
#define LIB_MISC "misc/"
#define LIB_ETC "etc/"
#define LIB_PLRTEXT "plrtext/"
#define LIB_PLROBJS "plrobjs/"
#define LIB_PLRVARS "plrvars/"
#define LIB_PLRALIAS "plralias/"
#define LIB_HOUSE "house/"
#define LIB_PLRFILES "plrfiles/"
#define SLASH "/"
#else
#error "Unknown path components."
#endif
#define SUF_OBJS "objs"
#define SUF_TEXT "text"
#define SUF_ALIAS "alias"
#define SUF_MEM "mem"
#define SUF_PLR "plr"
#if defined(CIRCLE_AMIGA)
#define EXE_FILE "/bin/circle" /* maybe use argv[0] but it's not reliable */
#define KILLSCRIPT_FILE "/.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "/pause" /* autorun: don't restart mud */
#elif defined(CIRCLE_MACINTOSH)
#define EXE_FILE "::bin:circle" /* maybe use argv[0] but it's not reliable */
#define FASTBOOT_FILE "::.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "::.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "::pause" /* autorun: don't restart mud */
#else
#define EXE_FILE "bin/circle" /* maybe use argv[0] but it's not reliable */
#define FASTBOOT_FILE "../.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "../.killscript"/* autorun: shut mud down */
#define PAUSE_FILE "../pause" /* autorun: don't restart mud */
#endif
/* names of various files and directories */
#define INDEX_FILE "index" /* index of world files */
#define MINDEX_FILE "index.mini" /* ... and for mini-mud-mode */
#define WLD_PREFIX LIB_WORLD"wld"SLASH /* room definitions */
#define MOB_PREFIX LIB_WORLD"mob"SLASH /* monster prototypes */
#define OBJ_PREFIX LIB_WORLD"obj"SLASH /* object prototypes */
#define ZON_PREFIX LIB_WORLD"zon"SLASH /* zon defs & command tables */
#define SHP_PREFIX LIB_WORLD"shp"SLASH /* shop definitions */
#define TRG_PREFIX LIB_WORLD"trg"SLASH /* trigger files */
#define HLP_PREFIX LIB_TEXT"hedit"SLASH /* Help files */
#define CREDITS_FILE LIB_TEXT"credits" /* for the 'credits' command */
#define NEWS_FILE LIB_TEXT"news" /* for the 'news' command */
#define MOTD_FILE LIB_TEXT"motd" /* messages of the day / mortal */
#define IMOTD_FILE LIB_TEXT"imotd" /* messages of the day / immort */
#define GREETINGS_FILE LIB_TEXT"greetings" /* The opening screen. */
#define HELP_PAGE_FILE LIB_TEXT_HEDIT"screen" /* for HELP <CR> */
#define IHELP_PAGE_FILE LIB_TEXT_HEDIT"iscreen" /* for HELP <CR> imms */
#define CONTEXT_HELP_FILE LIB_TEXT"contexthelp" /* context help for olc */
#define INFO_FILE LIB_TEXT"info" /* for INFO */
#define WIZLIST_FILE LIB_TEXT"wizlist" /* for WIZLIST */
#define IMMLIST_FILE LIB_TEXT"immlist" /* for IMMLIST */
#define BACKGROUND_FILE LIB_TEXT"background"/* for the background story */
#define POLICIES_FILE LIB_TEXT"policies" /* player policies/rules */
#define HANDBOOK_FILE LIB_TEXT"handbook" /* handbook for new immorts */
#define HELP_FILE "help.hlp"
#define IDEA_FILE LIB_MISC"ideas" /* for the 'idea'-command */
#define TYPO_FILE LIB_MISC"typos" /* 'typo' */
#define BUG_FILE LIB_MISC"bugs" /* 'bug' */
#define MESS_FILE LIB_MISC"messages" /* damage messages */
#define SOCMESS_FILE LIB_MISC"socials" /* messages for social acts */
#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 CONFIG_FILE LIB_ETC"config" /* OasisOLC * GAME CONFIG FL */
#define PLAYER_FILE LIB_ETC"players" /* the player database */
#define MAIL_FILE LIB_ETC"plrmail" /* for the mudmail system */
#define MAIL_FILE_TMP LIB_ETC"plrmail_tmp" /* for the mudmail system */
#define BAN_FILE LIB_ETC"badsites" /* for the siteban system */
#define HCONTROL_FILE LIB_ETC"hcontrol" /* for the house system */
#define TIME_FILE LIB_ETC"time" /* for calendar system */
/* new bitvector data for use in player_index_element */
#define PINDEX_DELETED (1 << 0) /* deleted player */
#define PINDEX_NODELETE (1 << 1) /* protected player */
#define PINDEX_SELFDELETE (1 << 2) /* player is selfdeleting*/
#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_extra_descriptions(struct extra_descr_data *edesc);
void free_text_files(void);
void free_help_table(void);
void free_player_index(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);
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 VIRTUAL 1
/* structure for the reset commands */
struct reset_com {
char command; /* current command */
bool if_flag; /* if TRUE: exe only if preceding exe'd */
int arg1; /* */
int arg2; /* Arguments to the command */
int arg3; /* */
int line; /* line number this command appears on */
char *sarg1; /* string argument */
char *sarg2; /* string argument */
/*
* Commands: *
* 'M': Read a mobile *
* 'O': Read an object *
* 'G': Give obj to mob *
* 'P': Put obj in obj *
* 'G': Obj to char *
* 'E': Obj to char equip *
* 'D': Set state of door *
* 'T': Trigger command *
* 'V': Assign a variable *
*/
};
/* zone definition structure. for the 'zone-table' */
struct zone_data {
char *name; /* name of this zone */
char *builders; /* namelist of builders allowed to */
/* modify this zone. */
int lifespan; /* how long between resets (minutes) */
int age; /* current age of this zone (minutes) */
room_vnum bot; /* starting room number for this zone */
room_vnum top; /* upper limit for rooms in this zone */
int reset_mode; /* conditions for reset (see below) */
zone_vnum number; /* virtual number of this zone */
struct reset_com *cmd; /* command table for reset */
/*
* Reset mode:
* 0: Don't reset, and don't update age.
* 1: Reset if no PC's are located in zone.
* 2: Just reset.
*/
};
/* for queueing zones for update */
struct reset_q_element {
zone_rnum zone_to_reset; /* ref to zone_data */
struct reset_q_element *next;
};
/* structure for the update queue */
struct reset_q_type {
struct reset_q_element *head;
struct reset_q_element *tail;
};
/* Added level, flags, and last, primarily for pfile autocleaning. You
can also use them to keep online statistics, and can add race, class,
etc if you like.
*/
struct player_index_element {
char *name;
long id;
int level;
int flags;
time_t last;
};
struct help_index_element {
char *index; /*Future Use */
char *keywords; /*Keyword Place holder and sorter */
char *entry; /*Entries for help files with Keywords at very top*/
int duplicate; /*Duplicate entries for multple keywords*/
int min_level; /*Min Level to read help entry*/
};
/* don't change these */
#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;
};
/* global buffering system */
#ifndef __DB_C__
extern struct config_data config_info;
extern struct room_data *world;
extern room_rnum top_of_world;
extern struct zone_data *zone_table;
extern zone_rnum top_of_zone_table;
extern struct descriptor_data *descriptor_list;
extern struct char_data *character_list;
extern struct player_special_data dummy_mob;
extern struct index_data *mob_index;
extern struct char_data *mob_proto;
extern mob_rnum top_of_mobt;
extern struct index_data *obj_index;
extern struct obj_data *object_list;
extern struct obj_data *obj_proto;
extern obj_rnum top_of_objt;
extern struct social_messg *soc_mess_list;
extern int top_of_socialt;
extern struct shop_data *shop_index;
extern int top_shop;
extern struct index_data **trig_index;
extern struct trig_data *trigger_list;
extern int top_of_trigt;
extern long max_mob_id;
extern long max_obj_id;
extern int dg_owner_purged;
#endif /* __DB_C__ */

210
src/dg_comm.c Normal file
View file

@ -0,0 +1,210 @@
/* ************************************************************************
* File: dg_comm.c Part of Death's Gate MUD *
* *
* Usage: Contains routines to handle mud to player communication *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "dg_scripts.h"
#include "utils.h"
#include "comm.h"
#include "handler.h"
#include "db.h"
#include "constants.h"
/* same as any_one_arg except that it stops at punctuation */
char *any_one_name(char *argument, char *first_arg)
{
char* arg;
/* Find first non blank */
while(isspace(*argument))
argument++;
/* Find length of first word */
for(arg = first_arg ;
*argument && !isspace(*argument) &&
(!ispunct(*argument) || *argument == '#' || *argument == '-') ;
arg++, argument++)
*arg = LOWER(*argument);
*arg = '\0';
return argument;
}
void sub_write_to_char(char_data *ch, char *tokens[],
void *otokens[], char type[])
{
char sb[MAX_STRING_LENGTH];
int i;
strcpy(sb,"");
for (i = 0; tokens[i + 1]; i++)
{
strcat(sb,tokens[i]);
switch (type[i])
{
case '~':
if (!otokens[i])
strcat(sb,"someone");
else if ((char_data *)otokens[i] == ch)
strcat(sb,"you");
else
strcat(sb,PERS((char_data *)otokens[i], ch));
break;
case '|':
if (!otokens[i])
strcat(sb,"someone's");
else if ((char_data *)otokens[i] == ch)
strcat(sb,"your");
else
{
strcat(sb,PERS((char_data *) otokens[i], ch));
strcat(sb,"'s");
}
break;
case '^':
if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i]))
strcat(sb,"its");
else if (otokens[i] == ch)
strcat(sb,"your");
else
strcat(sb,HSHR((char_data *) otokens[i]));
break;
case '&':
if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i]))
strcat(sb,"it");
else if (otokens[i] == ch)
strcat(sb,"you");
else
strcat(sb,HSSH((char_data *) otokens[i]));
break;
case '*':
if (!otokens[i] || !CAN_SEE(ch, (char_data *) otokens[i]))
strcat(sb,"it");
else if (otokens[i] == ch)
strcat(sb,"you");
else
strcat(sb,HMHR((char_data *) otokens[i]));
break;
case '¨':
if (!otokens[i])
strcat(sb,"something");
else
strcat(sb,OBJS(((obj_data *) otokens[i]), ch));
break;
}
}
strcat(sb,tokens[i]);
strcat(sb,"\n\r");
sb[0] = toupper(sb[0]);
send_to_char(ch, "%s", sb);
}
void sub_write(char *arg, char_data *ch, byte find_invis, int targets)
{
char str[MAX_INPUT_LENGTH * 2];
char type[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH];
char *tokens[MAX_INPUT_LENGTH], *s, *p;
void *otokens[MAX_INPUT_LENGTH];
char_data *to;
obj_data *obj;
int i, tmp;
int to_sleeping = 1; /* mainly for windows compiles */
if (!arg)
return;
tokens[0] = str;
for (i = 0, p = arg, s = str; *p;)
{
switch (*p) {
case '~':
case '|':
case '^':
case '&':
case '*':
/* get char_data, move to next token */
type[i] = *p;
*s = '\0';
p = any_one_name(++p, name);
otokens[i] =
find_invis ? (void *)get_char_in_room(&world[IN_ROOM(ch)], name) : (void *)get_char_room_vis(ch, name, NULL);
tokens[++i] = ++s;
break;
case '¨':
/* get obj_data, move to next token */
type[i] = *p;
*s = '\0';
p = any_one_name(++p, name);
if (find_invis) obj = get_obj_in_room(&world[IN_ROOM(ch)], name);
else if (!(obj = get_obj_in_list_vis(ch, name, NULL, world[IN_ROOM(ch)].contents))) ;
else if (!(obj = get_obj_in_equip_vis(ch, name, &tmp, ch->equipment))) ;
else obj = get_obj_in_list_vis(ch, name, NULL, ch->carrying);
otokens[i] = (void *)obj;
tokens[++i] = ++s;
break;
case '\\':
p++;
*s++ = *p++;
break;
default:
*s++ = *p++;
}
}
*s = '\0';
tokens[++i] = NULL;
if (IS_SET(targets, TO_CHAR) && SENDOK(ch))
sub_write_to_char(ch, tokens, otokens, type);
if (IS_SET(targets, TO_ROOM))
for (to = world[IN_ROOM(ch)].people;
to; to = to->next_in_room)
if (to != ch && SENDOK(to))
sub_write_to_char(to, tokens, otokens, type);
}
void send_to_zone(char *messg, zone_rnum zone)
{
struct descriptor_data *i;
if (!messg || !*messg)
return;
for (i = descriptor_list; i; i = i->next)
if (!i->connected && i->character && AWAKE(i->character) &&
(IN_ROOM(i->character) != NOWHERE) &&
(world[IN_ROOM(i->character)].zone == zone))
write_to_output(i, "%s", messg);
}

325
src/dg_db_scripts.c Normal file
View file

@ -0,0 +1,325 @@
/* ************************************************************************
* File: dg_db_scripts.c Part of Death's Gate MUD *
* *
* Usage: Contains routines to handle db functions for scripts and trigs *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "dg_scripts.h"
#include "utils.h"
#include "db.h"
#include "handler.h"
#include "dg_event.h"
#include "comm.h"
#include "constants.h"
extern void half_chop(char *string, char *arg1, char *arg2);
extern bitvector_t asciiflag_conv(char *flag);
void parse_trigger(FILE *trig_f, int nr)
{
int t[2], k, attach_type;
char line[256], *cmds, *s, flags[256], errors[MAX_INPUT_LENGTH];
struct cmdlist_element *cle;
struct index_data *t_index;
struct trig_data *trig;
CREATE(trig, trig_data, 1);
CREATE(t_index, index_data, 1);
t_index->vnum = nr;
t_index->number = 0;
t_index->func = NULL;
t_index->proto = trig;
snprintf(errors, sizeof(errors), "trig vnum %d", nr);
trig->nr = top_of_trigt;
trig->name = fread_string(trig_f, errors);
get_line(trig_f, line);
k = sscanf(line, "%d %s %d", &attach_type, flags, t);
trig->attach_type = (byte)attach_type;
trig->trigger_type = (long)asciiflag_conv(flags);
trig->narg = (k == 3) ? t[0] : 0;
trig->arglist = fread_string(trig_f, errors);
cmds = s = fread_string(trig_f, errors);
CREATE(trig->cmdlist, struct cmdlist_element, 1);
trig->cmdlist->cmd = strdup(strtok(s, "\n\r"));
cle = trig->cmdlist;
while ((s = strtok(NULL, "\n\r"))) {
CREATE(cle->next, struct cmdlist_element, 1);
cle = cle->next;
cle->cmd = strdup(s);
}
free(cmds);
trig_index[top_of_trigt++] = t_index;
}
/*
* create a new trigger from a prototype.
* nr is the real number of the trigger.
*/
trig_data *read_trigger(int nr)
{
index_data *t_index;
trig_data *trig;
if (nr >= top_of_trigt) return NULL;
if ((t_index = trig_index[nr]) == NULL)
return NULL;
CREATE(trig, trig_data, 1);
trig_data_copy(trig, t_index->proto);
t_index->number++;
return trig;
}
void trig_data_init(trig_data *this_data)
{
this_data->nr = NOTHING;
this_data->data_type = 0;
this_data->name = NULL;
this_data->trigger_type = 0;
this_data->cmdlist = NULL;
this_data->curr_state = NULL;
this_data->narg = 0;
this_data->arglist = NULL;
this_data->depth = 0;
this_data->wait_event = NULL;
this_data->purged = FALSE;
this_data->var_list = NULL;
this_data->next = NULL;
}
void trig_data_copy(trig_data *this_data, const trig_data *trg)
{
trig_data_init(this_data);
this_data->nr = trg->nr;
this_data->attach_type = trg->attach_type;
this_data->data_type = trg->data_type;
if (trg->name)
this_data->name = strdup(trg->name);
else {
this_data->name = strdup("unnamed trigger");
log("Trigger with no name! (%d)", trg->nr);
}
this_data->trigger_type = trg->trigger_type;
this_data->cmdlist = trg->cmdlist;
this_data->narg = trg->narg;
if (trg->arglist) this_data->arglist = strdup(trg->arglist);
}
/* for mobs and rooms: */
void dg_read_trigger(FILE *fp, void *proto, int type)
{
char line[READ_SIZE];
char junk[8];
int vnum, rnum, count;
char_data *mob;
room_data *room;
struct trig_proto_list *trg_proto, *new_trg;
get_line(fp, line);
count = sscanf(line,"%7s %d",junk,&vnum);
if (count != 2) {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: Error assigning trigger! - Line was\n %s", line);
return;
}
rnum = real_trigger(vnum);
if (rnum == NOTHING) {
switch(type) {
case MOB_TRIGGER:
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: dg_read_trigger: Trigger vnum #%d asked for but non-existant! (mob: %s - %d)",
vnum, GET_NAME((char_data *)proto), GET_MOB_VNUM((char_data *)proto));
break;
case WLD_TRIGGER:
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: dg_read_trigger: Trigger vnum #%d asked for but non-existant! (room:%d)",
vnum, GET_ROOM_VNUM( ((room_data *)proto)->number ));
break;
default:
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: dg_read_trigger: Trigger vnum #%d asked for but non-existant! (?)", vnum);
break;
}
return;
}
switch(type) {
case MOB_TRIGGER:
CREATE(new_trg, struct trig_proto_list, 1);
new_trg->vnum = vnum;
new_trg->next = NULL;
mob = (char_data *)proto;
trg_proto = mob->proto_script;
if (!trg_proto) {
mob->proto_script = trg_proto = new_trg;
} else {
while (trg_proto->next)
trg_proto = trg_proto->next;
trg_proto->next = new_trg;
}
break;
case WLD_TRIGGER:
CREATE(new_trg, struct trig_proto_list, 1);
new_trg->vnum = vnum;
new_trg->next = NULL;
room = (room_data *)proto;
trg_proto = room->proto_script;
if (!trg_proto) {
room->proto_script = trg_proto = new_trg;
} else {
while (trg_proto->next)
trg_proto = trg_proto->next;
trg_proto->next = new_trg;
}
if (rnum != NOTHING) {
if (!(room->script))
CREATE(room->script, struct script_data, 1);
add_trigger(SCRIPT(room), read_trigger(rnum), -1);
} else {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: non-existant trigger #%d assigned to room #%d",
vnum, room->number);
}
break;
default:
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: Trigger vnum #%d assigned to non-mob/obj/room", vnum);
}
}
void dg_obj_trigger(char *line, struct obj_data *obj)
{
char junk[8];
int vnum, rnum, count;
struct trig_proto_list *trg_proto, *new_trg;
count = sscanf(line,"%s %d",junk,&vnum);
if (count != 2) {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: dg_obj_trigger() : Error assigning trigger! - Line was:\n %s", line);
return;
}
rnum = real_trigger(vnum);
if (rnum==NOTHING) {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: Trigger vnum #%d asked for but non-existant! (Object: %s - %d)",
vnum, obj->short_description, GET_OBJ_VNUM(obj));
return;
}
CREATE(new_trg, struct trig_proto_list, 1);
new_trg->vnum = vnum;
new_trg->next = NULL;
trg_proto = obj->proto_script;
if (!trg_proto) {
obj->proto_script = trg_proto = new_trg;
} else {
while (trg_proto->next) trg_proto = trg_proto->next;
trg_proto->next = new_trg;
}
}
void assign_triggers(void *i, int type)
{
struct char_data *mob = NULL;
struct obj_data *obj = NULL;
struct room_data *room = NULL;
int rnum;
struct trig_proto_list *trg_proto;
switch (type)
{
case MOB_TRIGGER:
mob = (char_data *)i;
trg_proto = mob->proto_script;
while (trg_proto) {
rnum = real_trigger(trg_proto->vnum);
if (rnum==NOTHING) {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: trigger #%d non-existant, for mob #%d",
trg_proto->vnum, mob_index[mob->nr].vnum);
} else {
if (!SCRIPT(mob))
CREATE(SCRIPT(mob), struct script_data, 1);
add_trigger(SCRIPT(mob), read_trigger(rnum), -1);
}
trg_proto = trg_proto->next;
}
break;
case OBJ_TRIGGER:
obj = (obj_data *)i;
trg_proto = obj->proto_script;
while (trg_proto) {
rnum = real_trigger(trg_proto->vnum);
if (rnum==NOTHING) {
log("SYSERR: trigger #%d non-existant, for obj #%d",
trg_proto->vnum, obj_index[obj->item_number].vnum);
} else {
if (!SCRIPT(obj))
CREATE(SCRIPT(obj), struct script_data, 1);
add_trigger(SCRIPT(obj), read_trigger(rnum), -1);
}
trg_proto = trg_proto->next;
}
break;
case WLD_TRIGGER:
room = (struct room_data *)i;
trg_proto = room->proto_script;
while (trg_proto) {
rnum = real_trigger(trg_proto->vnum);
if (rnum==NOTHING) {
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: trigger #%d non-existant, for room #%d",
trg_proto->vnum, room->number);
} else {
if (!SCRIPT(room))
CREATE(SCRIPT(room), struct script_data, 1);
add_trigger(SCRIPT(room), read_trigger(rnum), -1);
}
trg_proto = trg_proto->next;
}
break;
default:
mudlog(BRF, LVL_BUILDER, TRUE,
"SYSERR: unknown type for assign_triggers()");
break;
}
}

295
src/dg_event.c Normal file
View file

@ -0,0 +1,295 @@
/**************************************************************************
* File: dg_event.c *
* *
* Usage: This file contains a simplified event system to allow *
* DG Script triggers to use the "wait" command, causing a delay in the *
* middle of a script. *
* *
* By: Mark A. Heilpern (Sammy @ eQuoria MUD equoria.com:4000) *
* *
* As of dg scripts pl 8 this includes the 'FULL' DG event package. * *
* This file includes the file queue.c, which handles the priority queues.* *
* Thomas Arp - Welcor - 2002 *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
/*
* dg_event.c: This file contains a simplified event system to allow
* DG Script triggers to use the "wait" command, causing a delay in the
* middle of a script.
*
* By: Mark A. Heilpern (Sammy @ eQuoria MUD equoria.com:4000)
*
* As of dg scripts pl 8 this includes the 'FULL' DG event package.
* This file includes the file queue.c, which handles the priority queues.
* Thomas Arp - Welcor - 2002
*
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "db.h"
#include "utils.h"
#include "dg_event.h"
#include "constants.h"
struct queue *event_q; /* the event queue */
extern long pulse;
/* initializes the event queue */
void event_init(void)
{
event_q = queue_init();
}
/*
** Add an event to the current list
*/
/* creates an event and returns it */
struct event *event_create(EVENTFUNC(*func), void *event_obj, long when)
{
struct event *new_event;
if (when < 1) /* make sure its in the future */
when = 1;
CREATE(new_event, struct event, 1);
new_event->func = func;
new_event->event_obj = event_obj;
new_event->q_el = queue_enq(event_q, new_event, when + pulse);
return new_event;
}
/* removes the event from the system */
void event_cancel(struct event *event)
{
if (!event) {
log("SYSERR: Attempted to cancel a NULL event");
return;
}
if (!event->q_el) {
log("SYSERR: Attempted to cancel a non-NULL unqueued event, freeing anyway");
} else
queue_deq(event_q, event->q_el);
if (event->event_obj)
free(event->event_obj);
free(event);
}
/* Process any events whose time has come. */
void event_process(void)
{
struct event *the_event;
long new_time;
while ((long) pulse >= queue_key(event_q)) {
if (!(the_event = (struct event *) queue_head(event_q))) {
log("SYSERR: Attempt to get a NULL event");
return;
}
/*
** Set the_event->q_el to NULL so that any functions called beneath
** event_process can tell if they're being called beneath the actual
** event function.
*/
the_event->q_el = NULL;
/* call event func, reenqueue event if retval > 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);
else
free(the_event);
}
}
/* returns the time remaining before the event */
long event_time(struct event *event)
{
long when;
when = queue_elmt_key(event->q_el);
return (when - pulse);
}
/* frees all events in the queue */
void event_free_all(void)
{
struct event *the_event;
while ((the_event = (struct event *) queue_head(event_q))) {
if (the_event->event_obj)
free(the_event->event_obj);
free(the_event);
}
queue_free(event_q);
}
/* boolean function to tell whether an event is queued or not */
int event_is_queued(struct event *event)
{
if (event->q_el)
return 1;
else
return 0;
}
/* ************************************************************************
* File: queue.c *
* *
* Usage: generic queue functions for building and using a priority queue *
* *
************************************************************************ */
/* returns a new, initialized queue */
struct queue *queue_init(void)
{
struct queue *q;
CREATE(q, struct queue, 1);
return q;
}
/* add data into the priority queue q with key */
struct q_element *queue_enq(struct queue *q, void *data, long key)
{
struct q_element *qe, *i;
int bucket;
CREATE(qe, struct q_element, 1);
qe->data = data;
qe->key = key;
bucket = key % NUM_EVENT_QUEUES; /* which queue does this go in */
if (!q->head[bucket]) { /* queue is empty */
q->head[bucket] = qe;
q->tail[bucket] = qe;
}
else {
for (i = q->tail[bucket]; i; i = i->prev) {
if (i->key < key) { /* found insertion point */
if (i == q->tail[bucket])
q->tail[bucket] = qe;
else {
qe->next = i->next;
i->next->prev = qe;
}
qe->prev = i;
i->next = qe;
break;
}
}
if (i == NULL) { /* insertion point is front of list */
qe->next = q->head[bucket];
q->head[bucket] = qe;
qe->next->prev = qe;
}
}
return qe;
}
/* remove queue element qe from the priority queue q */
void queue_deq(struct queue *q, struct q_element *qe)
{
int i;
assert(qe);
i = qe->key % NUM_EVENT_QUEUES;
if (qe->prev == NULL)
q->head[i] = qe->next;
else
qe->prev->next = qe->next;
if (qe->next == NULL)
q->tail[i] = qe->prev;
else
qe->next->prev = qe->prev;
free(qe);
}
/*
* removes and returns the data of the
* first element of the priority queue q
*/
void *queue_head(struct queue *q)
{
void *data;
int i;
i = pulse % NUM_EVENT_QUEUES;
if (!q->head[i])
return NULL;
data = q->head[i]->data;
queue_deq(q, q->head[i]);
return data;
}
/*
* returns the key of the head element of the priority queue
* if q is NULL, then return the largest unsigned number
*/
long queue_key(struct queue *q)
{
int i;
i = pulse % NUM_EVENT_QUEUES;
if (q->head[i])
return q->head[i]->key;
else
return LONG_MAX;
}
/* returns the key of queue element qe */
long queue_elmt_key(struct q_element *qe)
{
return qe->key;
}
/* free q and contents */
void queue_free(struct queue *q)
{
int i;
struct q_element *qe, *next_qe;
for (i = 0; i < NUM_EVENT_QUEUES; i++)
for (qe = q->head[i]; qe; qe = next_qe) {
next_qe = qe->next;
free(qe);
}
free(q);
}

70
src/dg_event.h Normal file
View file

@ -0,0 +1,70 @@
/* ************************************************************************
* File: dg_event.h *
* *
* Usage: structures and prototypes for events *
* *
* Written by Eric Green (ejg3@cornell.edu) *
* *
* Changes: *
* 3/6/98 ejg: Changed return type of EVENTFUNC from void to long. *
* Moved struct event definition to events.c. *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
************************************************************************ */
/*
** how often will heartbeat() call the 'wait' event function?
*/
#define PULSE_DG_EVENT 1
/********** Event related section *********/
#define EVENTFUNC(name) long (name)(void *event_obj)
/*
** define event related structures
*/
struct event {
EVENTFUNC(*func);
void *event_obj;
struct q_element *q_el;
};
/****** End of Event related info ********/
/***** Queue related info ******/
/* number of queues to use (reduces enqueue cost) */
#define NUM_EVENT_QUEUES 10
struct queue {
struct q_element *head[NUM_EVENT_QUEUES], *tail[NUM_EVENT_QUEUES];
};
struct q_element {
void *data;
long key;
struct q_element *prev, *next;
};
/****** End of Queue related info ********/
/* - events - function protos need by other modules */
void event_init(void);
struct event *event_create(EVENTFUNC(*func), void *event_obj, long when);
void event_cancel(struct event *event);
void event_process(void);
long event_time(struct event *event);
void event_free_all(void);
/* - queues - function protos need by other modules */
struct queue *queue_init(void);
struct q_element *queue_enq(struct queue *q, void *data, long key);
void queue_deq(struct queue *q, struct q_element *qe);
void *queue_head(struct queue *q);
long queue_key(struct queue *q);
long queue_elmt_key(struct q_element *qe);
void queue_free(struct queue *q);
int event_is_queued(struct event *event);

301
src/dg_handler.c Normal file
View file

@ -0,0 +1,301 @@
/**************************************************************************
* File: dg_handler.c *
* *
* Usage: contains functions to handle memory for scripts. *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
***************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "dg_scripts.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "handler.h"
#include "spells.h"
#include "dg_event.h"
#include "constants.h"
/* frees memory associated with var */
void free_var_el(struct trig_var_data *var)
{
if (var->name)
free(var->name);
if (var->value)
free(var->value);
free(var);
}
/* release memory allocated for a variable list */
void free_varlist(struct trig_var_data *vd)
{
struct trig_var_data *i, *j;
for (i = vd; i;) {
j = i;
i = i->next;
free_var_el(j);
}
}
/*
* remove var name from var_list
* returns 1 if found, else 0
*/
int remove_var(struct trig_var_data **var_list, char *name)
{
struct trig_var_data *i, *j;
for (j = NULL, i = *var_list; i && str_cmp(name, i->name);
j = i, i = i->next);
if (i) {
if (j) {
j->next = i->next;
free_var_el(i);
} else {
*var_list = i->next;
free_var_el(i);
}
return 1;
}
return 0;
}
/*
* Return memory used by a trigger
* The command list is free'd when changed and when
* shutting down.
*/
void free_trigger(struct trig_data *trig)
{
free(trig->name);
trig->name = NULL;
if (trig->arglist) {
free(trig->arglist);
trig->arglist = NULL;
}
if (trig->var_list) {
free_varlist(trig->var_list);
trig->var_list = NULL;
}
if (GET_TRIG_WAIT(trig))
event_cancel(GET_TRIG_WAIT(trig));
free(trig);
}
/* remove a single trigger from a mob/obj/room */
void extract_trigger(struct trig_data *trig)
{
struct trig_data *temp;
if (GET_TRIG_WAIT(trig)) {
event_cancel(GET_TRIG_WAIT(trig));
GET_TRIG_WAIT(trig) = NULL;
}
trig_index[trig->nr]->number--;
/* walk the trigger list and remove this one */
REMOVE_FROM_LIST(trig, trigger_list, next_in_world);
free_trigger(trig);
}
/* remove all triggers from a mob/obj/room */
void extract_script(void *thing, int type)
{
struct script_data *sc = NULL;
struct trig_data *trig, *next_trig;
char_data *mob;
obj_data *obj;
room_data *room;
switch (type) {
case MOB_TRIGGER:
mob = (struct char_data *)thing;
sc = SCRIPT(mob);
SCRIPT(mob) = NULL;
break;
case OBJ_TRIGGER:
obj = (struct obj_data *)thing;
sc = SCRIPT(obj);
SCRIPT(obj) = NULL;
break;
case WLD_TRIGGER:
room = (struct room_data *)thing;
sc = SCRIPT(room);
SCRIPT(room) = NULL;
break;
}
#if 1 /* debugging */
{
struct char_data *i = character_list;
struct obj_data *j = object_list;
room_rnum k;
if (sc) {
for ( ; i ; i = i->next)
assert(sc != SCRIPT(i));
for ( ; j ; j = j->next)
assert(sc != SCRIPT(j));
for (k = 0; k < top_of_world; k++)
assert(sc != SCRIPT(&world[k]));
}
}
#endif
for (trig = TRIGGERS(sc); trig; trig = next_trig) {
next_trig = trig->next;
extract_trigger(trig);
}
TRIGGERS(sc) = NULL;
/* Thanks to James Long for tracking down this memory leak */
free_varlist(sc->global_vars);
free(sc);
}
/* erase the script memory of a mob */
void extract_script_mem(struct script_memory *sc)
{
struct script_memory *next;
while (sc) {
next = sc->next;
if (sc->cmd) free(sc->cmd);
free(sc);
sc = next;
}
}
void free_proto_script(void *thing, int type)
{
struct trig_proto_list *proto = NULL, *fproto;
char_data *mob;
obj_data *obj;
room_data *room;
switch (type) {
case MOB_TRIGGER:
mob = (struct char_data *)thing;
proto = mob->proto_script;
mob->proto_script = NULL;
break;
case OBJ_TRIGGER:
obj = (struct obj_data *)thing;
proto = obj->proto_script;
obj->proto_script = NULL;
break;
case WLD_TRIGGER:
room = (struct room_data *)thing;
proto = room->proto_script;
room->proto_script = NULL;
break;
}
#if 1 /* debugging */
{
struct char_data *i = character_list;
struct obj_data *j = object_list;
room_rnum k;
if (proto) {
for ( ; i ; i = i->next)
assert(proto != i->proto_script);
for ( ; j ; j = j->next)
assert(proto != j->proto_script);
for (k = 0; k < top_of_world; k++)
assert(proto != world[k].proto_script);
}
}
#endif
while (proto) {
fproto = proto;
proto = proto->next;
free(fproto);
}
}
void copy_proto_script(void *source, void *dest, int type)
{
struct trig_proto_list *tp_src = NULL, *tp_dst = NULL;
switch (type) {
case MOB_TRIGGER:
tp_src = ((char_data *)source)->proto_script;
break;
case OBJ_TRIGGER:
tp_src = ((obj_data *)source)->proto_script;
break;
case WLD_TRIGGER:
tp_src = ((room_data *)source)->proto_script;
break;
}
if (tp_src) {
CREATE(tp_dst, struct trig_proto_list, 1);
switch (type) {
case MOB_TRIGGER:
((char_data *)dest)->proto_script = tp_dst;
break;
case OBJ_TRIGGER:
((obj_data *)dest)->proto_script = tp_dst;
break;
case WLD_TRIGGER:
((room_data *)dest)->proto_script = tp_dst;
break;
}
while (tp_src) {
tp_dst->vnum = tp_src->vnum;
tp_src = tp_src->next;
if (tp_src)
CREATE(tp_dst->next, struct trig_proto_list, 1);
tp_dst = tp_dst->next;
}
}
}
void delete_variables(const char *charname)
{
char filename[PATH_MAX];
if (!get_filename(filename, sizeof(filename), SCRIPT_VARS_FILE, charname))
return;
if (remove(filename) < 0 && errno != ENOENT)
log("SYSERR: deleting variable file %s: %s", filename, strerror(errno));
}
void update_wait_events(struct room_data *to, struct room_data *from)
{
struct trig_data *trig;
if (!SCRIPT(from))
return;
for (trig = TRIGGERS(SCRIPT(from)); trig; trig = trig->next) {
if (!GET_TRIG_WAIT(trig))
continue;
((struct wait_event_data *)GET_TRIG_WAIT(trig)->event_obj)->go = to;
}
}

327
src/dg_misc.c Normal file
View file

@ -0,0 +1,327 @@
/**************************************************************************
* File: dg_misc.c *
* Usage: contains general functions for script usage. *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "dg_scripts.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "dg_event.h"
#include "db.h"
#include "screen.h"
#include "spells.h"
#include "constants.h"
void die(struct char_data *ch, struct char_data * killer);
/* copied from spell_parser.c: */
#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 check is required. Note that mobs should generally use the */
/* normal 'cast' command (which must be patched to allow mobs to cast */
/* spells) as the spell system is designed to have a character caster, */
/* and this cast routine may overlook certain issues. */
/* LIMITATION: a target MUST exist for the spell unless the spell is */
/* set to TAR_IGNORE. Also, group spells are not permitted */
/* code borrowed from do_cast() */
void do_dg_cast(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd)
{
struct char_data *caster = NULL;
struct char_data *tch = NULL;
struct obj_data *tobj = NULL;
struct room_data *caster_room = NULL;
char *s, *t;
int spellnum, target = 0;
char buf2[MAX_STRING_LENGTH], orig_cmd[MAX_INPUT_LENGTH];
/* need to get the caster or the room of the temporary caster */
switch (type) {
case MOB_TRIGGER:
caster = (struct char_data *)go;
break;
case WLD_TRIGGER:
caster_room = (struct room_data *)go;
break;
case OBJ_TRIGGER:
caster_room = dg_room_of_obj((struct obj_data *)go);
if (!caster_room) {
script_log("dg_do_cast: unknown room for object-caster!");
return;
}
break;
default:
script_log("dg_do_cast: unknown trigger type!");
return;
}
strcpy(orig_cmd, cmd);
/* get: blank, spell name, target name */
s = strtok(cmd, "'");
if (s == NULL) {
script_log("Trigger: %s, VNum %d. dg_cast needs spell name.",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
return;
}
s = strtok(NULL, "'");
if (s == NULL) {
script_log("Trigger: %s, VNum %d. dg_cast needs spell name in `'s.",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
return;
}
t = strtok(NULL, "\0");
/* spellnum = search_block(s, spells, 0); */
spellnum = find_skill_num(s);
if ((spellnum < 1) || (spellnum > MAX_SPELLS)) {
script_log("Trigger: %s, VNum %d. dg_cast: invalid spell name (%s)",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), orig_cmd);
return;
}
/* Find the target */
if (t != NULL) {
one_argument(strcpy(buf2, t), t);
skip_spaces(&t);
}
if (IS_SET(SINFO.targets, TAR_IGNORE)) {
target = TRUE;
} else if (t != NULL && *t) {
if (!target &&
(IS_SET(SINFO.targets, TAR_CHAR_ROOM) ||
IS_SET(SINFO.targets, TAR_CHAR_WORLD))) {
if ((tch = get_char(t)) != NULL)
target = TRUE;
}
if (!target &&
(IS_SET(SINFO.targets, TAR_OBJ_INV) ||
IS_SET(SINFO.targets, TAR_OBJ_EQUIP) ||
IS_SET(SINFO.targets, TAR_OBJ_ROOM) ||
IS_SET(SINFO.targets, TAR_OBJ_WORLD))) {
if ((tobj = get_obj(t)) != NULL)
target = TRUE;
}
if (!target) {
script_log("Trigger: %s, VNum %d. dg_cast: target not found (%s)",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), orig_cmd);
return;
}
}
if (IS_SET(SINFO.routines, MAG_GROUPS)) {
script_log("Trigger: %s, VNum %d. dg_cast: group spells not permitted (%s)",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), orig_cmd);
return;
}
if (!caster) {
caster = read_mobile(DG_CASTER_PROXY, VIRTUAL);
if (!caster) {
script_log("dg_cast: Cannot load the caster mob!");
return;
}
/* set the caster's name to that of the object, or the gods.... */
if (type==OBJ_TRIGGER)
caster->player.short_descr =
strdup(((struct obj_data *)go)->short_description);
else if (type==WLD_TRIGGER)
caster->player.short_descr = strdup("The gods");
caster->next_in_room = caster_room->people;
caster_room->people = caster;
caster->in_room = real_room(caster_room->number);
call_magic(caster, tch, tobj, spellnum, DG_SPELL_LEVEL, CAST_SPELL);
extract_char(caster);
} else
call_magic(caster, tch, tobj, spellnum, GET_LEVEL(caster), CAST_SPELL);
}
/* modify an affection on the target. affections can be of the AFF_x */
/* variety or APPLY_x type. APPLY_x's have an integer value for them */
/* while AFF_x's have boolean values. In any case, the duration MUST */
/* be non-zero. */
/* usage: apply <target> <property> <value> <duration> */
#define APPLY_TYPE 1
#define AFFECT_TYPE 2
void do_dg_affect(void *go, struct script_data *sc, trig_data *trig,
int script_type, char *cmd)
{
struct char_data *ch = NULL;
int value=0, duration=0;
char junk[MAX_INPUT_LENGTH]; /* will be set to "dg_affect" */
char charname[MAX_INPUT_LENGTH], property[MAX_INPUT_LENGTH];
char value_p[MAX_INPUT_LENGTH], duration_p[MAX_INPUT_LENGTH];
int i=0, type=0;
struct affected_type af;
half_chop(cmd, junk, cmd);
half_chop(cmd, charname, cmd);
half_chop(cmd, property, cmd);
half_chop(cmd, value_p, duration_p);
/* make sure all parameters are present */
if (!charname || !*charname || !property || !*property ||
!value_p || !*value_p || !duration_p || !*duration_p) {
script_log("Trigger: %s, VNum %d. dg_affect usage: <target> <property> <value> <duration>",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
return;
}
value = atoi(value_p);
duration = atoi(duration_p);
if (duration <= 0) {
script_log("Trigger: %s, VNum %d. dg_affect: need positive duration!",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
script_log("Line was: dg_affect %s %s %s %s (%d)",
charname, property, value_p, duration_p, duration);
return;
}
/* find the property -- first search apply_types */
i = 0;
while (str_cmp(apply_types[i], "\n")) {
if (!str_cmp(apply_types[i], property)) {
type=APPLY_TYPE;
break;
}
i++;
}
if (!type) { /* search affect_types now */
i = 0;
while (str_cmp(affected_bits[i], "\n")) {
if (!str_cmp(affected_bits[i], property)) {
type=AFFECT_TYPE;
break;
}
i++;
}
}
if (!type) { /* property not found */
script_log("Trigger: %s, VNum %d. dg_affect: unknown property '%s'!",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), property);
return;
}
/* locate the target */
ch = get_char(charname);
if (!ch) {
script_log("Trigger: %s, VNum %d. dg_affect: cannot locate target!",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
return;
}
if (!str_cmp(value_p, "off")) {
affect_from_char(ch, SPELL_DG_AFFECT);
return;
}
/* add the affect */
af.type = SPELL_DG_AFFECT;
af.duration = duration;
af.modifier = value;
if (type == APPLY_TYPE) {
af.location = i;
af.bitvector = 0;
} else {
af.location = 0;
af.bitvector = (1<<i);
}
affect_to_char(ch, &af);
}
void send_char_pos(struct char_data *ch, int dam)
{
switch (GET_POS(ch)) {
case POS_MORTALLYW:
act("$n is mortally wounded, and will die soon, if not aided.", TRUE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "You are mortally wounded, and will die soon, if not aided.\r\n");
break;
case POS_INCAP:
act("$n is incapacitated and will slowly die, if not aided.", TRUE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "You are incapacitated and will slowly die, if not aided.\r\n");
break;
case POS_STUNNED:
act("$n is stunned, but will probably regain consciousness again.", TRUE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "You're stunned, but will probably regain consciousness again.\r\n");
break;
case POS_DEAD:
act("$n is dead! R.I.P.", FALSE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "You are dead! Sorry...\r\n");
break;
default: /* >= POSITION SLEEPING */
if (dam > (GET_MAX_HIT(ch) >> 2))
act("That really did HURT!", FALSE, ch, 0, 0, TO_CHAR);
if (GET_HIT(ch) < (GET_MAX_HIT(ch) >> 2))
send_to_char(ch, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n",
CCRED(ch, C_SPR), CCNRM(ch, C_SPR));
}
}
/* Used throughout the xxxcmds.c files for checking if a char
* can be targetted
* - allow_gods is false when called by %force%, for instance,
* while true for %teleport%. -- Welcor
*/
int valid_dg_target(struct char_data *ch, int bitvector)
{
if (IS_NPC(ch))
return TRUE; /* all npcs are allowed as targets */
else if (GET_LEVEL(ch) < LVL_IMMORT)
return TRUE; /* as well as all mortals */
else if (!IS_SET(bitvector, DG_ALLOW_GODS) &&
GET_LEVEL(ch) >= LVL_GRGOD) /* LVL_GOD has the advance command. Can't allow them to be forced. */
return FALSE; /* but not always the highest gods */
else if (!PRF_FLAGGED(ch, PRF_NOHASSLE))
return TRUE; /* the ones in between as allowed as long as they have no-hassle off. */
else
return FALSE; /* The rest are gods with nohassle on... */
}
void script_damage(struct char_data *vict, int dam)
{
if (GET_LEVEL(vict)>=LVL_IMMORT && (dam > 0)) {
send_to_char(vict, "Being the cool immortal you are, you sidestep a trap,\r\n"
"obviously placed to kill you.\r\n");
return;
}
GET_HIT(vict) -= dam;
GET_HIT(vict) = MIN(GET_HIT(vict), GET_MAX_HIT(vict));
update_pos(vict);
send_char_pos(vict, dam);
if (GET_POS(vict) == POS_DEAD) {
if (!IS_NPC(vict))
mudlog( BRF, 0, TRUE, "%s killed by script at %s",
GET_NAME(vict), world[vict->in_room].name);
die(vict, NULL);
}
}

1241
src/dg_mobcmd.c Normal file

File diff suppressed because it is too large Load diff

812
src/dg_objcmd.c Normal file
View file

@ -0,0 +1,812 @@
/**************************************************************************
* File: dg_objcmd.c *
* Usage: contains the command_interpreter for objects, *
* object commands. *
* *
* *
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "screen.h"
#include "dg_scripts.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "constants.h"
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
*/
#define OCMD(name) \
void (name)(obj_data *obj, char *argument, int cmd, int subcmd)
void obj_log(obj_data *obj, const char *format, ...);
room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr);
OCMD(do_oecho);
OCMD(do_oforce);
OCMD(do_ozoneecho);
OCMD(do_osend);
OCMD(do_orecho);
OCMD(do_otimer);
OCMD(do_otransform);
OCMD(do_opurge);
OCMD(do_oteleport);
OCMD(do_dgoload);
OCMD(do_odamage);
OCMD(do_oasound);
OCMD(do_odoor);
OCMD(do_osetval);
OCMD(do_oat);
void obj_command_interpreter(obj_data *obj, char *argument);
struct obj_command_info {
char *command;
void (*command_pointer)(obj_data *obj, char *argument, int cmd, int subcmd);
int subcmd;
};
/* do_osend */
#define SCMD_OSEND 0
#define SCMD_OECHOAROUND 1
/* attaches object name and vnum to msg and sends it to script_log */
void obj_log(obj_data *obj, const char *format, ...)
{
va_list args;
char output[MAX_STRING_LENGTH];
snprintf(output, sizeof(output), "Obj (%s, VNum %d):: %s", obj->short_description, GET_OBJ_VNUM(obj), format);
va_start(args, format);
script_vlog(output, args);
va_end(args);
}
/* returns the real room number that the object or object's carrier is in */
room_rnum obj_room(obj_data *obj)
{
if (IN_ROOM(obj) != NOWHERE)
return IN_ROOM(obj);
else if (obj->carried_by)
return IN_ROOM(obj->carried_by);
else if (obj->worn_by)
return IN_ROOM(obj->worn_by);
else if (obj->in_obj)
return obj_room(obj->in_obj);
else
return NOWHERE;
}
/* returns the real room number, or NOWHERE if not found or invalid */
room_rnum find_obj_target_room(obj_data *obj, char *rawroomstr)
{
int tmp;
room_rnum location;
char_data *target_mob;
obj_data *target_obj;
char roomstr[MAX_INPUT_LENGTH];
one_argument(rawroomstr, roomstr);
if (!*roomstr)
return NOWHERE;
if (isdigit(*roomstr) && !strchr(roomstr, '.'))
{
tmp = atoi(roomstr);
if ((location = real_room(tmp)) == NOWHERE)
return NOWHERE;
}
else if ((target_mob = get_char_by_obj(obj, roomstr)))
location = IN_ROOM(target_mob);
else if ((target_obj = get_obj_by_obj(obj, roomstr)))
{
if (IN_ROOM(target_obj) != NOWHERE)
location = IN_ROOM(target_obj);
else
return NOWHERE;
}
else
return NOWHERE;
/* a room has been found. Check for permission */
if (ROOM_FLAGGED(location, ROOM_GODROOM) ||
#ifdef ROOM_IMPROOM
ROOM_FLAGGED(location, ROOM_IMPROOM) ||
#endif
ROOM_FLAGGED(location, ROOM_HOUSE))
return NOWHERE;
if (ROOM_FLAGGED(location, ROOM_PRIVATE) &&
world[location].people && world[location].people->next_in_room)
return NOWHERE;
return location;
}
/* Object commands */
OCMD(do_oecho)
{
int room;
skip_spaces(&argument);
if (!*argument)
obj_log(obj, "oecho called with no args");
else if ((room = obj_room(obj)) != NOWHERE)
{
if (world[room].people)
sub_write(argument, world[room].people, TRUE, TO_ROOM | TO_CHAR);
}
else
obj_log(obj, "oecho called by object in NOWHERE");
}
OCMD(do_oforce)
{
char_data *ch, *next_ch;
int room;
char arg1[MAX_INPUT_LENGTH], *line;
line = one_argument(argument, arg1);
if (!*arg1 || !*line)
{
obj_log(obj, "oforce called with too few args");
return;
}
if (!str_cmp(arg1, "all"))
{
if ((room = obj_room(obj)) == NOWHERE)
obj_log(obj, "oforce called by object in NOWHERE");
else
{
for (ch = world[room].people; ch; ch = next_ch)
{
next_ch = ch->next_in_room;
if (valid_dg_target(ch, 0))
{
command_interpreter(ch, line);
}
}
}
}
else
{
if ((ch = get_char_by_obj(obj, arg1)))
{
if (valid_dg_target(ch, 0))
{
command_interpreter(ch, line);
}
}
else
obj_log(obj, "oforce: no target found");
}
}
OCMD(do_ozoneecho)
{
int zone;
char room_number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH], *msg;
msg = any_one_arg(argument, room_number);
skip_spaces(&msg);
if (!*room_number || !*msg)
obj_log(obj, "ozoneecho called with too few args");
else if ((zone = real_zone_by_thing(atoi(room_number))) == NOWHERE)
obj_log(obj, "ozoneecho called for nonexistant zone");
else {
sprintf(buf, "%s\r\n", msg);
send_to_zone(buf, zone);
}
}
OCMD(do_osend)
{
char buf[MAX_INPUT_LENGTH], *msg;
char_data *ch;
msg = any_one_arg(argument, buf);
if (!*buf)
{
obj_log(obj, "osend called with no args");
return;
}
skip_spaces(&msg);
if (!*msg)
{
obj_log(obj, "osend called without a message");
return;
}
if ((ch = get_char_by_obj(obj, buf)))
{
if (subcmd == SCMD_OSEND)
sub_write(msg, ch, TRUE, TO_CHAR);
else if (subcmd == SCMD_OECHOAROUND)
sub_write(msg, ch, TRUE, TO_ROOM);
}
else
obj_log(obj, "no target found for osend");
}
/* prints the message to everyone in the range of numbers */
/* Thx to Jamie Nelson of 4D for this contribution */
OCMD(do_orecho)
{
char start[MAX_INPUT_LENGTH], finish[MAX_INPUT_LENGTH], *msg;
msg = two_arguments(argument, start, finish);
skip_spaces(&msg);
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
obj_log(obj, "orecho: too few args");
else
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
}
/* set the object's timer value */
OCMD(do_otimer)
{
char arg[MAX_INPUT_LENGTH];
one_argument(argument, arg);
if (!*arg)
obj_log(obj, "otimer: missing argument");
else if (!isdigit(*arg))
obj_log(obj, "otimer: bad argument");
else
GET_OBJ_TIMER(obj) = atoi(arg);
}
/* transform into a different object */
/* note: this shouldn't be used with containers unless both objects */
/* are containers! */
OCMD(do_otransform)
{
char arg[MAX_INPUT_LENGTH];
obj_data *o, tmpobj;
struct char_data *wearer=NULL;
int pos = 0;
one_argument(argument, arg);
if (!*arg)
obj_log(obj, "otransform: missing argument");
else if (!isdigit(*arg))
obj_log(obj, "otransform: bad argument");
else {
o = read_object(atoi(arg), VIRTUAL);
if (o==NULL) {
obj_log(obj, "otransform: bad object vnum");
return;
}
if (obj->worn_by) {
pos = obj->worn_on;
wearer = obj->worn_by;
unequip_char(obj->worn_by, pos);
}
/* move new obj info over to old object and delete new obj */
memcpy(&tmpobj, o, sizeof(*o));
tmpobj.in_room = IN_ROOM(obj);
tmpobj.carried_by = obj->carried_by;
tmpobj.worn_by = obj->worn_by;
tmpobj.worn_on = obj->worn_on;
tmpobj.in_obj = obj->in_obj;
tmpobj.contains = obj->contains;
tmpobj.id = obj->id;
tmpobj.proto_script = obj->proto_script;
tmpobj.script = obj->script;
tmpobj.next_content = obj->next_content;
tmpobj.next = obj->next;
memcpy(obj, &tmpobj, sizeof(*obj));
if (wearer) {
equip_char(wearer, obj, pos);
}
extract_obj(o);
}
}
/* purge all objects an npcs in room, or specified object or mob */
OCMD(do_opurge)
{
char arg[MAX_INPUT_LENGTH];
char_data *ch, *next_ch;
obj_data *o, *next_obj;
int rm;
one_argument(argument, arg);
if (!*arg) {
/* purge all */
if ((rm = obj_room(obj)) != NOWHERE) {
for (ch = world[rm].people; ch; ch = next_ch ) {
next_ch = ch->next_in_room;
if (IS_NPC(ch))
extract_char(ch);
}
for (o = world[rm].contents; o; o = next_obj ) {
next_obj = o->next_content;
if (o != obj)
extract_obj(o);
}
}
return;
} /* no arg */
ch = get_char_by_obj(obj, arg);
if (!ch) {
o = get_obj_by_obj(obj, arg);
if (o) {
if (o==obj)
dg_owner_purged = 1;
extract_obj(o);
} else
obj_log(obj, "opurge: bad argument");
return;
}
if (!IS_NPC(ch)) {
obj_log(obj, "opurge: purging a PC");
return;
}
extract_char(ch);
}
OCMD(do_oteleport)
{
char_data *ch, *next_ch;
room_rnum target, rm;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
two_arguments(argument, arg1, arg2);
if (!*arg1 || !*arg2)
{
obj_log(obj, "oteleport called with too few args");
return;
}
target = find_obj_target_room(obj, arg2);
if (target == NOWHERE)
obj_log(obj, "oteleport target is an invalid room");
else if (!str_cmp(arg1, "all"))
{
rm = obj_room(obj);
if (target == rm)
obj_log(obj, "oteleport target is itself");
for (ch = world[rm].people; ch; ch = next_ch)
{
next_ch = ch->next_in_room;
if (!valid_dg_target(ch, DG_ALLOW_GODS))
continue;
char_from_room(ch);
char_to_room(ch, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
else
{
if ((ch = get_char_by_obj(obj, arg1))) {
if (valid_dg_target(ch, DG_ALLOW_GODS)) {
char_from_room(ch);
char_to_room(ch, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
else
obj_log(obj, "oteleport: no target found");
}
}
OCMD(do_dgoload)
{
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int number = 0, room;
char_data *mob;
obj_data *object;
char *target;
char_data *tch;
obj_data *cnt;
int pos;
target = two_arguments(argument, arg1, arg2);
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0))
{
obj_log(obj, "oload: bad syntax");
return;
}
if ((room = obj_room(obj)) == NOWHERE)
{
obj_log(obj, "oload: object in NOWHERE trying to load");
return;
}
/* load mob to target room - Jamie Nelson, April 13 2004 */
if (is_abbrev(arg1, "mob")) {
room_rnum rnum;
if (!target || !*target) {
rnum = room;
} else {
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE) {
obj_log(obj, "oload: room target vnum doesn't exist "
"(loading mob vnum %d to room %s)", number, target);
return;
}
}
if ((mob = read_mobile(number, VIRTUAL)) == NULL) {
obj_log(obj, "oload: bad mob vnum");
return;
}
char_to_room(mob, rnum);
if (SCRIPT(obj)) { // it _should_ have, but it might be detached.
char buf[MAX_INPUT_LENGTH];
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(mob));
add_var(&(SCRIPT(obj)->global_vars), "lastloaded", buf, 0);
}
load_mtrigger(mob);
}
else if (is_abbrev(arg1, "obj")) {
if ((object = read_object(number, VIRTUAL)) == NULL) {
obj_log(obj, "oload: bad object vnum");
return;
}
if (SCRIPT(obj)) { // it _should_ have, but it might be detached.
char buf[MAX_INPUT_LENGTH];
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(object));
add_var(&(SCRIPT(obj)->global_vars), "lastloaded", buf, 0);
}
/* special handling to make objects able to load on a person/in a container/worn etc. */
if (!target || !*target) {
obj_to_room(object, room);
load_otrigger(object);
return;
}
two_arguments(target, arg1, arg2); /* recycling ... */
tch = get_char_near_obj(obj, arg1);
if (tch) {
if (arg2 && *arg2 &&
(pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) &&
can_wear_on_pos(object, pos)) {
equip_char(tch, object, pos);
load_otrigger(object);
return;
}
obj_to_char(object, tch);
load_otrigger(object);
return;
}
cnt = get_obj_near_obj(obj, arg1);
if (cnt && GET_OBJ_TYPE(cnt) == ITEM_CONTAINER) {
obj_to_obj(object, cnt);
load_otrigger(object);
return;
}
/* neither char nor container found - just dump it in room */
obj_to_room(object, room);
load_otrigger(object);
return;
}
else
obj_log(obj, "oload: bad type");
}
OCMD(do_odamage) {
char name[MAX_INPUT_LENGTH], amount[MAX_INPUT_LENGTH];
int dam = 0;
char_data *ch;
two_arguments(argument, name, amount);
/* who cares if it's a number ? if not it'll just be 0 */
if (!*name || !*amount) {
obj_log(obj, "odamage: bad syntax");
return;
}
dam = atoi(amount);
ch = get_char_by_obj(obj, name);
if (!ch) {
obj_log(obj, "odamage: target not found");
return;
}
script_damage(ch, dam);
}
OCMD(do_oasound)
{
room_rnum room;
int door;
skip_spaces(&argument);
if (!*argument) {
obj_log(obj, "oasound called with no args");
return;
}
if ((room = obj_room(obj)) == NOWHERE) {
obj_log(obj, "oecho called by object in NOWHERE");
return;
}
for (door = 0; door < NUM_OF_DIRS; door++) {
if (world[room].dir_option[door] != NULL &&
(world[room].dir_option[door])->to_room != NOWHERE &&
(world[room].dir_option[door])->to_room != room &&
world[(world[room].dir_option[door])->to_room].people)
sub_write(argument, world[(world[room].dir_option[door])->to_room].people, TRUE, TO_ROOM | TO_CHAR);
}
}
OCMD(do_odoor)
{
char target[MAX_INPUT_LENGTH], direction[MAX_INPUT_LENGTH];
char field[MAX_INPUT_LENGTH], *value;
room_data *rm;
struct room_direction_data *newexit;
int dir, fd, to_room;
const char *door_field[] = {
"purge",
"description",
"flags",
"key",
"name",
"room",
"\n"
};
argument = two_arguments(argument, target, direction);
value = one_argument(argument, field);
skip_spaces(&value);
if (!*target || !*direction || !*field) {
obj_log(obj, "odoor called with too few args");
return;
}
if ((rm = get_room(target)) == NULL) {
obj_log(obj, "odoor: invalid target");
return;
}
if ((dir = search_block(direction, dirs, FALSE)) == -1) {
obj_log(obj, "odoor: invalid direction");
return;
}
if ((fd = search_block(field, door_field, FALSE)) == -1) {
obj_log(obj, "odoor: invalid field");
return;
}
newexit = rm->dir_option[dir];
/* purge exit */
if (fd == 0) {
if (newexit) {
if (newexit->general_description)
free(newexit->general_description);
if (newexit->keyword)
free(newexit->keyword);
free(newexit);
rm->dir_option[dir] = NULL;
}
}
else {
if (!newexit) {
CREATE(newexit, struct room_direction_data, 1);
rm->dir_option[dir] = newexit;
}
switch (fd) {
case 1: /* description */
if (newexit->general_description)
free(newexit->general_description);
CREATE(newexit->general_description, char, strlen(value) + 3);
strcpy(newexit->general_description, value);
strcat(newexit->general_description, "\r\n"); /* strcat : OK */
break;
case 2: /* flags */
newexit->exit_info = (sh_int)asciiflag_conv(value);
break;
case 3: /* key */
newexit->key = atoi(value);
break;
case 4: /* name */
if (newexit->keyword)
free(newexit->keyword);
CREATE(newexit->keyword, char, strlen(value) + 1);
strcpy(newexit->keyword, value);
break;
case 5: /* room */
if ((to_room = real_room(atoi(value))) != NOWHERE)
newexit->to_room = to_room;
else
obj_log(obj, "odoor: invalid door target");
break;
}
}
}
OCMD(do_osetval)
{
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int position, new_value;
two_arguments(argument, arg1, arg2);
if (!arg1 || !*arg1 || !arg2 || !*arg2 ||
!is_number(arg1) || !is_number(arg2)) {
obj_log(obj, "osetval: bad syntax");
return;
}
position = atoi(arg1);
new_value = atoi(arg2);
if (position>=0 && position<NUM_OBJ_VAL_POSITIONS)
GET_OBJ_VAL(obj, position) = new_value;
else
obj_log(obj, "osetval: position out of bounds!");
}
/* submitted by PurpleOnyx - tkhasi@shadowglen.com*/
OCMD(do_oat)
{
char location[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int vnum = 0, rnum = 0;
obj_data *object;
half_chop(argument, location, arg2);
if (!*location || !*arg2 || !isdigit(*location)) {
obj_log(obj, "oat: bad syntax : %s", argument);
return;
}
vnum = atoi(location);
rnum = real_room(vnum);
if (rnum == NOWHERE) {
obj_log(obj, "oat: location not found");
return;
}
object = read_object(GET_OBJ_VNUM(obj), VIRTUAL);
if (!object)
return;
obj_to_room(object, rnum);
obj_command_interpreter(object, arg2);
if (object->in_room == rnum)
extract_obj(object);
}
const struct obj_command_info obj_cmd_info[] = {
{ "RESERVED", 0, 0 },/* this must be first -- for specprocs */
{ "oasound " , do_oasound , 0 },
{ "oat " , do_oat , 0 },
{ "odoor " , do_odoor , 0 },
{ "odamage " , do_odamage, 0 },
{ "oecho " , do_oecho , 0 },
{ "oechoaround ", do_osend , SCMD_OECHOAROUND },
{ "oforce " , do_oforce , 0 },
{ "oload " , do_dgoload , 0 },
{ "opurge " , do_opurge , 0 },
{ "orecho " , do_orecho , 0 },
{ "osend " , do_osend , SCMD_OSEND },
{ "osetval " , do_osetval , 0 },
{ "oteleport " , do_oteleport, 0 },
{ "otimer " , do_otimer , 0 },
{ "otransform " , do_otransform, 0 },
{ "ozoneecho " , do_ozoneecho , 0 }, /* fix by Rumble */
{ "\n", 0, 0 } /* this must be last */
};
/*
* This is the command interpreter used by objects, called by script_driver.
*/
void obj_command_interpreter(obj_data *obj, char *argument)
{
int cmd, length;
char *line, arg[MAX_INPUT_LENGTH];
skip_spaces(&argument);
/* just drop to next line for hitting CR */
if (!*argument)
return;
line = any_one_arg(argument, arg);
/* find the command */
for (length = strlen(arg),cmd = 0;
*obj_cmd_info[cmd].command != '\n'; cmd++)
if (!strncmp(obj_cmd_info[cmd].command, arg, length))
break;
if (*obj_cmd_info[cmd].command == '\n')
obj_log(obj, "Unknown object cmd: '%s'", argument);
else
((*obj_cmd_info[cmd].command_pointer)
(obj, line, cmd, obj_cmd_info[cmd].subcmd));
}

1014
src/dg_olc.c Normal file

File diff suppressed because it is too large Load diff

46
src/dg_olc.h Normal file
View file

@ -0,0 +1,46 @@
/**************************************************************************
* File: dg_olc.h *
* *
* Usage: this source file is used in extending Oasis style OLC for *
* dg-scripts onto a CircleMUD that already has dg-scripts (as released *
* by Mark Heilpern on 1/1/98) implemented. *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#include "dg_scripts.h"
#define NUM_TRIG_TYPE_FLAGS 20
/*
* Submodes of TRIGEDIT connectedness.
*/
#define TRIGEDIT_MAIN_MENU 0
#define TRIGEDIT_TRIGTYPE 1
#define TRIGEDIT_CONFIRM_SAVESTRING 2
#define TRIGEDIT_NAME 3
#define TRIGEDIT_INTENDED 4
#define TRIGEDIT_TYPES 5
#define TRIGEDIT_COMMANDS 6
#define TRIGEDIT_NARG 7
#define TRIGEDIT_ARGUMENT 8
#define OLC_SCRIPT_EDIT 82766 /* arbitrary > highest possible room number */
#define SCRIPT_MAIN_MENU 0
#define SCRIPT_NEW_TRIGGER 1
#define SCRIPT_DEL_TRIGGER 2
#define OLC_SCRIPT_EDIT_MODE(d) (OLC(d)->script_mode) /* parse input mode */
#define OLC_SCRIPT(d) (OLC(d)->script) /* script editing */
#define OLC_ITEM_TYPE(d) (OLC(d)->item_type) /* mob/obj/room */
/* prototype exported functions from dg_olc.c */
void script_save_to_disk(FILE *fp, void *item, int type);
void dg_olc_script_free(struct descriptor_data *d);
void dg_olc_script_copy(struct descriptor_data *d);
void dg_script_menu(struct descriptor_data *d);
int dg_script_edit_parse(struct descriptor_data *d, char *arg);

3058
src/dg_scripts.c Normal file

File diff suppressed because it is too large Load diff

408
src/dg_scripts.h Normal file
View file

@ -0,0 +1,408 @@
/**************************************************************************
* File: dg_scripts.h *
* Usage: header file for script structures and constants, and *
* function prototypes for dg_scripts.c *
* *
* *
* $Author: Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#define DG_SCRIPT_VERSION "DG Scripts 1.0.14"
#define MOB_TRIGGER 0
#define OBJ_TRIGGER 1
#define WLD_TRIGGER 2
/* unless you change this, Puff casts all your dg spells */
#define DG_CASTER_PROXY 1
/* spells cast by objects and rooms use this level */
#define DG_SPELL_LEVEL 25
/*
* define this if you don't want wear/remove triggers to fire when
* a player is saved.
*/
#define NO_EXTRANEOUS_TRIGGERS
/*
* %actor.room% behaviour :
* Until pl 7 %actor.room% returned a room vnum.
* Working with this number in scripts was unnecessarily hard,
* especially in those situations one needed the id of the room,
* the items in it, etc. As a result of this, the output
* has been changed (as of pl 8) to a room variable.
* This means old scripts will need a minor adjustment;
*
* Before:
* if %actor.room%==3001
* %echo% You are at the main temple.
*
* After:
* eval room %actor.room%
* if %room.vnum%==3001
* %echo% You are at the main temple.
*
* If you wish to continue using the old style, comment out the line below.
*
* Welcor
*/
#define ACTOR_ROOM_IS_UID 1
/* mob trigger types */
#define MTRIG_GLOBAL (1 << 0) /* check even if zone empty */
#define MTRIG_RANDOM (1 << 1) /* checked randomly */
#define MTRIG_COMMAND (1 << 2) /* character types a command */
#define MTRIG_SPEECH (1 << 3) /* a char says a word/phrase */
#define MTRIG_ACT (1 << 4) /* word or phrase sent to act */
#define MTRIG_DEATH (1 << 5) /* character dies */
#define MTRIG_GREET (1 << 6) /* something enters room seen */
#define MTRIG_GREET_ALL (1 << 7) /* anything enters room */
#define MTRIG_ENTRY (1 << 8) /* the mob enters a room */
#define MTRIG_RECEIVE (1 << 9) /* character is given obj */
#define MTRIG_FIGHT (1 << 10) /* each pulse while fighting */
#define MTRIG_HITPRCNT (1 << 11) /* fighting and below some hp */
#define MTRIG_BRIBE (1 << 12) /* coins are given to mob */
#define MTRIG_LOAD (1 << 13) /* the mob is loaded */
#define MTRIG_MEMORY (1 << 14) /* mob see's someone remembered */
#define MTRIG_CAST (1 << 15) /* mob targetted by spell */
#define MTRIG_LEAVE (1 << 16) /* someone leaves room seen */
#define MTRIG_DOOR (1 << 17) /* door manipulated in room */
#define MTRIG_TIME (1 << 19) /* trigger based on game hour */
/* obj trigger types */
#define OTRIG_GLOBAL (1 << 0) /* unused */
#define OTRIG_RANDOM (1 << 1) /* checked randomly */
#define OTRIG_COMMAND (1 << 2) /* character types a command */
#define OTRIG_TIMER (1 << 5) /* item's timer expires */
#define OTRIG_GET (1 << 6) /* item is picked up */
#define OTRIG_DROP (1 << 7) /* character trys to drop obj */
#define OTRIG_GIVE (1 << 8) /* character trys to give obj */
#define OTRIG_WEAR (1 << 9) /* character trys to wear obj */
#define OTRIG_REMOVE (1 << 11) /* character trys to remove obj */
#define OTRIG_LOAD (1 << 13) /* the object is loaded */
#define OTRIG_CAST (1 << 15) /* object targetted by spell */
#define OTRIG_LEAVE (1 << 16) /* someone leaves room seen */
#define OTRIG_CONSUME (1 << 18) /* char tries to eat/drink obj */
#define OTRIG_TIME (1 << 19) /* trigger based on game hour */
/* wld trigger types */
#define WTRIG_GLOBAL (1 << 0) /* check even if zone empty */
#define WTRIG_RANDOM (1 << 1) /* checked randomly */
#define WTRIG_COMMAND (1 << 2) /* character types a command */
#define WTRIG_SPEECH (1 << 3) /* a char says word/phrase */
#define WTRIG_RESET (1 << 5) /* zone has been reset */
#define WTRIG_ENTER (1 << 6) /* character enters room */
#define WTRIG_DROP (1 << 7) /* something dropped in room */
#define WTRIG_CAST (1 << 15) /* spell cast in room */
#define WTRIG_LEAVE (1 << 16) /* character leaves the room */
#define WTRIG_DOOR (1 << 17) /* door manipulated in room */
#define WTRIG_TIME (1 << 19) /* trigger based on game hour */
/* obj command trigger types */
#define OCMD_EQUIP (1 << 0) /* obj must be in char's equip */
#define OCMD_INVEN (1 << 1) /* obj must be in char's inven */
#define OCMD_ROOM (1 << 2) /* obj must be in char's room */
/* obj consume trigger commands */
#define OCMD_EAT 1
#define OCMD_DRINK 2
#define OCMD_QUAFF 3
#define TRIG_NEW 0 /* trigger starts from top */
#define TRIG_RESTART 1 /* trigger restarting */
/*
* These are slightly off of PULSE_MOBILE so
* everything isnt happening at the same time
*/
#define PULSE_DG_SCRIPT (13 RL_SEC)
#define MAX_SCRIPT_DEPTH 10 /* maximum depth triggers can
recurse into each other */
#define SCRIPT_ERROR_CODE -9999999 /* this shouldn't happen too often */
/* one line of the trigger */
struct cmdlist_element {
char *cmd; /* one line of a trigger */
struct cmdlist_element *original;
struct cmdlist_element *next;
};
struct trig_var_data {
char *name; /* name of variable */
char *value; /* value of variable */
long context; /* 0: global context */
struct trig_var_data *next;
};
/* structure for triggers */
struct trig_data {
IDXTYPE nr; /* trigger's rnum */
byte attach_type; /* mob/obj/wld intentions */
byte data_type; /* type of game_data for trig */
char *name; /* name of trigger */
long trigger_type; /* type of trigger (for bitvector) */
struct cmdlist_element *cmdlist; /* top of command list */
struct cmdlist_element *curr_state; /* ptr to current line of trigger */
int narg; /* numerical argument */
char *arglist; /* argument list */
int depth; /* depth into nest ifs/whiles/etc */
int loops; /* loop iteration counter */
struct event *wait_event; /* event to pause the trigger */
ubyte purged; /* trigger is set to be purged */
struct trig_var_data *var_list; /* list of local vars for trigger */
struct trig_data *next;
struct trig_data *next_in_world; /* next in the global trigger list */
};
/* a complete script (composed of several triggers) */
struct script_data {
long types; /* bitvector of trigger types */
struct trig_data *trig_list; /* list of triggers */
struct trig_var_data *global_vars; /* list of global variables */
ubyte purged; /* script is set to be purged */
long context; /* current context for statics */
struct script_data *next; /* used for purged_scripts */
};
/* The event data for the wait command */
struct wait_event_data {
struct trig_data *trigger;
void *go;
int type;
};
/* typedefs that the dg functions rely on */
typedef struct index_data index_data;
typedef struct room_data room_data;
typedef struct obj_data obj_data;
typedef struct trig_data trig_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 */
char *one_phrase(char *arg, char *first_arg);
int is_substring(char *sub, char *string);
int word_check(char *str, char *wordlist);
void act_mtrigger(const char_data *ch, char *str,
char_data *actor, char_data *victim, obj_data *object, obj_data *target, char *arg);
void speech_mtrigger(char_data *actor, char *str);
void speech_wtrigger(char_data *actor, char *str);
void greet_memory_mtrigger(char_data *ch);
int greet_mtrigger(char_data *actor, int dir);
int entry_mtrigger(char_data *ch);
void entry_memory_mtrigger(char_data *ch);
int enter_wtrigger(room_data *room, char_data *actor, int dir);
int drop_otrigger(obj_data *obj, char_data *actor);
void timer_otrigger(obj_data *obj);
int get_otrigger(obj_data *obj, char_data *actor);
int drop_wtrigger(obj_data *obj, char_data *actor);
int give_otrigger(obj_data *obj, char_data *actor,
char_data *victim);
int receive_mtrigger(char_data *ch, char_data *actor,
obj_data *obj);
void bribe_mtrigger(char_data *ch, char_data *actor,
int amount);
int wear_otrigger(obj_data *obj, char_data *actor, int where);
int remove_otrigger(obj_data *obj, char_data *actor);
int cmd_otrig(obj_data *obj, char_data *actor, char *cmd,
char *argument, int type);
int command_mtrigger(char_data *actor, char *cmd, char *argument);
int command_otrigger(char_data *actor, char *cmd, char *argument);
int command_wtrigger(char_data *actor, char *cmd, char *argument);
int death_mtrigger(char_data *ch, char_data *actor);
void fight_mtrigger(char_data *ch);
void hitprcnt_mtrigger(char_data *ch);
void random_mtrigger(char_data *ch);
void random_otrigger(obj_data *obj);
void random_wtrigger(room_data *ch);
void reset_wtrigger(room_data *ch);
void load_mtrigger(char_data *ch);
void load_otrigger(obj_data *obj);
int cast_mtrigger(char_data *actor, char_data *ch, int spellnum);
int cast_otrigger(char_data *actor, obj_data *obj, int spellnum);
int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum);
int leave_mtrigger(char_data *actor, int dir);
int leave_wtrigger(room_data *room, char_data *actor, int dir);
int leave_otrigger(room_data *room, char_data *actor, int dir);
int door_mtrigger(char_data *actor, int subcmd, int dir);
int door_wtrigger(char_data *actor, int subcmd, int dir);
int consume_otrigger(obj_data *obj, char_data *actor, int cmd);
void time_mtrigger(char_data *ch);
void time_otrigger(obj_data *obj);
void time_wtrigger(room_data *room);
/* function prototypes from dg_scripts.c */
char *str_str(char *cs, char *ct);
int find_eq_pos_script(char *arg);
int can_wear_on_pos(struct obj_data *obj, int pos);
struct char_data *find_char(long n);
char_data *get_char(char *name);
char_data *get_char_near_obj(obj_data *obj, char *name);
char_data *get_char_in_room(room_data *room, char *name);
obj_data *get_obj_near_obj(obj_data *obj, char *name);
obj_data *get_obj(char *name);
room_data *get_room(char *name);
char_data *get_char_by_obj(obj_data *obj, char *name);
char_data *get_char_by_room(room_data *room, char *name);
obj_data *get_obj_by_obj(obj_data *obj, char *name);
obj_data *get_obj_in_room(room_data *room, char *name);
obj_data *get_obj_by_room(room_data *room, char *name);
int trgvar_in_room(room_vnum vnum);
obj_data *get_obj_in_list(char *name, obj_data *list);
obj_data *get_object_in_equip(char_data * ch, char *name);
void script_trigger_check(void);
void check_time_triggers(void);
void find_uid_name(char *uid, char *name, size_t nlen);
void do_sstat_room(struct char_data * ch);
void do_sstat_object(char_data *ch, obj_data *j);
void do_sstat_character(char_data *ch, char_data *k);
void add_trigger(struct script_data *sc, trig_data *t, int loc);
void script_vlog(const char *format, va_list args);
void script_log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
char *matching_quote(char *p);
struct room_data *dg_room_of_obj(struct obj_data *obj);
/* 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. */
int script_driver(void *go_adress, trig_data *trig, int type, int mode);
trig_rnum real_trigger(trig_vnum vnum);
void process_eval(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd);
void read_saved_vars(struct char_data *ch);
void save_char_vars(struct char_data *ch);
void init_lookup_table(void);
void add_to_lookup_table(long uid, void *c);
void remove_from_lookup_table(long uid);
/* from dg_db_scripts.c */
void parse_trigger(FILE *trig_f, int nr);
trig_data *read_trigger(int nr);
void trig_data_init(trig_data *this_data);
void trig_data_copy(trig_data *this_data, const trig_data *trg);
void dg_read_trigger(FILE *fp, void *proto, int type);
void dg_obj_trigger(char *line, struct obj_data *obj);
void assign_triggers(void *i, int type);
/* From dg_variables.c */
void add_var(struct trig_var_data **var_list, char *name, char *value, long id);
int item_in_list(char *item, obj_data *list);
char *skill_percent(struct char_data *ch, char *skill);
int char_has_item(char *item, struct char_data *ch);
void var_subst(void *go, struct script_data *sc, trig_data *trig,
int type, char *line, char *buf);
int text_processed(char *field, char *subfield, struct trig_var_data *vd,
char *str, size_t slen);
void find_replacement(void *go, struct script_data *sc, trig_data *trig,
int type, char *var, char *field, char *subfield, char *str, size_t slen);
/* From dg_handler.c */
void free_var_el(struct trig_var_data *var);
void free_varlist(struct trig_var_data *vd);
int remove_var(struct trig_var_data **var_list, char *name);
void free_trigger(trig_data *trig);
void extract_trigger(struct trig_data *trig);
void extract_script(void *thing, int type);
void extract_script_mem(struct script_memory *sc);
void free_proto_script(void *thing, int type);
void copy_proto_script(void *source, void *dest, int type);
void delete_variables(const char *charname);
void update_wait_events(struct room_data *to, struct room_data *from);
/* from dg_comm.c */
char *any_one_name(char *argument, char *first_arg);
void sub_write_to_char(char_data *ch, char *tokens[],
void *otokens[], char type[]);
void sub_write(char *arg, char_data *ch, byte find_invis, int targets);
void send_to_zone(char *messg, zone_rnum zone);
/* from dg_misc.c */
void do_dg_cast(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd);
void do_dg_affect(void *go, struct script_data *sc, trig_data *trig,
int type, char *cmd);
void send_char_pos(struct char_data *ch, int dam);
int valid_dg_target(char_data *ch, int bitvector);
void script_damage(char_data *vict, int dam);
/* from dg_objcmd.c */
room_rnum obj_room(obj_data *obj);
/* defines for valid_dg_target */
#define DG_ALLOW_GODS (1<<0)
/* Macros for scripts */
#define UID_CHAR '}'
#define GET_TRIG_NAME(t) ((t)->name)
#define GET_TRIG_RNUM(t) ((t)->nr)
#define GET_TRIG_VNUM(t) (trig_index[(t)->nr]->vnum)
#define GET_TRIG_TYPE(t) ((t)->trigger_type)
#define GET_TRIG_DATA_TYPE(t) ((t)->data_type)
#define GET_TRIG_NARG(t) ((t)->narg)
#define GET_TRIG_ARG(t) ((t)->arglist)
#define GET_TRIG_VARS(t) ((t)->var_list)
#define GET_TRIG_WAIT(t) ((t)->wait_event)
#define GET_TRIG_DEPTH(t) ((t)->depth)
#define GET_TRIG_LOOPS(t) ((t)->loops)
/* player id's: 0 to MOB_ID_BASE - 1 */
/* mob id's: MOB_ID_BASE to ROOM_ID_BASE - 1 */
/* room id's: ROOM_ID_BASE to OBJ_ID_BASE - 1 */
/* object id's: OBJ_ID_BASE and higher */
#define MOB_ID_BASE 50000 /* 50000 player IDNUMS should suffice */
#define ROOM_ID_BASE 1050000 /* 1000000 Mobs */
#define OBJ_ID_BASE 1300000 /* 250000 Rooms */
#define SCRIPT(o) ((o)->script)
#define SCRIPT_MEM(c) ((c)->memory)
#define SCRIPT_TYPES(s) ((s)->types)
#define TRIGGERS(s) ((s)->trig_list)
#define GET_SHORT(ch) ((ch)->player.short_descr)
#define SCRIPT_CHECK(go, type) (SCRIPT(go) && \
IS_SET(SCRIPT_TYPES(SCRIPT(go)), type))
#define TRIGGER_CHECK(t, type) (IS_SET(GET_TRIG_TYPE(t), type) && \
!GET_TRIG_DEPTH(t))
#define ADD_UID_VAR(buf, trig, go, name, context) do { \
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(go)); \
add_var(&GET_TRIG_VARS(trig), name, buf, context); } while (0)

1301
src/dg_triggers.c Normal file

File diff suppressed because it is too large Load diff

1548
src/dg_variables.c Normal file

File diff suppressed because it is too large Load diff

633
src/dg_wldcmd.c Normal file
View file

@ -0,0 +1,633 @@
/**************************************************************************
* File: dg_wldcmd.c *
* Usage: contains the command_interpreter for rooms, *
* room commands. *
* *
* *
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "screen.h"
#include "dg_scripts.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "constants.h"
/*
* External functions
*/
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) \
void (name)(room_data *room, char *argument, int cmd, int subcmd)
void wld_log(room_data *room, const char *format, ...);
void act_to_room(char *str, room_data *room);
WCMD(do_wasound);
WCMD(do_wecho);
WCMD(do_wsend);
WCMD(do_wzoneecho);
WCMD(do_wrecho);
WCMD(do_wdoor);
WCMD(do_wteleport);
WCMD(do_wforce);
WCMD(do_wpurge);
WCMD(do_wload);
WCMD(do_wdamage);
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 */
void wld_log(room_data *room, const char *format, ...)
{
va_list args;
char output[MAX_STRING_LENGTH];
snprintf(output, sizeof(output), "Room %d :: %s", room->number, format);
va_start(args, format);
script_vlog(output, args);
va_end(args);
}
/* sends str to room */
void act_to_room(char *str, room_data *room)
{
/* no one is in the room */
if (!room->people)
return;
/*
* since you can't use act(..., TO_ROOM) for an room, send it
* TO_ROOM and TO_CHAR for some char in the room.
* (just dont use $n or you might get strange results)
*/
act(str, FALSE, room->people, 0, 0, TO_ROOM);
act(str, FALSE, room->people, 0, 0, TO_CHAR);
}
/* World commands */
/* prints the argument to all the rooms aroud the room */
WCMD(do_wasound)
{
int door;
skip_spaces(&argument);
if (!*argument) {
wld_log(room, "wasound called with no argument");
return;
}
for (door = 0; door < NUM_OF_DIRS; door++) {
struct room_direction_data *newexit;
if ((newexit = room->dir_option[door]) && (newexit->to_room != NOWHERE) &&
room != &world[newexit->to_room])
act_to_room(argument, &world[newexit->to_room]);
}
}
WCMD(do_wecho)
{
skip_spaces(&argument);
if (!*argument)
wld_log(room, "wecho called with no args");
else
act_to_room(argument, room);
}
WCMD(do_wsend)
{
char buf[MAX_INPUT_LENGTH], *msg;
char_data *ch;
msg = any_one_arg(argument, buf);
if (!*buf)
{
wld_log(room, "wsend called with no args");
return;
}
skip_spaces(&msg);
if (!*msg)
{
wld_log(room, "wsend called without a message");
return;
}
if ((ch = get_char_by_room(room, buf)))
{
if (subcmd == SCMD_WSEND)
sub_write(msg, ch, TRUE, TO_CHAR);
else if (subcmd == SCMD_WECHOAROUND)
sub_write(msg, ch, TRUE, TO_ROOM);
}
else
wld_log(room, "no target found for wsend");
}
WCMD(do_wzoneecho)
{
zone_rnum zone;
char room_num[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH], *msg;
msg = any_one_arg(argument, room_num);
skip_spaces(&msg);
if (!*room_num || !*msg)
wld_log(room, "wzoneecho called with too few args");
else if ((zone = real_zone_by_thing(atoi(room_num))) == NOWHERE)
wld_log(room, "wzoneecho called for nonexistant zone");
else {
sprintf(buf, "%s\r\n", msg);
send_to_zone(buf, zone);
}
}
/* prints the message to everyone in the range of numbers */
/* Thx to Jamie Nelson of 4D for this contribution */
WCMD(do_wrecho)
{
char start[MAX_INPUT_LENGTH], finish[MAX_INPUT_LENGTH], *msg;
msg = two_arguments(argument, start, finish);
skip_spaces(&msg);
if (!*msg || !*start || !*finish || !is_number(start) || !is_number(finish))
wld_log(room, "wrecho: too few args");
else
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
}
WCMD(do_wdoor)
{
char target[MAX_INPUT_LENGTH], direction[MAX_INPUT_LENGTH];
char field[MAX_INPUT_LENGTH], *value;
room_data *rm;
struct room_direction_data *newexit;
int dir, fd, to_room;
const char *door_field[] = {
"purge",
"description",
"flags",
"key",
"name",
"room",
"\n"
};
argument = two_arguments(argument, target, direction);
value = one_argument(argument, field);
skip_spaces(&value);
if (!*target || !*direction || !*field) {
wld_log(room, "wdoor called with too few args");
return;
}
if ((rm = get_room(target)) == NULL) {
wld_log(room, "wdoor: invalid target");
return;
}
if ((dir = search_block(direction, dirs, FALSE)) == -1) {
wld_log(room, "wdoor: invalid direction");
return;
}
if ((fd = search_block(field, door_field, FALSE)) == -1) {
wld_log(room, "wdoor: invalid field");
return;
}
newexit = rm->dir_option[dir];
/* purge exit */
if (fd == 0) {
if (newexit) {
if (newexit->general_description)
free(newexit->general_description);
if (newexit->keyword)
free(newexit->keyword);
free(newexit);
rm->dir_option[dir] = NULL;
}
}
else {
if (!newexit) {
CREATE(newexit, struct room_direction_data, 1);
rm->dir_option[dir] = newexit;
}
switch (fd) {
case 1: /* description */
if (newexit->general_description)
free(newexit->general_description);
CREATE(newexit->general_description, char, strlen(value) + 3);
strcpy(newexit->general_description, value);
strcat(newexit->general_description, "\r\n");
break;
case 2: /* flags */
newexit->exit_info = (sh_int)asciiflag_conv(value);
break;
case 3: /* key */
newexit->key = atoi(value);
break;
case 4: /* name */
if (newexit->keyword)
free(newexit->keyword);
CREATE(newexit->keyword, char, strlen(value) + 1);
strcpy(newexit->keyword, value);
break;
case 5: /* room */
if ((to_room = real_room(atoi(value))) != NOWHERE)
newexit->to_room = to_room;
else
wld_log(room, "wdoor: invalid door target");
break;
}
}
}
WCMD(do_wteleport)
{
char_data *ch, *next_ch;
room_rnum target, nr;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
two_arguments(argument, arg1, arg2);
if (!*arg1 || !*arg2) {
wld_log(room, "wteleport called with too few args");
return;
}
nr = atoi(arg2);
target = real_room(nr);
if (target == NOWHERE)
wld_log(room, "wteleport target is an invalid room");
else if (!str_cmp(arg1, "all")) {
if (nr == room->number) {
wld_log(room, "wteleport all target is itself");
return;
}
for (ch = room->people; ch; ch = next_ch)
{
next_ch = ch->next_in_room;
if (!valid_dg_target(ch, DG_ALLOW_GODS))
continue;
char_from_room(ch);
char_to_room(ch, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
else
{
if ((ch = get_char_by_room(room, arg1))) {
if (valid_dg_target(ch, DG_ALLOW_GODS)) {
char_from_room(ch);
char_to_room(ch, target);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
else
wld_log(room, "wteleport: no target found");
}
}
WCMD(do_wforce)
{
char_data *ch, *next_ch;
char arg1[MAX_INPUT_LENGTH], *line;
line = one_argument(argument, arg1);
if (!*arg1 || !*line) {
wld_log(room, "wforce called with too few args");
return;
}
if (!str_cmp(arg1, "all"))
{
for (ch = room->people; ch; ch = next_ch)
{
next_ch = ch->next_in_room;
if (valid_dg_target(ch, 0))
{
command_interpreter(ch, line);
}
}
}
else
{
if ((ch = get_char_by_room(room, arg1)))
{
if (valid_dg_target(ch, 0))
{
command_interpreter(ch, line);
}
}
else
wld_log(room, "wforce: no target found");
}
}
/* purge all objects an npcs in room, or specified object or mob */
WCMD(do_wpurge)
{
char arg[MAX_INPUT_LENGTH];
char_data *ch, *next_ch;
obj_data *obj, *next_obj;
one_argument(argument, arg);
if (!*arg) {
/* purge all */
for (ch = room->people; ch; ch = next_ch ) {
next_ch = ch->next_in_room;
if (IS_NPC(ch))
extract_char(ch);
}
for (obj = room->contents; obj; obj = next_obj ) {
next_obj = obj->next_content;
extract_obj(obj);
}
return;
}
if (*arg == UID_CHAR)
ch = get_char(arg);
else
ch = get_char_in_room(room, arg);
if (!ch) {
if (*arg == UID_CHAR)
obj = get_obj(arg);
else
obj = get_obj_in_room(room, arg);
if (obj) {
extract_obj(obj);
} else
wld_log(room, "wpurge: bad argument");
return;
}
if (!IS_NPC(ch)) {
wld_log(room, "wpurge: purging a PC");
return;
}
extract_char(ch);
}
/* loads a mobile or object into the room */
WCMD(do_wload)
{
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int number = 0;
char_data *mob;
obj_data *object;
char *target;
char_data *tch;
obj_data *cnt;
int pos;
target = two_arguments(argument, arg1, arg2);
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0)) {
wld_log(room, "wload: bad syntax");
return;
}
/* load mob to target room - Jamie Nelson, April 13 2004 */
if (is_abbrev(arg1, "mob")) {
room_rnum rnum;
if (!target || !*target) {
rnum = real_room(room->number);
} else {
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE) {
wld_log(room, "wload: room target vnum doesn't exist (loading mob vnum %d to room %s)", number, target);
return;
}
}
if ((mob = read_mobile(number, VIRTUAL)) == NULL) {
wld_log(room, "mload: bad mob vnum");
return;
}
char_to_room(mob, rnum);
if (SCRIPT(room)) { // it _should_ have, but it might be detached.
char buf[MAX_INPUT_LENGTH];
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(mob));
add_var(&(SCRIPT(room)->global_vars), "lastloaded", buf, 0);
}
load_mtrigger(mob);
}
else if (is_abbrev(arg1, "obj")) {
if ((object = read_object(number, VIRTUAL)) == NULL) {
wld_log(room, "wload: bad object vnum");
return;
}
/* special handling to make objects able to load on a person/in a container/worn etc. */
if (!target || !*target) {
obj_to_room(object, real_room(room->number));
if (SCRIPT(room)) { // it _should_ have, but it might be detached.
char buf[MAX_INPUT_LENGTH];
sprintf(buf, "%c%ld", UID_CHAR, GET_ID(object));
add_var(&(SCRIPT(room)->global_vars), "lastloaded", buf, 0);
}
load_otrigger(object);
return;
}
two_arguments(target, arg1, arg2); /* recycling ... */
tch = get_char_in_room(room, arg1);
if (tch) {
if (arg2 && *arg2 &&
(pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) &&
can_wear_on_pos(object, pos)) {
equip_char(tch, object, pos);
load_otrigger(object);
return;
}
obj_to_char(object, tch);
load_otrigger(object);
return;
}
cnt = get_obj_in_room(room, arg1);
if (cnt && GET_OBJ_TYPE(cnt) == ITEM_CONTAINER) {
obj_to_obj(object, cnt);
load_otrigger(object);
return;
}
/* neither char nor container found - just dump it in room */
obj_to_room(object, real_room(room->number));
load_otrigger(object);
return;
}
else
wld_log(room, "wload: bad type");
}
WCMD(do_wdamage) {
char name[MAX_INPUT_LENGTH], amount[MAX_INPUT_LENGTH];
int dam = 0;
char_data *ch;
two_arguments(argument, name, amount);
/* who cares if it's a number ? if not it'll just be 0 */
if (!*name || !*amount) {
wld_log(room, "wdamage: bad syntax");
return;
}
dam = atoi(amount);
ch = get_char_by_room(room, name);
if (!ch) {
wld_log(room, "wdamage: target not found");
return;
}
script_damage(ch, dam);
}
WCMD(do_wat) {
char location[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int vnum = 0;
room_data *r2;
half_chop(argument, location, arg2);
if (!*location || !*arg2 || !isdigit(*location)) {
wld_log(room, "wat: bad syntax");
return;
}
vnum = atoi(location);
if (NOWHERE == real_room(vnum)) {
wld_log(room, "wat: location not found");
return;
}
r2 = &world[real_room(vnum)];
wld_command_interpreter(r2, arg2);
}
const struct wld_command_info wld_cmd_info[] = {
{ "RESERVED", 0, 0 },/* this must be first -- for specprocs */
{ "wasound " , do_wasound , 0 },
{ "wdoor " , do_wdoor , 0 },
{ "wecho " , do_wecho , 0 },
{ "wechoaround ", do_wsend , SCMD_WECHOAROUND },
{ "wforce " , do_wforce , 0 },
{ "wload " , do_wload , 0 },
{ "wpurge " , do_wpurge , 0 },
{ "wrecho " , do_wrecho , 0 },
{ "wsend " , do_wsend , SCMD_WSEND },
{ "wteleport " , do_wteleport , 0 },
{ "wzoneecho " , do_wzoneecho , 0 },
{ "wdamage " , do_wdamage, 0 },
{ "wat " , do_wat, 0 },
{ "\n", 0, 0 } /* this must be last */
};
/*
* This is the command interpreter used by rooms, called by script_driver.
*/
void wld_command_interpreter(room_data *room, char *argument)
{
int cmd, length;
char *line, arg[MAX_INPUT_LENGTH];
skip_spaces(&argument);
/* just drop to next line for hitting CR */
if (!*argument)
return;
line = any_one_arg(argument, arg);
/* find the command */
for (length = strlen(arg), cmd = 0;
*wld_cmd_info[cmd].command != '\n'; cmd++)
if (!strncmp(wld_cmd_info[cmd].command, arg, length))
break;
if (*wld_cmd_info[cmd].command == '\n')
wld_log(room, "Unknown world cmd: '%s'", argument);
else
((*wld_cmd_info[cmd].command_pointer)
(room, line, cmd, wld_cmd_info[cmd].subcmd));
}

1012
src/fight.c Normal file

File diff suppressed because it is too large Load diff

429
src/genmob.c Normal file
View file

@ -0,0 +1,429 @@
/************************************************************************
* Generic OLC Library - Mobiles / genmob.c v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "shop.h"
#include "handler.h"
#include "genolc.h"
#include "genmob.h"
#include "genzon.h"
#include "dg_olc.h"
int add_mobile(struct char_data *mob, mob_vnum vnum)
{
int rnum, i, found = FALSE, shop, cmd_no;
zone_rnum zone;
struct char_data *live_mob;
if ((rnum = real_mobile(vnum)) != NOBODY) {
/* Copy over the mobile and free() the old strings. */
copy_mobile(&mob_proto[rnum], mob);
/* Now re-point all existing mobile strings to here. */
for (live_mob = character_list; live_mob; live_mob = live_mob->next)
if (rnum == live_mob->nr)
update_mobile_strings(live_mob, &mob_proto[rnum]);
add_to_save_list(zone_table[real_zone_by_thing(vnum)].number, SL_MOB);
log("GenOLC: add_mobile: Updated existing mobile #%d.", vnum);
return rnum;
}
RECREATE(mob_proto, struct char_data, top_of_mobt + 2);
RECREATE(mob_index, struct index_data, top_of_mobt + 2);
top_of_mobt++;
for (i = top_of_mobt; i > 0; i--) {
if (vnum > mob_index[i - 1].vnum) {
mob_proto[i] = *mob;
mob_proto[i].nr = i;
copy_mobile_strings(mob_proto + i, mob);
mob_index[i].vnum = vnum;
mob_index[i].number = 0;
mob_index[i].func = 0;
found = i;
break;
}
mob_index[i] = mob_index[i - 1];
mob_proto[i] = mob_proto[i - 1];
mob_proto[i].nr++;
}
if (!found) {
mob_proto[0] = *mob;
mob_proto[0].nr = 0;
copy_mobile_strings(&mob_proto[0], mob);
mob_index[0].vnum = vnum;
mob_index[0].number = 0;
mob_index[0].func = 0;
}
log("GenOLC: add_mobile: Added mobile %d at index #%d.", vnum, found);
#if CONFIG_GENOLC_MOBPROG
GET_MPROG(OLC_MOB(d)) = OLC_MPROGL(d);
GET_MPROG_TYPE(OLC_MOB(d)) = (OLC_MPROGL(d) ? OLC_MPROGL(d)->type : 0);
while (OLC_MPROGL(d)) {
GET_MPROG_TYPE(OLC_MOB(d)) |= OLC_MPROGL(d)->type;
OLC_MPROGL(d) = OLC_MPROGL(d)->next;
}
#endif
/*
* Update live mobile rnums.
*/
for (live_mob = character_list; live_mob; live_mob = live_mob->next)
GET_MOB_RNUM(live_mob) += (GET_MOB_RNUM(live_mob) >= found);
/*
* Update zone table.
*/
for (zone = 0; zone <= top_of_zone_table; zone++)
for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++)
if (ZCMD(zone, cmd_no).command == 'M')
ZCMD(zone, cmd_no).arg1 += (ZCMD(zone, cmd_no).arg1 >= found);
/*
* Update shop keepers.
*/
if (shop_index)
for (shop = 0; shop <= top_shop - top_shop_offset; shop++)
SHOP_KEEPER(shop) += (SHOP_KEEPER(shop) >= found);
add_to_save_list(zone_table[real_zone_by_thing(vnum)].number, SL_MOB);
return found;
}
int copy_mobile(struct char_data *to, struct char_data *from)
{
free_mobile_strings(to);
*to = *from;
check_mobile_strings(from);
copy_mobile_strings(to, from);
return TRUE;
}
void extract_mobile_all(mob_vnum vnum)
{
struct char_data *next, *ch;
for (ch = character_list; ch; ch = next) {
next = ch->next;
if (GET_MOB_VNUM(ch) == vnum)
extract_char(ch);
}
}
int delete_mobile(mob_rnum refpt)
{
struct char_data *live_mob;
int counter, cmd_no;
mob_vnum vnum;
zone_rnum zone;
#if CIRCLE_UNSIGNED_INDEX
if (refpt == NOBODY || refpt > top_of_mobt) {
#else
if (refpt < 0 || refpt > top_of_mobt) {
#endif
log("SYSERR: GenOLC: delete_mobile: Invalid rnum %d.", refpt);
return NOBODY;
}
vnum = mob_index[refpt].vnum;
extract_mobile_all(vnum);
for (counter = refpt; counter < top_of_mobt; counter++) {
mob_index[counter] = mob_index[counter + 1];
mob_proto[counter] = mob_proto[counter + 1];
mob_proto[counter].nr--;
}
top_of_mobt--;
RECREATE(mob_index, struct index_data, top_of_mobt + 1);
RECREATE(mob_proto, struct char_data, top_of_mobt + 1);
/*
* Update live mobile rnums.
*/
for (live_mob = character_list; live_mob; live_mob = live_mob->next)
GET_MOB_RNUM(live_mob) -= (GET_MOB_RNUM(live_mob) >= refpt);
/*
* Update zone table.
*/
for (zone = 0; zone <= top_of_zone_table; zone++)
for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++)
if (ZCMD(zone, cmd_no).command == 'M' && ZCMD(zone, cmd_no).arg1 == refpt)
delete_command(&zone_table[zone], cmd_no);
/*
* Update shop keepers.
*/
if (shop_index)
for (counter = 0; counter <= top_shop - top_shop_offset; counter++)
SHOP_KEEPER(counter) -= (SHOP_KEEPER(counter) >= refpt);
save_mobiles(real_zone_by_thing(vnum));
return refpt;
}
int copy_mobile_strings(struct char_data *t, struct char_data *f)
{
if (f->player.name)
t->player.name = strdup(f->player.name);
if (f->player.title)
t->player.title = strdup(f->player.title);
if (f->player.short_descr)
t->player.short_descr = strdup(f->player.short_descr);
if (f->player.long_descr)
t->player.long_descr = strdup(f->player.long_descr);
if (f->player.description)
t->player.description = strdup(f->player.description);
return TRUE;
}
int update_mobile_strings(struct char_data *t, struct char_data *f)
{
if (f->player.name)
t->player.name = f->player.name;
if (f->player.title)
t->player.title = f->player.title;
if (f->player.short_descr)
t->player.short_descr = f->player.short_descr;
if (f->player.long_descr)
t->player.long_descr = f->player.long_descr;
if (f->player.description)
t->player.description = f->player.description;
return TRUE;
}
int free_mobile_strings(struct char_data *mob)
{
if (mob->player.name)
free(mob->player.name);
if (mob->player.title)
free(mob->player.title);
if (mob->player.short_descr)
free(mob->player.short_descr);
if (mob->player.long_descr)
free(mob->player.long_descr);
if (mob->player.description)
free(mob->player.description);
return TRUE;
}
/*
* Free a mobile structure that has been edited.
* Take care of existing mobiles and their mob_proto!
*/
int free_mobile(struct char_data *mob)
{
mob_rnum i;
if (mob == NULL)
return FALSE;
/*
* Non-prototyped mobile. Also known as new mobiles.
*/
if ((i = GET_MOB_RNUM(mob)) == NOBODY) {
free_mobile_strings(mob);
/* free script proto list */
free_proto_script(mob, MOB_TRIGGER);
} else { /* Prototyped mobile. */
if (mob->player.name && mob->player.name != mob_proto[i].player.name)
free(mob->player.name);
if (mob->player.title && mob->player.title != mob_proto[i].player.title)
free(mob->player.title);
if (mob->player.short_descr && mob->player.short_descr != mob_proto[i].player.short_descr)
free(mob->player.short_descr);
if (mob->player.long_descr && mob->player.long_descr != mob_proto[i].player.long_descr)
free(mob->player.long_descr);
if (mob->player.description && mob->player.description != mob_proto[i].player.description)
free(mob->player.description);
/* free script proto list if it's not the prototype */
if (mob->proto_script && mob->proto_script != mob_proto[i].proto_script)
free_proto_script(mob, MOB_TRIGGER);
}
while (mob->affected)
affect_remove(mob, mob->affected);
/* free any assigned scripts */
if (SCRIPT(mob))
extract_script(mob, MOB_TRIGGER);
free(mob);
return TRUE;
}
int save_mobiles(zone_rnum rznum)
{
zone_vnum vznum;
FILE *mobfd;
room_vnum i;
mob_rnum rmob;
int written;
char mobfname[64], usedfname[64];
#if CIRCLE_UNSIGNED_INDEX
if (rznum == NOWHERE || rznum > top_of_zone_table) {
#else
if (rznum < 0 || rznum > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_mobiles: Invalid real zone number %d. (0-%d)", rznum, top_of_zone_table);
return FALSE;
}
vznum = zone_table[rznum].number;
snprintf(mobfname, sizeof(mobfname), "%s%d.new", MOB_PREFIX, vznum);
if ((mobfd = fopen(mobfname, "w")) == NULL) {
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: Cannot open mob file for writing.");
return FALSE;
}
for (i = genolc_zone_bottom(rznum); i <= zone_table[rznum].top; i++) {
if ((rmob = real_mobile(i)) == NOBODY)
continue;
check_mobile_strings(&mob_proto[rmob]);
if (write_mobile_record(i, &mob_proto[rmob], mobfd) < 0)
log("SYSERR: GenOLC: Error writing mobile #%d.", i);
}
fputs("$\n", mobfd);
written = ftell(mobfd);
fclose(mobfd);
snprintf(usedfname, sizeof(usedfname), "%s%d.mob", MOB_PREFIX, vznum);
remove(usedfname);
rename(mobfname, usedfname);
if (in_save_list(vznum, SL_MOB))
remove_from_save_list(vznum, SL_MOB);
log("GenOLC: '%s' saved, %d bytes written.", usedfname, written);
return written;
}
#if CONFIG_GENOLC_MOBPROG
int write_mobile_mobprog(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
char wmmarg[MAX_STRING_LENGTH], wmmcom[MAX_STRING_LENGTH];
MPROG_DATA *mob_prog;
for (mob_prog = GET_MPROG(mob); mob_prog; mob_prog = mob_prog->next) {
wmmarg[MAX_STRING_LENGTH - 1] = '\0';
wmmcom[MAX_STRING_LENGTH - 1] = '\0';
strip_cr(strncpy(wmmarg, mob_prog->arglist, MAX_STRING_LENGTH - 1));
strip_cr(strncpy(wmmcom, mob_prog->comlist, MAX_STRING_LENGTH - 1));
fprintf(fd, "%s %s~\n"
"%s%c\n",
medit_get_mprog_type(mob_prog), wmmarg,
wmmcom, STRING_TERMINATOR
);
if (mob_prog->next == NULL)
fputs("|\n", fd);
}
return TRUE;
}
#endif
int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
if (GET_ATTACK(mob) != 0)
fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob));
if (GET_STR(mob) != 11)
fprintf(fd, "Str: %d\n", GET_STR(mob));
if (GET_ADD(mob) != 0)
fprintf(fd, "StrAdd: %d\n", GET_ADD(mob));
if (GET_DEX(mob) != 11)
fprintf(fd, "Dex: %d\n", GET_DEX(mob));
if (GET_INT(mob) != 11)
fprintf(fd, "Int: %d\n", GET_INT(mob));
if (GET_WIS(mob) != 11)
fprintf(fd, "Wis: %d\n", GET_WIS(mob));
fputs("E\n", fd);
return TRUE;
}
int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd)
{
char bit1[64];
char bit2[64];
char ldesc[MAX_STRING_LENGTH];
char ddesc[MAX_STRING_LENGTH];
ldesc[MAX_STRING_LENGTH - 1] = '\0';
ddesc[MAX_STRING_LENGTH - 1] = '\0';
strip_cr(strncpy(ldesc, GET_LDESC(mob), MAX_STRING_LENGTH - 1));
strip_cr(strncpy(ddesc, GET_DDESC(mob), MAX_STRING_LENGTH - 1));
fprintf(fd, "#%d\n"
"%s%c\n"
"%s%c\n"
"%s%c\n"
"%s%c\n",
mvnum,
GET_ALIAS(mob), STRING_TERMINATOR,
GET_SDESC(mob), STRING_TERMINATOR,
ldesc, STRING_TERMINATOR,
ddesc, STRING_TERMINATOR
);
sprintascii(bit1, MOB_FLAGS(mob));
sprintascii(bit2, AFF_FLAGS(mob));
fprintf(fd, "%s %s %d E\n"
"%d %d %d %dd%d+%d %dd%d+%d\n",
bit1, bit2, GET_ALIGNMENT(mob),
GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob),
GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob),
GET_DAMROLL(mob)
);
fprintf(fd, "%d %d\n"
"%d %d %d\n",
GET_GOLD(mob), GET_EXP(mob),
GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob)
);
if (write_mobile_espec(mvnum, mob, fd) < 0)
log("SYSERR: GenOLC: Error writing E-specs for mobile #%d.", mvnum);
script_save_to_disk(fd, mob, MOB_TRIGGER);
#if CONFIG_GENOLC_MOBPROG
if (write_mobile_mobprog(mvnum, mob, fd) < 0)
log("SYSERR: GenOLC: Error writing MobProgs for mobile #%d.", mvnum);
#endif
return TRUE;
}
void check_mobile_strings(struct char_data *mob)
{
mob_vnum mvnum = mob_index[mob->nr].vnum;
check_mobile_string(mvnum, &GET_LDESC(mob), "long description");
check_mobile_string(mvnum, &GET_DDESC(mob), "detailed description");
check_mobile_string(mvnum, &GET_ALIAS(mob), "alias list");
check_mobile_string(mvnum, &GET_SDESC(mob), "short description");
}
void check_mobile_string(mob_vnum i, char **string, const char *desc)
{
if (*string == NULL || **string == '\0') {
char smbuf[128];
sprintf(smbuf, "GenOLC: Mob #%d has an invalid %s.", i, desc);
mudlog(BRF, LVL_GOD, TRUE, smbuf);
if (*string)
free(*string);
*string = strdup("An undefined string.");
}
}

33
src/genmob.h Normal file
View file

@ -0,0 +1,33 @@
/************************************************************************
* Generic OLC Library - Mobiles / genmob.h v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
int delete_mobile(mob_rnum);
int copy_mobile(struct char_data *to, struct char_data *from);
int add_mobile(struct char_data *, mob_vnum);
int copy_mob_strings(struct char_data *to, struct char_data *from);
int free_mob_strings(struct char_data *);
int free_mobile(struct char_data *mob);
int save_mobiles(zone_rnum rznum);
void extract_mobile_all(mob_vnum vnum);
int update_mobile_strings(struct char_data *t, struct char_data *f);
void check_mobile_strings(struct char_data *mob);
void check_mobile_string(mob_vnum i, char **string, const char *desc);
int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd);
int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd);
int free_mobile_strings(struct char_data *mob);
int copy_mobile_strings(struct char_data *t, struct char_data *f);
#if CONFIG_GENOLC_MOBPROG
int write_mobile_mobprog(mob_vnum mvnum, struct char_data *mob, FILE *fd);
#endif
/* Handy macros. */
#define GET_NDD(mob) ((mob)->mob_specials.damnodice)
#define GET_SDD(mob) ((mob)->mob_specials.damsizedice)
#define GET_ALIAS(mob) ((mob)->player.name)
#define GET_SDESC(mob) ((mob)->player.short_descr)
#define GET_LDESC(mob) ((mob)->player.long_descr)
#define GET_DDESC(mob) ((mob)->player.description)
#define GET_ATTACK(mob) ((mob)->mob_specials.attack_type)

507
src/genobj.c Normal file
View file

@ -0,0 +1,507 @@
/************************************************************************
* Generic OLC Library - Objects / genobj.c v1.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "boards.h"
#include "shop.h"
#include "genolc.h"
#include "genobj.h"
#include "genzon.h"
#include "dg_olc.h"
#include "handler.h"
extern struct board_info_type board_info[];
obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum)
{
int found = NOTHING;
zone_rnum rznum = real_zone_by_thing(ovnum);
/*
* Write object to internal tables.
*/
if ((newobj->item_number = real_object(ovnum)) != NOTHING) {
copy_object(&obj_proto[newobj->item_number], newobj);
update_objects(&obj_proto[newobj->item_number]);
add_to_save_list(zone_table[rznum].number, SL_OBJ);
return newobj->item_number;
}
found = insert_object(newobj, ovnum);
adjust_objects(found);
add_to_save_list(zone_table[rznum].number, SL_OBJ);
return found;
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
/*
* Fix all existing objects to have these values.
* We need to run through each 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 replace it
* with the new one.
*/
int update_objects(struct obj_data *refobj)
{
struct obj_data *obj, swap;
int count = 0;
for (obj = object_list; obj; obj = obj->next) {
if (obj->item_number != refobj->item_number)
continue;
count++;
/* Update the existing object but save a copy for private information. */
swap = *obj;
*obj = *refobj;
/* Copy game-time dependent variables over. */
IN_ROOM(obj) = swap.in_room;
obj->carried_by = swap.carried_by;
obj->worn_by = swap.worn_by;
obj->worn_on = swap.worn_on;
obj->in_obj = swap.in_obj;
obj->contains = swap.contains;
obj->next_content = swap.next_content;
obj->next = swap.next;
}
return count;
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
/*
* Adjust the internal values of other objects as if something was inserted at the given array index.
* Might also be useful to make 'holes' in the array for some reason.
*/
obj_rnum adjust_objects(obj_rnum refpt)
{
int shop, i, zone, cmd_no;
struct obj_data *obj;
#if CIRCLE_UNSIGNED_INDEX
if (refpt == NOTHING || refpt > top_of_objt)
#else
if (refpt < 0 || refpt > top_of_objt)
#endif
return NOTHING;
/*
* Renumber live objects.
*/
for (obj = object_list; obj; obj = obj->next)
GET_OBJ_RNUM(obj) += (GET_OBJ_RNUM(obj) >= refpt);
/*
* Renumber zone table.
*/
for (zone = 0; zone <= top_of_zone_table; zone++) {
for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) {
switch (ZCMD(zone, cmd_no).command) {
case 'P':
ZCMD(zone, cmd_no).arg3 += (ZCMD(zone, cmd_no).arg3 >= refpt);
/*
* No break here - drop into next case.
*/
case 'O':
case 'G':
case 'E':
ZCMD(zone, cmd_no).arg1 += (ZCMD(zone, cmd_no).arg1 >= refpt);
break;
case 'R':
ZCMD(zone, cmd_no).arg2 += (ZCMD(zone, cmd_no).arg2 >= refpt);
break;
}
}
}
/*
* Renumber notice boards.
*/
for (i = 0; i < NUM_OF_BOARDS; i++)
BOARD_RNUM(i) += (BOARD_RNUM(i) >= refpt);
/*
* Renumber shop produce.
*/
for (shop = 0; shop <= top_shop - top_shop_offset; shop++)
for (i = 0; SHOP_PRODUCT(shop, i) != NOTHING; i++)
SHOP_PRODUCT(shop, i) += (SHOP_PRODUCT(shop, i) >= refpt);
return refpt;
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
/*
* Function handle the insertion of an object within the prototype framework. Note that this does not adjust internal values
* of other objects, use add_object() for that.
*/
obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum)
{
obj_rnum i;
top_of_objt++;
RECREATE(obj_index, struct index_data, top_of_objt + 1);
RECREATE(obj_proto, struct obj_data, top_of_objt + 1);
/*
* Start counting through both tables.
*/
for (i = top_of_objt; i > 0; i--) {
/*
* Check if current virtual is bigger than our virtual number.
*/
if (ovnum > obj_index[i - 1].vnum)
return index_object(obj, ovnum, i);
/* Copy over the object that should be here. */
obj_index[i] = obj_index[i - 1];
obj_proto[i] = obj_proto[i - 1];
obj_proto[i].item_number = i;
}
/* Not found, place at 0. */
return index_object(obj, ovnum, 0);
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum)
{
#if CIRCLE_UNSIGNED_INDEX
if (obj == NULL || ornum == NOTHING || ornum > top_of_objt)
#else
if (obj == NULL || ovnum < 0 || ornum < 0 || ornum > top_of_objt)
#endif
return NOWHERE;
obj->item_number = ornum;
obj_index[ornum].vnum = ovnum;
obj_index[ornum].number = 0;
obj_index[ornum].func = NULL;
copy_object_preserve(&obj_proto[ornum], obj);
obj_proto[ornum].in_room = NOWHERE;
return ornum;
}
/* ------------------------------------------------------------------------------------------------------------------------------ */
int save_objects(zone_rnum zone_num)
{
char fname[128], buf[MAX_STRING_LENGTH], bit1[64], bit2[64];
int counter, counter2, realcounter;
FILE *fp;
struct obj_data *obj;
struct extra_descr_data *ex_desc;
#if CIRCLE_UNSIGNED_INDEX
if (zone_num == NOWHERE || zone_num > top_of_zone_table) {
#else
if (zone_num < 0 || zone_num > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_objects: Invalid real zone number %d. (0-%d)", zone_num, top_of_zone_table);
return FALSE;
}
snprintf(fname, sizeof(fname), "%s/%d.new", OBJ_PREFIX, zone_table[zone_num].number);
if (!(fp = fopen(fname, "w+"))) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: Cannot open objects file %s!", fname);
return FALSE;
}
/*
* Start running through all objects in this zone.
*/
for (counter = genolc_zone_bottom(zone_num); counter <= zone_table[zone_num].top; counter++) {
if ((realcounter = real_object(counter)) != NOTHING) {
if ((obj = &obj_proto[realcounter])->action_description) {
strncpy(buf, obj->action_description, sizeof(buf) - 1);
strip_cr(buf);
} else
*buf = '\0';
fprintf(fp,
"#%d\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n",
GET_OBJ_VNUM(obj),
(obj->name && *obj->name) ? obj->name : "undefined",
(obj->short_description && *obj->short_description) ? obj->short_description : "undefined",
(obj->description && *obj->description) ? obj->description : "undefined",
buf);
sprintascii(buf, GET_OBJ_EXTRA(obj));
sprintascii(bit1, GET_OBJ_WEAR(obj));
sprintascii(bit2, GET_OBJ_PERM(obj));
fprintf(fp,
"%d %s %s %s\n"
"%d %d %d %d\n"
"%d %d %d %d\n",
GET_OBJ_TYPE(obj), buf, bit1, bit2,
GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 3),
GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj), GET_OBJ_LEVEL(obj)
);
/*
* Do we have script(s) attached ?
*/
script_save_to_disk(fp, obj, OBJ_TRIGGER);
/*
* Do we have extra descriptions?
*/
if (obj->ex_description) { /* Yes, save them too. */
for (ex_desc = obj->ex_description; ex_desc; ex_desc = ex_desc->next) {
/*
* Sanity check to prevent nasty protection faults.
*/
if (!ex_desc->keyword || !ex_desc->description || !*ex_desc->keyword || !*ex_desc->description) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: oedit_save_to_disk: Corrupt ex_desc!");
continue;
}
strncpy(buf, ex_desc->description, sizeof(buf) - 1);
strip_cr(buf);
fprintf(fp, "E\n"
"%s~\n"
"%s~\n", ex_desc->keyword, buf);
}
}
/*
* Do we have affects?
*/
for (counter2 = 0; counter2 < MAX_OBJ_AFFECT; counter2++)
if (obj->affected[counter2].modifier)
fprintf(fp, "A\n"
"%d %d\n", obj->affected[counter2].location,
obj->affected[counter2].modifier);
}
}
/*
* Write the final line, close the file.
*/
fprintf(fp, "$~\n");
fclose(fp);
snprintf(buf, sizeof(buf), "%s/%d.obj", OBJ_PREFIX, zone_table[zone_num].number);
remove(buf);
rename(fname, buf);
if (in_save_list(zone_table[zone_num].number, SL_OBJ))
remove_from_save_list(zone_table[zone_num].number, SL_OBJ);
return TRUE;
}
/*
* Free all, unconditionally.
*/
void free_object_strings(struct obj_data *obj)
{
if (obj->name)
free(obj->name);
if (obj->description)
free(obj->description);
if (obj->short_description)
free(obj->short_description);
if (obj->action_description)
free(obj->action_description);
if (obj->ex_description)
free_ex_descriptions(obj->ex_description);
}
/*
* For object instances that are not the prototype.
*/
void free_object_strings_proto(struct obj_data *obj)
{
int robj_num = GET_OBJ_RNUM(obj);
if (obj->name && obj->name != obj_proto[robj_num].name)
free(obj->name);
if (obj->description && obj->description != obj_proto[robj_num].description)
free(obj->description);
if (obj->short_description && obj->short_description != obj_proto[robj_num].short_description)
free(obj->short_description);
if (obj->action_description && obj->action_description != obj_proto[robj_num].action_description)
free(obj->action_description);
if (obj->ex_description) {
struct extra_descr_data *thised, *plist, *next_one; /* O(horrible) */
int ok_key, ok_desc, ok_item;
for (thised = obj->ex_description; thised; thised = next_one) {
next_one = thised->next;
for (ok_item = ok_key = ok_desc = 1, plist = obj_proto[robj_num].ex_description; plist; plist = plist->next) {
if (plist->keyword == thised->keyword)
ok_key = 0;
if (plist->description == thised->description)
ok_desc = 0;
if (plist == thised)
ok_item = 0;
}
if (thised->keyword && ok_key)
free(thised->keyword);
if (thised->description && ok_desc)
free(thised->description);
if (ok_item)
free(thised);
}
}
}
void copy_object_strings(struct obj_data *to, struct obj_data *from)
{
to->name = from->name ? strdup(from->name) : NULL;
to->description = from->description ? strdup(from->description) : NULL;
to->short_description = from->short_description ? strdup(from->short_description) : NULL;
to->action_description = from->action_description ? strdup(from->action_description) : NULL;
if (from->ex_description)
copy_ex_descriptions(&to->ex_description, from->ex_description);
else
to->ex_description = NULL;
}
int copy_object(struct obj_data *to, struct obj_data *from)
{
free_object_strings(to);
return copy_object_main(to, from, TRUE);
}
int copy_object_preserve(struct obj_data *to, struct obj_data *from)
{
return copy_object_main(to, from, FALSE);
}
int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object)
{
*to = *from;
copy_object_strings(to, from);
return TRUE;
}
int delete_object(obj_rnum rnum)
{
obj_rnum i;
struct obj_data *obj, *tmp;
int shop, j;
if (rnum == NOWHERE || rnum > top_of_objt)
return FALSE;
obj = &obj_proto[rnum];
zone_rnum zrnum = real_zone_by_thing(GET_OBJ_VNUM(obj));
/* This is something you might want to read about in the logs. */
log("GenOLC: delete_object: Deleting object #%d (%s).", GET_OBJ_VNUM(obj), obj->short_description);
for (tmp = object_list; tmp; tmp = tmp->next) {
if (tmp->item_number != obj->item_number)
continue;
// extract_obj() will just axe contents.
if (tmp->contains) {
struct obj_data *this_content, *next_content;
for (this_content = tmp->contains; this_content; this_content = next_content) {
next_content = this_content->next_content;
if (IN_ROOM(tmp)) {
// transfer stuff from object to room
obj_from_obj(this_content);
obj_to_room(this_content, IN_ROOM(tmp));
} else if (tmp->worn_by || tmp->carried_by) {
// transfer stuff from object to person inventory
obj_from_char(this_content);
obj_to_char(this_content, tmp->carried_by);
} else if (tmp->in_obj) {
// transfer stuff from object to containing object
obj_from_obj(this_content);
obj_to_obj(this_content, tmp->in_obj);
}
}
}
// remove from object_list, etc. - handles weightchanges, and similar.
extract_obj(tmp);
}
// make sure all are removed.
assert(obj_index[rnum].number == 0);
// adjust rnums of all other objects.
for (tmp = object_list; tmp; tmp = tmp->next) {
GET_OBJ_RNUM(tmp) -= (GET_OBJ_RNUM(tmp) > rnum);
}
for (i = rnum; i < top_of_objt; i++) {
obj_index[i] = obj_index[i + 1];
obj_proto[i] = obj_proto[i + 1];
obj_proto[i].item_number = i;
}
top_of_objt--;
RECREATE(obj_index, struct index_data, top_of_objt + 1);
RECREATE(obj_proto, struct obj_data, top_of_objt + 1);
/*
* Renumber notice boards.
*/
for (j = 0; j < NUM_OF_BOARDS; j++)
BOARD_RNUM(j) -= (BOARD_RNUM(j) > rnum);
/*
* Renumber shop produce;
*/
for (shop = 0; shop <= top_shop - top_shop_offset; shop++)
for (j = 0; SHOP_PRODUCT(shop, j) != NOTHING; j++)
SHOP_PRODUCT(shop, j) -= (SHOP_PRODUCT(shop, j) > rnum);
/*
* Renumber zone table.
*/
int zone, cmd_no;
for (zone = 0; zone <= top_of_zone_table; zone++) {
for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) {
switch (ZCMD(zone, cmd_no).command) {
case 'P':
if (ZCMD(zone, cmd_no).arg3 == rnum) {
delete_command(&zone_table[zone], cmd_no);
} else
ZCMD(zone, cmd_no).arg3 -= (ZCMD(zone, cmd_no).arg3 > rnum);
break;
case 'O':
case 'G':
case 'E':
if (ZCMD(zone, cmd_no).arg1 == rnum) {
delete_command(&zone_table[zone], cmd_no);
} else
ZCMD(zone, cmd_no).arg1 -= (ZCMD(zone, cmd_no).arg1 > rnum);
break;
case 'R':
if (ZCMD(zone, cmd_no).arg2 == rnum) {
delete_command(&zone_table[zone], cmd_no);
} else
ZCMD(zone, cmd_no).arg2 -= (ZCMD(zone, cmd_no).arg2 > rnum);
break;
}
}
}
save_objects(zrnum);
return TRUE;
}

21
src/genobj.h Normal file
View file

@ -0,0 +1,21 @@
/************************************************************************
* Generic OLC Library - Objects / genobj.h v1.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
void copy_object_strings(struct obj_data *to, struct obj_data *from);
void free_object_strings(struct obj_data *obj);
void free_object_strings_proto(struct obj_data *obj);
int copy_object(struct obj_data *to, struct obj_data *from);
int copy_object_preserve(struct obj_data *to, struct obj_data *from);
int save_objects(zone_rnum vznum);
obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum);
obj_rnum adjust_objects(obj_rnum refpt);
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);
int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object);
int delete_object(obj_rnum);

1013
src/genolc.c Normal file

File diff suppressed because it is too large Load diff

64
src/genolc.h Normal file
View file

@ -0,0 +1,64 @@
/************************************************************************
* Generic OLC Library - General / genolc.h v1.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#if !defined(_CIRCLEMUD) || !defined(CIRCLEMUD_VERSION)
# error "This version of GenOLC only supports CircleMUD 3.0 bpl15 or later."
#else
# if _CIRCLEMUD < CIRCLEMUD_VERSION(3,0,15)
# error "This version of GenOLC only supports CircleMUD 3.0 bpl15 or later."
# endif
#endif
#define STRING_TERMINATOR '~'
#define CONFIG_GENOLC_MOBPROG 0
/* from modify.c */
void smash_tilde(char *str);
int genolc_checkstring(struct descriptor_data *d, char *arg);
int remove_from_save_list(zone_vnum, int type);
int add_to_save_list(zone_vnum, int type);
int in_save_list(zone_vnum, int type);
void strip_cr(char *);
void do_show_save_list(struct char_data *);
int save_all(void);
char *str_udup(const char *);
void copy_ex_descriptions(struct extra_descr_data **to, struct extra_descr_data *from);
void free_ex_descriptions(struct extra_descr_data *head);
int sprintascii(char *out, bitvector_t bits);
struct save_list_data {
int zone;
int type;
struct save_list_data *next;
};
extern struct save_list_data *save_list;
extern int top_shop_offset;
/* save_list_data.type */
#define SL_MOB 0
#define SL_OBJ 1
#define SL_SHP 2
#define SL_WLD 3
#define SL_ZON 4
#define SL_CFG 5
#define SL_ACT 6
#define SL_MAX 6
#ifndef STOCK_CIRCLE
#define SL_ACTION 100 /* must be above MAX */
#endif
#define ZCMD(zon, cmds) zone_table[(zon)].cmd[(cmds)]
#define LIMIT(var, low, high) MIN(high, MAX(var, low))
room_vnum genolc_zone_bottom(zone_rnum rznum);
room_vnum genolc_zonep_bottom(struct zone_data *zone);

535
src/genshp.c Normal file
View file

@ -0,0 +1,535 @@
/************************************************************************
* Generic OLC Library - Shops / genshp.c v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "shop.h"
#include "genolc.h"
#include "genshp.h"
#include "genzon.h"
/*
* NOTE (gg): Didn't modify sedit much. Don't consider it as 'recent'
* as the other editors with regard to updates or style.
*/
/*-------------------------------------------------------------------*/
void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings)
{
/*
* Copy basic information over.
*/
S_NUM(tshop) = S_NUM(fshop);
S_KEEPER(tshop) = S_KEEPER(fshop);
S_OPEN1(tshop) = S_OPEN1(fshop);
S_CLOSE1(tshop) = S_CLOSE1(fshop);
S_OPEN2(tshop) = S_OPEN2(fshop);
S_CLOSE2(tshop) = S_CLOSE2(fshop);
S_BANK(tshop) = S_BANK(fshop);
S_BROKE_TEMPER(tshop) = S_BROKE_TEMPER(fshop);
S_BITVECTOR(tshop) = S_BITVECTOR(fshop);
S_NOTRADE(tshop) = S_NOTRADE(fshop);
S_SORT(tshop) = S_SORT(fshop);
S_BUYPROFIT(tshop) = S_BUYPROFIT(fshop);
S_SELLPROFIT(tshop) = S_SELLPROFIT(fshop);
S_FUNC(tshop) = S_FUNC(fshop);
/*
* Copy lists over.
*/
copy_list(&(S_ROOMS(tshop)), S_ROOMS(fshop));
copy_list(&(S_PRODUCTS(tshop)), S_PRODUCTS(fshop));
copy_type_list(&(tshop->type), fshop->type);
/*
* Copy notification strings over.
*/
if (free_old_strings)
free_shop_strings(tshop);
S_NOITEM1(tshop) = str_udup(S_NOITEM1(fshop));
S_NOITEM2(tshop) = str_udup(S_NOITEM2(fshop));
S_NOCASH1(tshop) = str_udup(S_NOCASH1(fshop));
S_NOCASH2(tshop) = str_udup(S_NOCASH2(fshop));
S_NOBUY(tshop) = str_udup(S_NOBUY(fshop));
S_BUY(tshop) = str_udup(S_BUY(fshop));
S_SELL(tshop) = str_udup(S_SELL(fshop));
}
/*-------------------------------------------------------------------*/
/*
* Copy a 'NOTHING' terminated integer array list.
*/
void copy_list(IDXTYPE **tlist, IDXTYPE *flist)
{
int num_items, i;
if (*tlist)
free(*tlist);
/*
* Count number of entries.
*/
for (i = 0; flist[i] != NOTHING; i++);
num_items = i + 1;
/*
* Make space for entries.
*/
CREATE(*tlist, IDXTYPE, num_items);
/*
* Copy entries over.
*/
for (i = 0; i < num_items; i++)
(*tlist)[i] = flist[i];
}
/*-------------------------------------------------------------------*/
/*
* Copy a -1 terminated (in the type field) shop_buy_data
* array list.
*/
void copy_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist)
{
int num_items, i;
if (*tlist)
free_type_list(tlist);
/*
* Count number of entries.
*/
for (i = 0; BUY_TYPE(flist[i]) != NOTHING; i++);
num_items = i + 1;
/*
* Make space for entries.
*/
CREATE(*tlist, struct shop_buy_data, num_items);
/*
* Copy entries over.
*/
for (i = 0; i < num_items; i++) {
(*tlist)[i].type = flist[i].type;
if (BUY_WORD(flist[i]))
BUY_WORD((*tlist)[i]) = strdup(BUY_WORD(flist[i]));
}
}
/*-------------------------------------------------------------------*/
void remove_from_type_list(struct shop_buy_data **list, int num)
{
int i, num_items;
struct shop_buy_data *nlist;
/*
* Count number of entries.
*/
for (i = 0; (*list)[i].type != NOTHING; i++);
if (num < 0 || num >= i)
return;
num_items = i;
CREATE(nlist, struct shop_buy_data, num_items);
for (i = 0; i < num_items; i++)
nlist[i] = (i < num) ? (*list)[i] : (*list)[i + 1];
free(BUY_WORD((*list)[num]));
free(*list);
*list = nlist;
}
/*-------------------------------------------------------------------*/
void add_to_type_list(struct shop_buy_data **list, struct shop_buy_data *newl)
{
int i, num_items;
struct shop_buy_data *nlist;
/*
* Count number of entries.
*/
for (i = 0; (*list)[i].type != NOTHING; i++);
num_items = i;
/*
* Make a new list and slot in the new entry.
*/
CREATE(nlist, struct shop_buy_data, num_items + 2);
for (i = 0; i < num_items; i++)
nlist[i] = (*list)[i];
nlist[num_items] = *newl;
nlist[num_items + 1].type = NOTHING;
/*
* Out with the old, in with the new.
*/
free(*list);
*list = nlist;
}
/*-------------------------------------------------------------------*/
void add_to_int_list(IDXTYPE **list, IDXTYPE newi)
{
IDXTYPE i, num_items, *nlist;
/*
* Count number of entries.
*/
for (i = 0; (*list)[i] != NOTHING; i++);
num_items = i;
/*
* Make a new list and slot in the new entry.
*/
CREATE(nlist, IDXTYPE, num_items + 2);
for (i = 0; i < num_items; i++)
nlist[i] = (*list)[i];
nlist[num_items] = newi;
nlist[num_items + 1] = NOTHING;
/*
* Out with the old, in with the new.
*/
free(*list);
*list = nlist;
}
/*-------------------------------------------------------------------*/
void remove_from_int_list(IDXTYPE **list, IDXTYPE num)
{
IDXTYPE i, num_items, *nlist;
/*
* Count number of entries.
*/
for (i = 0; (*list)[i] != NOTHING; i++);
#if CIRCLE_UNSIGNED_INDEX
if (num >= i)
#else
if (num < 0 || num >= i)
#endif
return;
num_items = i;
CREATE(nlist, IDXTYPE, num_items);
for (i = 0; i < num_items; i++)
nlist[i] = (i < num) ? (*list)[i] : (*list)[i + 1];
free(*list);
*list = nlist;
}
/*-------------------------------------------------------------------*/
/*
* Free all the notice character strings in a shop structure.
*/
void free_shop_strings(struct shop_data *shop)
{
if (S_NOITEM1(shop)) {
free(S_NOITEM1(shop));
S_NOITEM1(shop) = NULL;
}
if (S_NOITEM2(shop)) {
free(S_NOITEM2(shop));
S_NOITEM2(shop) = NULL;
}
if (S_NOCASH1(shop)) {
free(S_NOCASH1(shop));
S_NOCASH1(shop) = NULL;
}
if (S_NOCASH2(shop)) {
free(S_NOCASH2(shop));
S_NOCASH2(shop) = NULL;
}
if (S_NOBUY(shop)) {
free(S_NOBUY(shop));
S_NOBUY(shop) = NULL;
}
if (S_BUY(shop)) {
free(S_BUY(shop));
S_BUY(shop) = NULL;
}
if (S_SELL(shop)) {
free(S_SELL(shop));
S_SELL(shop) = NULL;
}
}
/*-------------------------------------------------------------------*/
/*
* Free a type list and all the strings it contains.
*/
void free_type_list(struct shop_buy_data **list)
{
int i;
for (i = 0; (*list)[i].type != NOTHING; i++)
if (BUY_WORD((*list)[i]))
free(BUY_WORD((*list)[i]));
free(*list);
*list = NULL;
}
/*-------------------------------------------------------------------*/
/*
* Free up the whole shop structure and it's content.
*/
void free_shop(struct shop_data *shop)
{
free_shop_strings(shop);
free_type_list(&(S_NAMELISTS(shop)));
free(S_ROOMS(shop));
free(S_PRODUCTS(shop));
free(shop);
}
/*-------------------------------------------------------------------*/
/* returns the real number of the shop with given virtual number
*
* We take so good care to keep it sorted - let's use it :) - Welcor
*/
shop_rnum real_shop(shop_vnum vnum)
{
shop_rnum bot, top, mid;
bot = 0;
top = top_shop - top_shop_offset;
/* perform binary search on shop_table */
for (;;) {
mid = (bot + top) / 2;
if (SHOP_NUM(mid) == vnum)
return (mid);
if (bot >= top)
return (NOWHERE);
if (SHOP_NUM(mid) > vnum)
top = mid;
else
bot = mid + 1;
}
}
/*-------------------------------------------------------------------*/
/*
* Generic string modifier for shop keeper messages.
*/
void modify_string(char **str, char *new_s)
{
char buf[MAX_STRING_LENGTH];
char *pointer;
/*
* Check the '%s' is present, if not, add it.
*/
if (*new_s != '%') {
snprintf(buf, sizeof(buf), "%%s %s", new_s);
pointer = buf;
} else
pointer = new_s;
if (*str)
free(*str);
*str = strdup(pointer);
}
/*-------------------------------------------------------------------*/
int add_shop(struct shop_data *nshp)
{
shop_rnum rshop;
int found = 0;
zone_rnum rznum = real_zone_by_thing(S_NUM(nshp));
/*
* The shop already exists, just update it.
*/
if ((rshop = real_shop(S_NUM(nshp))) != NOWHERE) {
/* free old strings. They're not used in any other place -- Welcor */
copy_shop(&shop_index[rshop], nshp, TRUE);
if (rznum != NOWHERE)
add_to_save_list(zone_table[rznum].number, SL_SHP);
else
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: GenOLC: Cannot determine shop zone.");
return rshop;
}
top_shop++;
RECREATE(shop_index, struct shop_data, top_shop - top_shop_offset + 1);
for (rshop = top_shop - top_shop_offset; rshop > 0; rshop--) {
if (nshp->vnum > SHOP_NUM(rshop - 1)) {
found = rshop;
/* Make a "nofree" variant and remove these later. */
shop_index[rshop].in_room = NULL;
shop_index[rshop].producing = NULL;
shop_index[rshop].type = NULL;
/* don't free old strings - they're still in use -- Welcor */
copy_shop(&shop_index[rshop], nshp, FALSE);
break;
}
shop_index[rshop] = shop_index[rshop - 1];
}
if (!found) {
/* Make a "nofree" variant and remove these later. */
shop_index[rshop].in_room = NULL;
shop_index[rshop].producing = NULL;
shop_index[rshop].type = NULL;
/* don't free old strings - they're still in use -- Welcor */
copy_shop(&shop_index[0], nshp, FALSE);
}
if (rznum != NOWHERE)
add_to_save_list(zone_table[rznum].number, SL_SHP);
else
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: GenOLC: Cannot determine shop zone.");
return rshop;
}
/*-------------------------------------------------------------------*/
int save_shops(zone_rnum zone_num)
{
int i, j, rshop;
FILE *shop_file;
char fname[128], oldname[128];
struct shop_data *shop;
#if CIRCLE_UNSIGNED_INDEX
if (zone_num == NOWHERE || zone_num > top_of_zone_table) {
#else
if (zone_num < 0 || zone_num > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_shops: Invalid real zone number %d. (0-%d)", zone_num, top_of_zone_table);
return FALSE;
}
snprintf(fname, sizeof(fname), "%s/%d.new", SHP_PREFIX, zone_table[zone_num].number);
if (!(shop_file = fopen(fname, "w"))) {
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: OLC: Cannot open shop file!");
return FALSE;
} else if (fprintf(shop_file, "CircleMUD v3.0 Shop File~\n") < 0) {
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: OLC: Cannot write to shop file!");
fclose(shop_file);
return FALSE;
}
/*
* Search database for shops in this zone.
*/
for (i = genolc_zone_bottom(zone_num); i <= zone_table[zone_num].top; i++) {
if ((rshop = real_shop(i)) != NOWHERE) {
fprintf(shop_file, "#%d~\n", i);
shop = shop_index + rshop;
/*
* Save the products.
*/
for (j = 0; S_PRODUCT(shop, j) != NOTHING; j++)
fprintf(shop_file, "%d\n", obj_index[S_PRODUCT(shop, j)].vnum);
fprintf(shop_file, "-1\n");
/*
* Save the rates.
*/
fprintf(shop_file, "%1.2f\n"
"%1.2f\n",
S_BUYPROFIT(shop),
S_SELLPROFIT(shop));
/*
* Save the buy types and namelists.
*/
for (j = 0;S_BUYTYPE(shop, j) != NOTHING; j++)
fprintf(shop_file, "%d%s\n",
S_BUYTYPE(shop, j),
S_BUYWORD(shop, j) ? S_BUYWORD(shop, j) : "");
fprintf(shop_file, "-1\n");
/* Not allowed to use Ascii in shopfile anymore (bpl21)
sprintascii(buf1, S_BITVECTOR(shop));
sprintascii(buf2, S_NOTRADE(shop));
*/
/*
* Save messages'n'stuff.
* Added some small'n'silly defaults as sanity checks.
*/
fprintf(shop_file,
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%d\n"
"%ld\n"
"%d\n"
"%d\n",
S_NOITEM1(shop) ? S_NOITEM1(shop) : "%s Ke?!",
S_NOITEM2(shop) ? S_NOITEM2(shop) : "%s Ke?!",
S_NOBUY(shop) ? S_NOBUY(shop) : "%s Ke?!",
S_NOCASH1(shop) ? S_NOCASH1(shop) : "%s Ke?!",
S_NOCASH2(shop) ? S_NOCASH2(shop) : "%s Ke?!",
S_BUY(shop) ? S_BUY(shop) : "%s Ke?! %d?",
S_SELL(shop) ? S_SELL(shop) : "%s Ke?! %d?",
S_BROKE_TEMPER(shop),
S_BITVECTOR(shop),
S_KEEPER(shop) == NOBODY ? -1 : mob_index[S_KEEPER(shop)].vnum,
S_NOTRADE(shop)
);
/*
* Save the rooms.
*/
for (j = 0;S_ROOM(shop, j) != NOWHERE; j++)
fprintf(shop_file, "%d\n", S_ROOM(shop, j));
fprintf(shop_file, "-1\n");
/*
* Save open/closing times
*/
fprintf(shop_file, "%d\n%d\n%d\n%d\n", S_OPEN1(shop), S_CLOSE1(shop),
S_OPEN2(shop), S_CLOSE2(shop));
}
}
fprintf(shop_file, "$~\n");
fclose(shop_file);
snprintf(oldname, sizeof(oldname), "%s/%d.shp", SHP_PREFIX, zone_table[zone_num].number);
remove(oldname);
rename(fname, oldname);
if (in_save_list(zone_table[zone_num].number, SL_SHP))
remove_from_save_list(zone_table[zone_num].number, SL_SHP);
return TRUE;
}

55
src/genshp.h Normal file
View file

@ -0,0 +1,55 @@
/************************************************************************
* Generic OLC Library - Shops / genshp.h v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
void copy_shop(struct shop_data *tshop, struct shop_data *fshop, int free_old_strings);
void copy_list(IDXTYPE **tlist, IDXTYPE *flist);
void copy_type_list(struct shop_buy_data **tlist, struct shop_buy_data *flist);
void remove_from_type_list(struct shop_buy_data **list, int num);
void remove_from_int_list(IDXTYPE **list, IDXTYPE num);
void add_to_type_list(struct shop_buy_data **list, struct shop_buy_data *newl);
void add_to_int_list(IDXTYPE **tlist, IDXTYPE newi);
void free_shop_string(struct shop_data *shop);
void free_type_list(struct shop_buy_data **list);
void free_shop(struct shop_data *shop);
void free_shop_strings(struct shop_data *shop);
void modify_string(char **str, char *newstr);
int add_shop(struct shop_data *shop);
int save_shops(zone_rnum zone_num);
shop_rnum real_shop(shop_vnum vnum);
/*
* Handy macros.
*/
#define S_NUM(i) ((i)->vnum)
#define S_KEEPER(i) ((i)->keeper)
#define S_OPEN1(i) ((i)->open1)
#define S_CLOSE1(i) ((i)->close1)
#define S_OPEN2(i) ((i)->open2)
#define S_CLOSE2(i) ((i)->close2)
#define S_BANK(i) ((i)->bankAccount)
#define S_BROKE_TEMPER(i) ((i)->temper1)
#define S_BITVECTOR(i) ((i)->bitvector)
#define S_NOTRADE(i) ((i)->with_who)
#define S_SORT(i) ((i)->lastsort)
#define S_BUYPROFIT(i) ((i)->profit_buy)
#define S_SELLPROFIT(i) ((i)->profit_sell)
#define S_FUNC(i) ((i)->func)
#define S_ROOMS(i) ((i)->in_room)
#define S_PRODUCTS(i) ((i)->producing)
#define S_NAMELISTS(i) ((i)->type)
#define S_ROOM(i, num) ((i)->in_room[(num)])
#define S_PRODUCT(i, num) ((i)->producing[(num)])
#define S_BUYTYPE(i, num) (BUY_TYPE((i)->type[(num)]))
#define S_BUYWORD(i, num) (BUY_WORD((i)->type[(num)]))
#define S_NOITEM1(i) ((i)->no_such_item1)
#define S_NOITEM2(i) ((i)->no_such_item2)
#define S_NOCASH1(i) ((i)->missing_cash1)
#define S_NOCASH2(i) ((i)->missing_cash2)
#define S_NOBUY(i) ((i)->do_not_buy)
#define S_BUY(i) ((i)->message_buy)
#define S_SELL(i) ((i)->message_sell)

528
src/genwld.c Normal file
View file

@ -0,0 +1,528 @@
/************************************************************************
* Generic OLC Library - Rooms / genwld.c v1.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "handler.h"
#include "comm.h"
#include "genolc.h"
#include "genwld.h"
#include "genzon.h"
#include "shop.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 the description, title, and such.
*/
room_rnum add_room(struct room_data *room)
{
struct char_data *tch;
struct obj_data *tobj;
int j, found = FALSE;
room_rnum i;
if (room == NULL)
return NOWHERE;
if ((i = real_room(room->number)) != NOWHERE) {
if (SCRIPT(&world[i]))
extract_script(&world[i], WLD_TRIGGER);
tch = world[i].people;
tobj = world[i].contents;
copy_room(&world[i], room);
world[i].people = tch;
world[i].contents = tobj;
add_to_save_list(zone_table[room->zone].number, SL_WLD);
log("GenOLC: add_room: Updated existing room #%d.", room->number);
return i;
}
RECREATE(world, struct room_data, top_of_world + 2);
top_of_world++;
for (i = top_of_world; i > 0; i--) {
if (room->number > world[i - 1].number) {
world[i] = *room;
copy_room_strings(&world[i], room);
found = i;
break;
} else {
/* Copy the room over now. */
world[i] = world[i - 1];
update_wait_events(&world[i], &world[i-1]);
/* People in this room must have their in_rooms moved up one. */
for (tch = world[i].people; tch; tch = tch->next_in_room)
IN_ROOM(tch) += (IN_ROOM(tch) != NOWHERE);
/* Move objects too. */
for (tobj = world[i].contents; tobj; tobj = tobj->next_content)
IN_ROOM(tobj) += (IN_ROOM(tobj) != NOWHERE);
}
}
if (!found) {
world[0] = *room; /* Last place, in front. */
copy_room_strings(&world[0], room);
}
log("GenOLC: add_room: Added room %d at index #%d.", room->number, found);
/* found is equal to the array index where we added the room. */
/*
* Find what zone that room was in so we can update the loading table.
*/
for (i = room->zone; i <= top_of_zone_table; i++)
for (j = 0; ZCMD(i, j).command != 'S'; j++)
switch (ZCMD(i, j).command) {
case 'M':
case 'O':
case 'T':
case 'V':
ZCMD(i, j).arg3 += (ZCMD(i, j).arg3 != NOWHERE && ZCMD(i, j).arg3 >= found);
break;
case 'D':
case 'R':
ZCMD(i, j).arg1 += (ZCMD(i, j).arg1 != NOWHERE && ZCMD(i, j).arg1 >= found);
case 'G':
case 'P':
case 'E':
case '*':
/* Known zone entries we don't care about. */
break;
default:
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: add_room: Unknown zone entry found!");
}
/*
* Update the loadroom table. Adds 1 or 0.
*/
r_mortal_start_room += (r_mortal_start_room >= found);
r_immort_start_room += (r_immort_start_room >= found);
r_frozen_start_room += (r_frozen_start_room >= found);
/*
* Update world exits.
*/
i = top_of_world + 1;
do {
i--;
for (j = 0; j < NUM_OF_DIRS; j++)
if (W_EXIT(i, j) && W_EXIT(i, j)->to_room != NOWHERE)
W_EXIT(i, j)->to_room += (W_EXIT(i, j)->to_room >= found);
} while (i > 0);
add_to_save_list(zone_table[room->zone].number, SL_WLD);
/*
* Return what array entry we placed the new room in.
*/
return found;
}
/* -------------------------------------------------------------------------- */
int delete_room(room_rnum rnum)
{
room_rnum i;
int j;
struct char_data *ppl, *next_ppl;
struct obj_data *obj, *next_obj;
struct room_data *room;
if (rnum <= 0 || rnum > top_of_world) /* Can't delete void yet. */
return FALSE;
room = &world[rnum];
add_to_save_list(zone_table[room->zone].number, SL_WLD);
/* This is something you might want to read about in the logs. */
log("GenOLC: delete_room: Deleting room #%d (%s).", room->number, room->name);
if (r_mortal_start_room == rnum) {
log("WARNING: GenOLC: delete_room: Deleting mortal start room!");
r_mortal_start_room = 0; /* The Void */
}
if (r_immort_start_room == rnum) {
log("WARNING: GenOLC: delete_room: Deleting immortal start room!");
r_immort_start_room = 0; /* The Void */
}
if (r_frozen_start_room == rnum) {
log("WARNING: GenOLC: delete_room: Deleting frozen start room!");
r_frozen_start_room = 0; /* The Void */
}
/*
* Dump the contents of this room into the Void. We could also just
* extract the people, mobs, and objects here.
*/
for (obj = world[rnum].contents; obj; obj = next_obj) {
next_obj = obj->next_content;
obj_from_room(obj);
obj_to_room(obj, 0);
}
for (ppl = world[rnum].people; ppl; ppl = next_ppl) {
next_ppl = ppl->next_in_room;
char_from_room(ppl);
char_to_room(ppl, 0);
}
free_room_strings(room);
if (SCRIPT(room))
extract_script(room, WLD_TRIGGER);
free_proto_script(room, WLD_TRIGGER);
/*
* Change any exit going to this room to go the void.
* Also fix all the exits pointing to rooms above this.
*/
i = top_of_world + 1;
do {
i--;
for (j = 0; j < NUM_OF_DIRS; j++) {
if (W_EXIT(i, j) == NULL)
continue;
else if (W_EXIT(i, j)->to_room > rnum)
W_EXIT(i, j)->to_room -= (W_EXIT(i, j)->to_room != NOWHERE); /* with unsigned NOWHERE > any rnum */
else if (W_EXIT(i, j)->to_room == rnum) {
if ((!W_EXIT(i, j)->keyword || !*W_EXIT(i, j)->keyword) &&
(!W_EXIT(i, j)->general_description || !*W_EXIT(i, j)->general_description)) {
/* no description, remove exit completely */
if (W_EXIT(i, j)->keyword)
free(W_EXIT(i, j)->keyword);
if (W_EXIT(i, j)->general_description)
free(W_EXIT(i, j)->general_description);
free(W_EXIT(i, j));
W_EXIT(i, j) = NULL;
} else {
/* description is set, just point to nowhere */
W_EXIT(i, j)->to_room = NOWHERE;
}
}
}
} while (i > 0);
/*
* Find what zone that room was in so we can update the loading table.
*/
for (i = 0; i <= top_of_zone_table; i++)
for (j = 0; ZCMD(i , j).command != 'S'; j++)
switch (ZCMD(i, j).command) {
case 'M':
case 'O':
case 'T':
case 'V':
if (ZCMD(i, j).arg3 == rnum)
ZCMD(i, j).command = '*'; /* Cancel command. */
else if (ZCMD(i, j).arg3 > rnum)
ZCMD(i, j).arg3 -= (ZCMD(i, j).arg3 != NOWHERE); /* with unsigned NOWHERE > any rnum */
break;
case 'D':
case 'R':
if (ZCMD(i, j).arg1 == rnum)
ZCMD(i, j).command = '*'; /* Cancel command. */
else if (ZCMD(i, j).arg1 > rnum)
ZCMD(i, j).arg1 -= (ZCMD(i, j).arg1 != NOWHERE); /* with unsigned NOWHERE > any rnum */
case 'G':
case 'P':
case 'E':
case '*':
/* Known zone entries we don't care about. */
break;
default:
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: delete_room: Unknown zone entry found!");
}
/*
* Remove this room from all shop lists.
*/
for (i = 0;i < top_shop;i++) {
for (j = 0;SHOP_ROOM(i, j) != NOWHERE;j++) {
if (SHOP_ROOM(i, j) == world[rnum].number)
SHOP_ROOM(i, j) = 0; /* set to the void */
}
}
/*
* Now we actually move the rooms down.
*/
for (i = rnum; i < top_of_world; i++) {
world[i] = world[i + 1];
update_wait_events(&world[i], &world[i+1]);
for (ppl = world[i].people; ppl; ppl = ppl->next_in_room)
IN_ROOM(ppl) -= (IN_ROOM(ppl) != NOWHERE); /* Redundant check? */
for (obj = world[i].contents; obj; obj = obj->next_content)
IN_ROOM(obj) -= (IN_ROOM(obj) != NOWHERE); /* Redundant check? */
}
top_of_world--;
RECREATE(world, struct room_data, top_of_world + 1);
return TRUE;
}
int save_rooms(zone_rnum rzone)
{
int i;
struct room_data *room;
FILE *sf;
char filename[128];
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char bit[64];
#if CIRCLE_UNSIGNED_INDEX
if (rzone == NOWHERE || rzone > top_of_zone_table) {
#else
if (rzone < 0 || rzone > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_rooms: Invalid zone number %d passed! (0-%d)", rzone, top_of_zone_table);
return FALSE;
}
log("GenOLC: save_rooms: Saving rooms in zone #%d (%d-%d).",
zone_table[rzone].number, genolc_zone_bottom(rzone), zone_table[rzone].top);
snprintf(filename, sizeof(filename), "%s/%d.new", WLD_PREFIX, zone_table[rzone].number);
if (!(sf = fopen(filename, "w"))) {
perror("SYSERR: save_rooms");
return FALSE;
}
for (i = genolc_zone_bottom(rzone); i <= zone_table[rzone].top; i++) {
room_rnum rnum;
if ((rnum = real_room(i)) != NOWHERE) {
int j;
room = (world + rnum);
/*
* Copy the description and strip off trailing newlines.
*/
strncpy(buf, room->description ? room->description : "Empty room.", sizeof(buf)-1 );
strip_cr(buf);
/*
* Save the numeric and string section of the file.
*/
sprintascii(bit, room->room_flags);
fprintf(sf, "#%d\n"
"%s%c\n"
"%s%c\n"
"%d %s %d\n",
room->number,
room->name ? room->name : "Untitled", STRING_TERMINATOR,
buf, STRING_TERMINATOR,
zone_table[room->zone].number, bit, room->sector_type
);
/*
* Now you write out the exits for the room.
*/
for (j = 0; j < NUM_OF_DIRS; j++) {
if (R_EXIT(room, j)) {
int dflag;
if (R_EXIT(room, j)->general_description) {
strncpy(buf, R_EXIT(room, j)->general_description, sizeof(buf)-1);
strip_cr(buf);
} else
*buf = '\0';
/*
* Figure out door flag.
*/
if (IS_SET(R_EXIT(room, j)->exit_info, EX_ISDOOR)) {
if (IS_SET(R_EXIT(room, j)->exit_info, EX_PICKPROOF))
dflag = 2;
else
dflag = 1;
} else
dflag = 0;
if (R_EXIT(room, j)->keyword)
strncpy(buf1, R_EXIT(room, j)->keyword, sizeof(buf1)-1 );
else
*buf1 = '\0';
/*
* Now write the exit to the file.
*/
fprintf(sf, "D%d\n"
"%s~\n"
"%s~\n"
"%d %d %d\n", j, buf, buf1, dflag,
R_EXIT(room, j)->key != NOTHING ? R_EXIT(room, j)->key : -1,
R_EXIT(room, j)->to_room != NOWHERE ? world[R_EXIT(room, j)->to_room].number : -1);
}
}
if (room->ex_description) {
struct extra_descr_data *xdesc;
for (xdesc = room->ex_description; xdesc; xdesc = xdesc->next) {
strncpy(buf, xdesc->description, sizeof(buf));
strip_cr(buf);
fprintf(sf, "E\n"
"%s~\n"
"%s~\n", xdesc->keyword, buf);
}
}
fprintf(sf, "S\n");
script_save_to_disk(sf, room, WLD_TRIGGER);
}
}
/*
* Write the final line and close it.
*/
fprintf(sf, "$~\n");
fclose(sf);
/* Old file we're replacing. */
snprintf(buf, sizeof(buf), "%s/%d.wld", WLD_PREFIX, zone_table[rzone].number);
remove(buf);
rename(filename, buf);
if (in_save_list(zone_table[rzone].number, SL_WLD))
remove_from_save_list(zone_table[rzone].number, SL_WLD);
return TRUE;
}
int copy_room(struct room_data *to, struct room_data *from)
{
free_room_strings(to);
*to = *from;
copy_room_strings(to, from);
/* Don't put people and objects in two locations.
Am thinking this shouldn't be done here... */
from->people = NULL;
from->contents = NULL;
return TRUE;
}
/*
* Idea by: Cris Jacobin <jacobin@bellatlantic.net>
*/
room_rnum duplicate_room(room_vnum dest_vnum, room_rnum orig)
{
int new_rnum, znum;
struct room_data nroom;
#if CIRCLE_UNSIGNED_INDEX
if (orig == NOWHERE || orig > top_of_world) {
#else
if (orig < 0 || orig > top_of_world) {
#endif
log("SYSERR: GenOLC: copy_room: Given bad original real room.");
return NOWHERE;
} else if ((znum = real_zone_by_thing(dest_vnum)) == NOWHERE) {
log("SYSERR: GenOLC: copy_room: No such destination zone.");
return NOWHERE;
}
/*
* add_room will make its own copies of strings.
*/
if ((new_rnum = add_room(&nroom)) == NOWHERE) {
log("SYSERR: GenOLC: copy_room: Problem adding room.");
return NOWHERE;
}
nroom = world[new_rnum];
nroom.number = dest_vnum;
nroom.zone = znum;
/* So the people and objects aren't in two places at once... */
nroom.contents = NULL;
nroom.people = NULL;
return new_rnum;
}
/* -------------------------------------------------------------------------- */
/*
* Copy strings over so bad things don't happen. We do not free the
* existing strings here because copy_room() did a shallow copy previously
* and we'd be freeing the very strings we're copying. If this function
* is used elsewhere, be sure to free_room_strings() the 'dest' room first.
*/
int copy_room_strings(struct room_data *dest, struct room_data *source)
{
int i;
if (dest == NULL || source == NULL) {
log("SYSERR: GenOLC: copy_room_strings: NULL values passed.");
return FALSE;
}
dest->description = str_udup(source->description);
dest->name = str_udup(source->name);
for (i = 0; i < NUM_OF_DIRS; i++) {
if (!R_EXIT(source, i))
continue;
CREATE(R_EXIT(dest, i), struct room_direction_data, 1);
*R_EXIT(dest, i) = *R_EXIT(source, i);
if (R_EXIT(source, i)->general_description)
R_EXIT(dest, i)->general_description = strdup(R_EXIT(source, i)->general_description);
if (R_EXIT(source, i)->keyword)
R_EXIT(dest, i)->keyword = strdup(R_EXIT(source, i)->keyword);
}
if (source->ex_description)
copy_ex_descriptions(&dest->ex_description, source->ex_description);
return TRUE;
}
int free_room_strings(struct room_data *room)
{
int i;
/* Free descriptions. */
if (room->name)
free(room->name);
if (room->description)
free(room->description);
if (room->ex_description)
free_ex_descriptions(room->ex_description);
/* Free exits. */
for (i = 0; i < NUM_OF_DIRS; i++) {
if (room->dir_option[i]) {
if (room->dir_option[i]->general_description)
free(room->dir_option[i]->general_description);
if (room->dir_option[i]->keyword)
free(room->dir_option[i]->keyword);
free(room->dir_option[i]);
room->dir_option[i] = NULL;
}
}
return TRUE;
}

14
src/genwld.h Normal file
View file

@ -0,0 +1,14 @@
/************************************************************************
* Generic OLC Library - Rooms / genwld.h v1.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
room_rnum add_room(struct room_data *);
int delete_room(room_rnum);
int save_rooms(zone_rnum);
int copy_room(struct room_data *to, struct room_data *from);
room_rnum duplicate_room(room_vnum to, room_rnum from);
int copy_room_strings(struct room_data *dest, struct room_data *source);
int free_room_strings(struct room_data *);

601
src/genzon.c Normal file
View file

@ -0,0 +1,601 @@
/************************************************************************
* Generic OLC Library - Zones / genzon.c v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "genolc.h"
#include "genzon.h"
#include "dg_scripts.h"
/* real zone of room/mobile/object/shop given */
zone_rnum real_zone_by_thing(room_vnum vznum)
{
zone_rnum bot, top, mid;
int low, high;
bot = 0;
top = top_of_zone_table;
/* perform binary search on zone-table */
for (;;) {
mid = (bot + top) / 2;
/* Upper/lower bounds of the zone. */
low = genolc_zone_bottom(mid);
high = zone_table[mid].top;
if (low <= vznum && vznum <= high)
return mid;
if (bot >= top)
return NOWHERE;
if (low > vznum)
top = mid - 1;
else
bot = mid + 1;
}
}
zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top, const char **error)
{
FILE *fp;
struct zone_data *zone;
int i;
zone_rnum rznum;
char buf[MAX_STRING_LENGTH];
#if CIRCLE_UNSIGNED_INDEX
if (vzone_num == NOWHERE) {
#else
if (vzone_num < 0) {
#endif
*error = "You can't make negative zones.\r\n";
return NOWHERE;
} else if (bottom > top) {
*error = "Bottom room cannot be greater than top room.\r\n";
return NOWHERE;
}
for (i = 0; i < top_of_zone_table; i++)
if (zone_table[i].number == vzone_num) {
*error = "That virtual zone already exists.\r\n";
return NOWHERE;
}
/*
* Create the zone file.
*/
snprintf(buf, sizeof(buf), "%s/%d.zon", ZON_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new zone file.");
*error = "Could not write zone file.\r\n";
return NOWHERE;
}
fprintf(fp, "#%d\nNone~\nNew Zone~\n%d %d 30 2\nS\n$\n", vzone_num, bottom, top);
fclose(fp);
/*
* Create the room file.
*/
snprintf(buf, sizeof(buf), "%s/%d.wld", WLD_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new world file.");
*error = "Could not write world file.\r\n";
return NOWHERE;
}
fprintf(fp, "#%d\nThe Beginning~\nNot much here.\n~\n%d 0 0\nS\n$\n", bottom, vzone_num);
fclose(fp);
/*
* Create the mobile file.
*/
snprintf(buf, sizeof(buf), "%s/%d.mob", MOB_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new mob file.");
*error = "Could not write mobile file.\r\n";
return NOWHERE;
}
fprintf(fp, "$\n");
fclose(fp);
/*
* Create the object file.
*/
snprintf(buf, sizeof(buf), "%s/%d.obj", OBJ_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new obj file.");
*error = "Could not write object file.\r\n";
return NOWHERE;
}
fprintf(fp, "$\n");
fclose(fp);
/*
* Create the shop file.
*/
snprintf(buf, sizeof(buf), "%s/%d.shp", SHP_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new shop file.");
*error = "Could not write shop file.\r\n";
return NOWHERE;
}
fprintf(fp, "$~\n");
fclose(fp);
/*
* Create the trigger file.
*/
snprintf(buf, sizeof(buf), "%s/%d.trg", TRG_PREFIX, vzone_num);
if (!(fp = fopen(buf, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Can't write new trigger file");
*error = "Could not write trigger file.\r\n";
return NOWHERE;
}
fprintf(fp, "$~\n");
fclose(fp);
/*
* Update index files.
*/
create_world_index(vzone_num, "zon");
create_world_index(vzone_num, "wld");
create_world_index(vzone_num, "mob");
create_world_index(vzone_num, "obj");
create_world_index(vzone_num, "shp");
create_world_index(vzone_num, "trg");
/*
* Make a new zone in memory. This was the source of all the zedit new
* crashes reported to the CircleMUD list. It was happily overwriting
* the stack. This new loop by Andrew Helm fixes that problem and is
* more understandable at the same time.
*
* The variable is 'top_of_zone_table_table + 2' because we need record 0
* through top_of_zone (top_of_zone_table + 1 items) and a new one which
* makes it top_of_zone_table + 2 elements large.
*/
RECREATE(zone_table, struct zone_data, top_of_zone_table + 2);
zone_table[top_of_zone_table + 1].number = 32000;
if (vzone_num > zone_table[top_of_zone_table].number)
rznum = top_of_zone_table + 1;
else {
int j, room;
for (i = top_of_zone_table + 1; i > 0 && vzone_num < zone_table[i - 1].number; i--) {
zone_table[i] = zone_table[i - 1];
for (j = zone_table[i].bot; j <= zone_table[i].top; j++)
if ((room = real_room(j)) != NOWHERE)
world[room].zone++;
}
rznum = i;
}
zone = &zone_table[rznum];
/*
* Ok, insert the new zone here.
*/
zone->name = strdup("New Zone");
zone->number = vzone_num;
zone->builders = strdup("None");
zone->bot = bottom;
zone->top = top;
zone->lifespan = 30;
zone->age = 0;
zone->reset_mode = 2;
/*
* No zone commands, just terminate it with an 'S'
*/
CREATE(zone->cmd, struct reset_com, 1);
zone->cmd[0].command = 'S';
top_of_zone_table++;
add_to_save_list(zone->number, SL_ZON);
return rznum;
}
/*-------------------------------------------------------------------*/
void create_world_index(int znum, const char *type)
{
FILE *newfile, *oldfile;
char new_name[32], old_name[32], *prefix;
int num, found = FALSE;
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
switch (*type) {
case 'z':
prefix = ZON_PREFIX;
break;
case 'w':
prefix = WLD_PREFIX;
break;
case 'o':
prefix = OBJ_PREFIX;
break;
case 'm':
prefix = MOB_PREFIX;
break;
case 's':
prefix = SHP_PREFIX;
break;
case 't':
prefix = TRG_PREFIX;
break;
default:
/*
* Caller messed up
*/
return;
}
snprintf(old_name, sizeof(old_name), "%s/index", prefix);
snprintf(new_name, sizeof(new_name), "%s/newindex", prefix);
if (!(oldfile = fopen(old_name, "r"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Failed to open %s.", old_name);
return;
} else if (!(newfile = fopen(new_name, "w"))) {
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: OLC: Failed to open %s.", new_name);
fclose(oldfile);
return;
}
/*
* Index contents must be in order: search through the old file for the
* right place, insert the new file, then copy the rest over.
*/
snprintf(buf1, sizeof(buf1), "%d.%s", znum, type);
while (get_line(oldfile, buf)) {
if (*buf == '$') {
/*
* The following used to add a blank line, thanks to Brian Taylor for the fix... (Mythran)
*/
fprintf(newfile, "%s", (!found ? strncat(buf1, "\n$\n", sizeof(buf1)-1) : "$\n"));
break;
} else if (!found) {
sscanf(buf, "%d", &num);
if (num > znum) {
found = TRUE;
fprintf(newfile, "%s\n", buf1);
}
}
fprintf(newfile, "%s\n", buf);
}
fclose(newfile);
fclose(oldfile);
/*
* Out with the old, in with the new.
*/
remove(old_name);
rename(new_name, old_name);
}
/*-------------------------------------------------------------------*/
void remove_room_zone_commands(zone_rnum zone, room_rnum room_num)
{
int subcmd = 0, cmd_room = -2;
/*
* Delete all entries in zone_table that relate to this room so we
* can add all the ones we have in their place.
*/
while (zone_table[zone].cmd[subcmd].command != 'S') {
switch (zone_table[zone].cmd[subcmd].command) {
case 'M':
case 'O':
case 'T':
case 'V':
cmd_room = zone_table[zone].cmd[subcmd].arg3;
break;
case 'D':
case 'R':
cmd_room = zone_table[zone].cmd[subcmd].arg1;
break;
default:
break;
}
if (cmd_room == room_num)
remove_cmd_from_list(&zone_table[zone].cmd, subcmd);
else
subcmd++;
}
}
/*-------------------------------------------------------------------*/
/*
* Save all the zone_table for this zone to disk. This function now
* writes simple comments in the form of (<name>) to each record. A
* header for each field is also there.
*/
int save_zone(zone_rnum zone_num)
{
int subcmd, arg1 = -1, arg2 = -1, arg3 = -1;
char fname[128], oldname[128];
const char *comment = NULL;
FILE *zfile;
#if CIRCLE_UNSIGNED_INDEX
if (zone_num == NOWHERE || zone_num > top_of_zone_table) {
#else
if (zone_num < 0 || zone_num > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_zone: Invalid real zone number %d. (0-%d)", zone_num, top_of_zone_table);
return FALSE;
}
snprintf(fname, sizeof(fname), "%s/%d.new", ZON_PREFIX, zone_table[zone_num].number);
if (!(zfile = fopen(fname, "w"))) {
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: save_zones: Can't write zone %d.", zone_table[zone_num].number);
return FALSE;
}
/*
* Print zone header to file
*/
fprintf(zfile, "#%d\n"
"%s~\n"
"%s~\n"
"%d %d %d %d\n",
zone_table[zone_num].number,
(zone_table[zone_num].builders && *zone_table[zone_num].builders)
? zone_table[zone_num].builders : "None.",
(zone_table[zone_num].name && *zone_table[zone_num].name)
? zone_table[zone_num].name : "undefined",
genolc_zone_bottom(zone_num),
zone_table[zone_num].top,
zone_table[zone_num].lifespan,
zone_table[zone_num].reset_mode
);
/*
* Handy Quick Reference Chart for Zone Values.
*
* Field #1 Field #3 Field #4 Field #5
* -------------------------------------------------
* M (Mobile) Mob-Vnum Wld-Max Room-Vnum
* O (Object) Obj-Vnum Wld-Max Room-Vnum
* G (Give) Obj-Vnum Wld-Max Unused
* E (Equip) Obj-Vnum Wld-Max EQ-Position
* P (Put) Obj-Vnum Wld-Max Target-Obj-Vnum
* D (Door) Room-Vnum Door-Dir Door-State
* R (Remove) Room-Vnum Obj-Vnum Unused
* T (Trigger) Trig-type Trig-Vnum Room-Vnum
* V (var) Trig-type Context Room-Vnum Varname Value
* -------------------------------------------------
*/
for (subcmd = 0; ZCMD(zone_num, subcmd).command != 'S'; subcmd++) {
switch (ZCMD(zone_num, subcmd).command) {
case 'M':
arg1 = mob_index[ZCMD(zone_num, subcmd).arg1].vnum;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = world[ZCMD(zone_num, subcmd).arg3].number;
comment = mob_proto[ZCMD(zone_num, subcmd).arg1].player.short_descr;
break;
case 'O':
arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = world[ZCMD(zone_num, subcmd).arg3].number;
comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description;
break;
case 'G':
arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = -1;
comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description;
break;
case 'E':
arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = ZCMD(zone_num, subcmd).arg3;
comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description;
break;
case 'P':
arg1 = obj_index[ZCMD(zone_num, subcmd).arg1].vnum;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = obj_index[ZCMD(zone_num, subcmd).arg3].vnum;
comment = obj_proto[ZCMD(zone_num, subcmd).arg1].short_description;
break;
case 'D':
arg1 = world[ZCMD(zone_num, subcmd).arg1].number;
arg2 = ZCMD(zone_num, subcmd).arg2;
arg3 = ZCMD(zone_num, subcmd).arg3;
comment = world[ZCMD(zone_num, subcmd).arg1].name;
break;
case 'R':
arg1 = world[ZCMD(zone_num, subcmd).arg1].number;
arg2 = obj_index[ZCMD(zone_num, subcmd).arg2].vnum;
comment = obj_proto[ZCMD(zone_num, subcmd).arg2].short_description;
arg3 = -1;
break;
case 'T':
arg1 = ZCMD(zone_num, subcmd).arg1; /* trigger type */
arg2 = trig_index[ZCMD(zone_num, subcmd).arg2]->vnum; /* trigger vnum */
arg3 = world[ZCMD(zone_num, subcmd).arg3].number; /* room num */
comment = GET_TRIG_NAME(trig_index[real_trigger(arg2)]->proto);
break;
case 'V':
arg1 = ZCMD(zone_num, subcmd).arg1; /* trigger type */
arg2 = ZCMD(zone_num, subcmd).arg2; /* context */
arg3 = world[ZCMD(zone_num, subcmd).arg3].number;
break;
case '*':
/*
* Invalid commands are replaced with '*' - Ignore them.
*/
continue;
default:
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: z_save_to_disk(): Unknown cmd '%c' - NOT saving", ZCMD(zone_num, subcmd).command);
continue;
}
if (ZCMD(zone_num, subcmd).command != 'V')
fprintf(zfile, "%c %d %d %d %d \t(%s)\n",
ZCMD(zone_num, subcmd).command, ZCMD(zone_num, subcmd).if_flag, arg1, arg2, arg3, comment);
else
fprintf(zfile, "%c %d %d %d %d %s %s\n",
ZCMD(zone_num, subcmd).command, ZCMD(zone_num, subcmd).if_flag, arg1, arg2, arg3,
ZCMD(zone_num, subcmd).sarg1, ZCMD(zone_num, subcmd).sarg2);
}
fputs("S\n$\n", zfile);
fclose(zfile);
snprintf(oldname, sizeof(oldname), "%s/%d.zon", ZON_PREFIX, zone_table[zone_num].number);
remove(oldname);
rename(fname, oldname);
if (in_save_list(zone_table[zone_num].number, SL_ZON))
remove_from_save_list(zone_table[zone_num].number, SL_ZON);
return TRUE;
}
/*-------------------------------------------------------------------*/
/*
* Some common code to count the number of comands in the list.
*/
int count_commands(struct reset_com *list)
{
int count = 0;
while (list[count].command != 'S')
count++;
return count;
}
/*-------------------------------------------------------------------*/
/*
* Adds a new reset command into a list. Takes a pointer to the list
* so that it may play with the memory locations.
*/
void add_cmd_to_list(struct reset_com **list, struct reset_com *newcmd, int pos)
{
int count, i, l;
struct reset_com *newlist;
/*
* Count number of commands (not including terminator).
*/
count = count_commands(*list);
/*
* Value is +2 for the terminator and new field to add.
*/
CREATE(newlist, struct reset_com, count + 2);
/*
* Even tighter loop to copy the old list and insert a new command.
*/
for (i = 0, l = 0; i <= count; i++) {
newlist[i] = ((i == pos) ? *newcmd : (*list)[l++]);
}
/*
* Add terminator, then insert new list.
*/
newlist[count + 1].command = 'S';
free(*list);
*list = newlist;
}
/*-------------------------------------------------------------------*/
/*
* Remove a reset command from a list. Takes a pointer to the list
* so that it may play with the memory locations.
*/
void remove_cmd_from_list(struct reset_com **list, int pos)
{
int count, i, l;
struct reset_com *newlist;
/*
* Count number of commands (not including terminator)
*/
count = count_commands(*list);
/*
* Value is 'count' because we didn't include the terminator above
* but since we're deleting one thing anyway we want one less.
*/
CREATE(newlist, struct reset_com, count);
/*
* Even tighter loop to copy old list and skip unwanted command.
*/
for (i = 0, l = 0; i < count; i++) {
if (i != pos) {
newlist[l++] = (*list)[i];
}
}
/*
* Add the terminator, then insert the new list.
*/
newlist[count - 1].command = 'S';
free(*list);
*list = newlist;
}
/*-------------------------------------------------------------------*/
/*
* Error check user input and then add new (blank) command
*/
int new_command(struct zone_data *zone, int pos)
{
int subcmd = 0;
struct reset_com *new_com;
/*
* Error check to ensure users hasn't given too large an index
*/
while (zone->cmd[subcmd].command != 'S')
subcmd++;
if (pos < 0 || pos > subcmd)
return 0;
/*
* Ok, let's add a new (blank) command
*/
CREATE(new_com, struct reset_com, 1);
new_com->command = 'N';
add_cmd_to_list(&zone->cmd, new_com, pos);
return 1;
}
/*-------------------------------------------------------------------*/
/*
* Error check user input and then remove command
*/
void delete_command(struct zone_data *zone, int pos)
{
int subcmd = 0;
/*
* Error check to ensure users hasn't given too large an index
*/
while (zone->cmd[subcmd].command != 'S')
subcmd++;
if (pos < 0 || pos >= subcmd)
return;
/*
* Ok, let's zap it
*/
remove_cmd_from_list(&zone->cmd, pos);
}
/*-------------------------------------------------------------------*/

18
src/genzon.h Normal file
View file

@ -0,0 +1,18 @@
/************************************************************************
* Generic OLC Library - Zones / genzon.h v1.0 *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
zone_rnum create_new_zone(zone_vnum vzone_num, room_vnum bottom, room_vnum top, const char **error);
void create_world_index(int znum, const char *type);
void remove_room_zone_commands(zone_rnum zone, room_rnum room_num);
int save_zone(zone_rnum zone_num);
int count_commands(struct reset_com *list);
void add_cmd_to_list(struct reset_com **list, struct reset_com *newcmd, int pos);
void remove_cmd_from_list(struct reset_com **list, int pos);
int new_command(struct zone_data *zone, int pos);
void delete_command(struct zone_data *zone, int pos);
zone_rnum real_zone_by_thing(room_vnum vznum);
/* Make delete_zone() */

248
src/graph.c Normal file
View file

@ -0,0 +1,248 @@
/* ************************************************************************
* File: graph.c Part of CircleMUD *
* Usage: various graph algorithms *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
/* external functions */
ACMD(do_say);
/* external variables */
extern const char *dirs[];
/* local functions */
int VALID_EDGE(room_rnum x, int y);
void bfs_enqueue(room_rnum room, int dir);
void bfs_dequeue(void);
void bfs_clear_queue(void);
int find_first_step(room_rnum src, room_rnum target);
ACMD(do_track);
void hunt_victim(struct char_data *ch);
struct bfs_queue_struct {
room_rnum room;
char dir;
struct bfs_queue_struct *next;
};
static struct bfs_queue_struct *queue_head = 0, *queue_tail = 0;
/* Utility macros */
#define MARK(room) (SET_BIT(ROOM_FLAGS(room), ROOM_BFS_MARK))
#define UNMARK(room) (REMOVE_BIT(ROOM_FLAGS(room), ROOM_BFS_MARK))
#define IS_MARKED(room) (ROOM_FLAGGED(room, ROOM_BFS_MARK))
#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))
int VALID_EDGE(room_rnum x, int y)
{
if (world[x].dir_option[y] == NULL || TOROOM(x, y) == NOWHERE)
return 0;
if (CONFIG_TRACK_T_DOORS == FALSE && IS_CLOSED(x, y))
return 0;
if (ROOM_FLAGGED(TOROOM(x, y), ROOM_NOTRACK) || IS_MARKED(TOROOM(x, y)))
return 0;
return 1;
}
void bfs_enqueue(room_rnum room, int dir)
{
struct bfs_queue_struct *curr;
CREATE(curr, struct bfs_queue_struct, 1);
curr->room = room;
curr->dir = dir;
curr->next = 0;
if (queue_tail) {
queue_tail->next = curr;
queue_tail = curr;
} else
queue_head = queue_tail = curr;
}
void bfs_dequeue(void)
{
struct bfs_queue_struct *curr;
curr = queue_head;
if (!(queue_head = queue_head->next))
queue_tail = 0;
free(curr);
}
void bfs_clear_queue(void)
{
while (queue_head)
bfs_dequeue();
}
/*
* find_first_step: given a source room and a target room, find the first
* step 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 PC. Or, a 'track' skill for PCs.
*/
int find_first_step(room_rnum src, room_rnum target)
{
int curr_dir;
room_rnum curr_room;
if (src == NOWHERE || target == NOWHERE || src > top_of_world || target > top_of_world) {
log("SYSERR: Illegal value %d or %d passed to find_first_step. (%s)", src, target, __FILE__);
return (BFS_ERROR);
}
if (src == target)
return (BFS_ALREADY_THERE);
/* clear marks first, some OLC systems will save the mark. */
for (curr_room = 0; curr_room <= top_of_world; curr_room++)
UNMARK(curr_room);
MARK(src);
/* first, enqueue the first steps, saving which direction we're going. */
for (curr_dir = 0; curr_dir < NUM_OF_DIRS; curr_dir++)
if (VALID_EDGE(src, curr_dir)) {
MARK(TOROOM(src, curr_dir));
bfs_enqueue(TOROOM(src, curr_dir), curr_dir);
}
/* now, do the classic BFS. */
while (queue_head) {
if (queue_head->room == target) {
curr_dir = queue_head->dir;
bfs_clear_queue();
return (curr_dir);
} else {
for (curr_dir = 0; curr_dir < NUM_OF_DIRS; curr_dir++)
if (VALID_EDGE(queue_head->room, curr_dir)) {
MARK(TOROOM(queue_head->room, curr_dir));
bfs_enqueue(TOROOM(queue_head->room, curr_dir), queue_head->dir);
}
bfs_dequeue();
}
}
return (BFS_NO_PATH);
}
/********************************************************
* Functions and Commands which use the above functions. *
********************************************************/
ACMD(do_track)
{
char arg[MAX_INPUT_LENGTH];
struct char_data *vict;
int dir;
/* The character must have the track skill. */
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TRACK)) {
send_to_char(ch, "You have no idea how.\r\n");
return;
}
one_argument(argument, arg);
if (!*arg) {
send_to_char(ch, "Whom are you trying to track?\r\n");
return;
}
/* The person can't see the victim. */
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD))) {
send_to_char(ch, "No one is around by that name.\r\n");
return;
}
/* We can't track the victim. */
if (AFF_FLAGGED(vict, AFF_NOTRACK)) {
send_to_char(ch, "You sense no trail.\r\n");
return;
}
/* 101 is a complete failure, no matter what the proficiency. */
if (rand_number(0, 101) >= GET_SKILL(ch, SKILL_TRACK)) {
int tries = 10;
/* Find a random direction. :) */
do {
dir = rand_number(0, NUM_OF_DIRS - 1);
} while (!CAN_GO(ch, dir) && --tries);
send_to_char(ch, "You sense a trail %s from here!\r\n", dirs[dir]);
return;
}
/* They passed the skill check. */
dir = find_first_step(IN_ROOM(ch), IN_ROOM(vict));
switch (dir) {
case BFS_ERROR:
send_to_char(ch, "Hmm.. something seems to be wrong.\r\n");
break;
case BFS_ALREADY_THERE:
send_to_char(ch, "You're already in the same room!!\r\n");
break;
case BFS_NO_PATH:
send_to_char(ch, "You can't sense a trail to %s from here.\r\n", HMHR(vict));
break;
default: /* Success! */
send_to_char(ch, "You sense a trail %s from here!\r\n", dirs[dir]);
break;
}
}
void hunt_victim(struct char_data *ch)
{
int dir;
byte found;
struct char_data *tmp;
if (!ch || !HUNTING(ch) || FIGHTING(ch))
return;
/* make sure the char still exists */
for (found = FALSE, tmp = character_list; tmp && !found; tmp = tmp->next)
if (HUNTING(ch) == tmp)
found = TRUE;
if (!found) {
char actbuf[MAX_INPUT_LENGTH] = "Damn! My prey is gone!!";
do_say(ch, actbuf, 0, 0);
HUNTING(ch) = NULL;
return;
}
if ((dir = find_first_step(IN_ROOM(ch), IN_ROOM(HUNTING(ch)))) < 0) {
char buf[MAX_INPUT_LENGTH];
snprintf(buf, sizeof(buf), "Damn! I lost %s!", HMHR(HUNTING(ch)));
do_say(ch, buf, 0, 0);
HUNTING(ch) = NULL;
} else {
perform_move(ch, dir, 1);
if (IN_ROOM(ch) == IN_ROOM(HUNTING(ch)))
hit(ch, HUNTING(ch), TYPE_UNDEFINED);
}
}

1434
src/handler.c Normal file

File diff suppressed because it is too large Load diff

143
src/handler.h Normal file
View file

@ -0,0 +1,143 @@
/* ************************************************************************
* File: handler.h Part of CircleMUD *
* Usage: header file: prototypes of handling and utility functions *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
/* handling the affected-structures */
void affect_total(struct char_data *ch);
void affect_modify(struct char_data *ch, byte loc, sbyte mod, bitvector_t bitv, bool add);
void affect_to_char(struct char_data *ch, struct affected_type *af);
void affect_remove(struct char_data *ch, struct affected_type *af);
void affect_from_char(struct char_data *ch, int type);
bool affected_by_spell(struct char_data *ch, int type);
void affect_join(struct char_data *ch, struct affected_type *af,
bool add_dur, bool avg_dur, bool add_mod, bool avg_mod);
/* utility */
const char *money_desc(int amount);
struct obj_data *create_money(int amount);
int isname(const char *str, const char *namelist);
int is_name(const char *str, const char *namelist);
char *fname(const char *namelist);
int get_number(char **name);
/* ******** objects *********** */
void obj_to_char(struct obj_data *object, struct char_data *ch);
void obj_from_char(struct obj_data *object);
void equip_char(struct char_data *ch, struct obj_data *obj, int pos);
struct obj_data *unequip_char(struct char_data *ch, int pos);
int invalid_align(struct char_data *ch, struct obj_data *obj);
void obj_to_room(struct obj_data *object, room_rnum room);
void obj_from_room(struct obj_data *object);
void obj_to_obj(struct obj_data *obj, struct obj_data *obj_to);
void obj_from_obj(struct obj_data *obj);
void object_list_new_owner(struct obj_data *list, struct char_data *ch);
void extract_obj(struct obj_data *obj);
/* ******* characters ********* */
struct char_data *get_char_room(char *name, int *num, room_rnum room);
struct char_data *get_char_num(mob_rnum nr);
void char_from_room(struct char_data *ch);
void char_to_room(struct char_data *ch, room_rnum room);
void extract_char(struct char_data *ch);
void extract_char_final(struct char_data *ch);
void extract_pending_chars(void);
/* find if character can see */
struct char_data *get_player_vis(struct char_data *ch, char *name, int *number, int inroom);
struct char_data *get_char_vis(struct char_data *ch, char *name, int *number, int where);
struct char_data *get_char_room_vis(struct char_data *ch, char *name, int *number);
struct char_data *get_char_world_vis(struct char_data *ch, char *name, int *number);
struct obj_data *get_obj_in_list_num(int num, struct obj_data *list);
struct obj_data *get_obj_num(obj_rnum nr);
struct obj_data *get_obj_in_list_vis(struct char_data *ch, char *name, int *number, struct obj_data *list);
struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *num);
struct obj_data *get_obj_in_equip_vis(struct char_data *ch, char *arg, int *number, struct obj_data *equipment[]);
int get_obj_pos_in_equip_vis(struct char_data *ch, char *arg, int *num, struct obj_data *equipment[]);
/* find all dots */
int find_all_dots(char *arg);
#define FIND_INDIV 0
#define FIND_ALL 1
#define FIND_ALLDOT 2
/* Generic Find */
int generic_find(char *arg, bitvector_t bitvector, struct char_data *ch,
struct char_data **tar_ch, struct obj_data **tar_obj);
#define FIND_CHAR_ROOM (1 << 0)
#define FIND_CHAR_WORLD (1 << 1)
#define FIND_OBJ_INV (1 << 2)
#define FIND_OBJ_ROOM (1 << 3)
#define FIND_OBJ_WORLD (1 << 4)
#define FIND_OBJ_EQUIP (1 << 5)
/* prototypes from crash save system */
int Crash_delete_file(char *name);
int Crash_delete_crashfile(struct char_data *ch);
int Crash_clean_file(char *name);
void Crash_listrent(struct char_data *ch, char *name);
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: */
#define LAST_FILE LIB_ETC"last"
#define LAST_CONNECT 0
#define LAST_ENTER_GAME 1
#define LAST_RECONNECT 2
#define LAST_TAKEOVER 3
#define LAST_QUIT 4
#define LAST_IDLEOUT 5
#define LAST_DISCONNECT 6
#define LAST_SHUTDOWN 7
#define LAST_REBOOT 8
#define LAST_CRASH 9
#define LAST_PLAYING 10
struct last_entry {
int close_type;
char hostname[256];
char username[16];
time_t time;
time_t close_time;
int idnum;
int punique;
};
void add_llog_entry(struct char_data *ch, int type);
struct last_entry *find_llog_entry(int punique, long idnum);
void mod_llog_entry(struct last_entry *llast,int type);

512
src/hedit.c Normal file
View file

@ -0,0 +1,512 @@
/************************************************************************
* hedit.c Hedit version 3.0 for Oasis OLC 5/5/06 *
* by Steve Wolfe - siv@cyberenet.net *
* Updated by Scott Meisenholder for Oasis 2.0.6 *
* **********************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "comm.h"
#include "interpreter.h"
#include "utils.h"
#include "db.h"
#include "boards.h"
#include "oasis.h"
#include "genolc.h"
#include "genzon.h"
#include "handler.h"
#include "improved-edit.h"
/* List each help entry saved, was used for debugging. */
/*------------------------------------------------------------------------*/
/*
* External data structures.
*/
extern struct descriptor_data *descriptor_list;
extern void strip_string(char *buffer);
void hedit_disp_menu(struct descriptor_data *d);
/* 'global' vars */
struct help_index_element *help_table;
int top_of_h_table = 0; /* ref to top of help table */
int top_of_h_file = 0; /* ref of size of help file */
long top_help_idnum = 0; /* highest idnum in use */
void get_one_line(FILE *fl, char *buf);
void create_help_index(void);
int search_help(char *argument);
ACMD(do_reboot);
void load_help(FILE *fl, char *name)
{
char key[READ_SIZE + 1], next_key[READ_SIZE + 1], entry[32384];
size_t entrylen;
char line[READ_SIZE + 1], hname[READ_SIZE + 1], *scan;
struct help_index_element el;
strlcpy(hname, name, sizeof(hname));
/* get the first keyword line */
get_one_line(fl, key);
while (*key != '$') {
strcat(key, "\r\n"); /* strcat: OK (READ_SIZE - "\n" "\r\n" == READ_SIZE 1) */
entrylen = strlcpy(entry, key, sizeof(entry));
/* read in the corresponding help entry */
get_one_line(fl, line);
while (*line != '#' && entrylen < sizeof(entry) - 1) {
entrylen += strlcpy(entry + entrylen, line, sizeof(entry) - entrylen);
if (entrylen + 2 < sizeof(entry) - 1) {
strcpy(entry + entrylen, "\r\n"); /* strcpy: OK (size checked above) */
entrylen += 2;
}
get_one_line(fl, line);
}
if (entrylen >= sizeof(entry) - 1) {
int keysize;
const char *truncmsg = "\r\n*TRUNCATED*\r\n";
strcpy(entry + sizeof(entry) - strlen(truncmsg) - 1, truncmsg); /* strcpy: OK (assuming sane 'entry' size) */
keysize = strlen(key) - 2;
log("SYSERR: Help entry exceeded buffer space: %.*s", keysize, key);
/* If we ran out of buffer space, eat the rest of the entry. */
while (*line != '#')
get_one_line(fl, line);
}
if (*line == '#'){
if (sscanf(line, "#%d", &el.min_level) != 1){
log("SYSERR: Help entry does not have a min level. %s", key);
el.min_level = 0;
}
}
el.duplicate = 0;
el.entry = strdup(entry);
scan = one_word(key, next_key);
while (*next_key) {
el.keywords = strdup(next_key);
help_table[top_of_h_table++] = el;
el.duplicate++;
scan = one_word(scan, next_key);
}
/* get next keyword line (or $) */
get_one_line(fl, key);
}
}
int hsort(const void *a, const void *b)
{
const struct help_index_element *a1, *b1;
a1 = (const struct help_index_element *) a;
b1 = (const struct help_index_element *) b;
return (str_cmp(a1->keywords, b1->keywords));
}
ACMD(do_oasis_hedit)
{
struct descriptor_data *d;
int i;
if (!can_edit_zone(ch, HEDIT_PERMISSION)) {
send_to_char(ch, "You don't have access to editing Help files.\r\n");
return;
}
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_HEDIT) {
send_to_char(ch, "Sorry, only one can person can edit help files at a time.\r\n");
return;
}
skip_spaces(&argument);
if (!*argument) {
send_to_char(ch, "Please specify a help entry to edit.\r\n");
return;
}
d = ch->desc;
if (!str_cmp("save", argument)) {
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE, "OLC: %s saves help files.", GET_NAME(ch));
send_to_char(ch, "Writing help file..\r\n");
hedit_save_to_disk(d);
send_to_char(ch, "Done.\r\n");
return;
}
/*
* Give descriptor an OLC structure.
*/
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: do_oasis: Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
OLC_NUM(d) = 0;
OLC_STORAGE(d) = strdup(argument);
OLC_ZNUM(d) = search_help(OLC_STORAGE(d));
for(i = 0; i < (int)strlen(argument); i++)
argument[i] = toupper(argument[i]);
if (OLC_ZNUM(d) <= 0)
hedit_setup_new(d, OLC_STORAGE(d));
else
hedit_setup_existing(d, OLC_ZNUM(d));
STATE(d) = CON_HEDIT;
act("$n starts using OLC.", TRUE, d->character, 0, 0, TO_ROOM);
SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing help files.", GET_NAME(d->character));
}
/*------------------------------------------------------------------------*\
Utils and exported functions.
\*------------------------------------------------------------------------*/
void hedit_setup_new(struct descriptor_data *d, char *new_key)
{
CREATE(OLC_HELP(d), struct help_index_element, 1);
OLC_HELP(d)->keywords = strdup(new_key);
OLC_HELP(d)->entry = strdup("This is an unfinished help entry.\r\n");
OLC_HELP(d)->min_level = 0;
hedit_disp_menu(d);
OLC_VAL(d) = 0;
}
/*------------------------------------------------------------------------*/
void hedit_setup_existing(struct descriptor_data *d, int rnum)
{
/*
* Build a copy of the help entry for editing.
*/
CREATE(OLC_HELP(d), struct help_index_element, 1);
/*
* Allocate space for all strings.
*/
OLC_HELP(d)->keywords = strdup(help_table[rnum].keywords ?
help_table[rnum].keywords : "UNDEFINED\r\n");
OLC_HELP(d)->entry = strdup(help_table[rnum].entry ?
help_table[rnum].entry : "undefined\r\n");
OLC_HELP(d)->min_level = help_table[rnum].min_level;
/*
* Attach copy of help entry to player's descriptor.
*/
OLC_VAL(d) = 0;
hedit_disp_menu(d);
}
/*------------------------------------------------------------------------*/
void hedit_save_internally(struct descriptor_data *d)
{
struct help_index_element *new_help_table = NULL;
int i;
if (OLC_ZNUM(d) > top_of_h_table) {
CREATE(new_help_table, struct help_index_element, top_of_h_table + 2);
new_help_table[0] = *OLC_HELP(d);
for (i = 0; i <= top_of_h_table; i++)
new_help_table[i + 1] = help_table[i];
free(help_table);
help_table = new_help_table;
top_of_h_table ++;
} else
help_table[OLC_ZNUM(d)] = *OLC_HELP(d);
hedit_save_to_disk(d);
}
/*------------------------------------------------------------------------*/
void hedit_save_to_disk(struct descriptor_data *d)
{
FILE *fp;
char buf1[MAX_STRING_LENGTH], index_name[READ_SIZE], buf[READ_SIZE];
int i;
snprintf(index_name, sizeof(index_name), "%s%s", HLP_PREFIX, HELP_FILE);
if (!(fp = fopen(index_name, "w"))) {
log("SYSERR: Could not write help index file");
return;
}
for (i = 0; i <= top_of_h_table; i++){
if (help_table[i].entry && help_table[i].duplicate)
continue;
strncpy(buf1, help_table[i].entry ? help_table[i].entry : "Empty\n\r", sizeof(buf1) - 1);
strip_cr(buf1);
/*
* Forget making a buffer, lets just write the thing now.
*/
fprintf(fp, "%s" "#%d\n", buf1, help_table[i].min_level);
}
/*
* Write final line and close.
*/
fprintf(fp, "$~\n");
fclose(fp);
do_reboot(d->character, strcpy(buf, "xhelp"), 0, 0);
}
/**************************************************************************
Menu functions
**************************************************************************/
/*
* The main menu.
*/
void hedit_disp_menu(struct descriptor_data *d)
{
clear_screen(d);
write_to_output(d,
"\r\n@c-------------------------------------------------------------------------@n\r\n"
" @CHelpfile Editor@n \r\n"
"@c-------------------------------------------------------------------------@n\r\n"
"@g1@n) Keyword [@G%-12s@g]@n\r\n"
"@g2@n) Entry : \n@y%s\r\n"
"@g3@n) Min Level : @c%d@n\r\n"
"@gQ@n) Quit\r\n"
"Enter choice : ",
OLC_HELP(d)->keywords,
OLC_HELP(d)->entry,
OLC_HELP(d)->min_level
);
OLC_MODE(d) = HEDIT_MAIN_MENU;
}
/**************************************************************************
The main loop
**************************************************************************/
void hedit_parse(struct descriptor_data *d, char *arg)
{
char buf[MAX_STRING_LENGTH];
char *oldtext = '\0';
int number;
switch (OLC_MODE(d)) {
case HEDIT_CONFIRM_SAVESTRING:
switch (*arg) {
case 'y':
case 'Y':
snprintf(buf, sizeof(buf), "OLC: %s edits help for %s.", GET_NAME(d->character), OLC_HELP(d)->keywords);
mudlog(TRUE, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), CMP, buf);
write_to_output(d, "Help files saved to disk.\r\n");
hedit_save_internally(d);
/*
* Do NOT free strings! Just the help structure.
*/
cleanup_olc(d, CLEANUP_STRUCTS);
break;
case 'n':
case 'N':
/*
* Free everything up, including strings, etc.
*/
cleanup_olc(d, CLEANUP_ALL);
break;
default:
write_to_output(d, "Invalid choice!\r\nDo you wish to save this help entry internally? : \r\n");
break;
}
return;
case HEDIT_MAIN_MENU:
switch (*arg) {
case 'q':
case 'Q':
if (OLC_VAL(d)) { /* Something has been modified. */
write_to_output(d, "Do you wish to save this help entry? : ");
OLC_MODE(d) = HEDIT_CONFIRM_SAVESTRING;
} else {
log("this is a test of quit out of hedit");
write_to_output(d, "No changes made.\r\n");
cleanup_olc(d, CLEANUP_ALL);
}
break;
case '1':
write_to_output(d, "Enter keywords:-\r\n] ");
OLC_MODE(d) = HEDIT_KEYWORDS;
break;
case '2':
OLC_MODE(d) = HEDIT_ENTRY;
clear_screen(d);
send_editor_help(d);
write_to_output(d, "Enter help entry: (/s saves /h for help)\r\n");
if (OLC_HELP(d)->entry) {
write_to_output(d, "%s", OLC_HELP(d)->entry);
oldtext = strdup(OLC_HELP(d)->entry);
}
string_write(d, &OLC_HELP(d)->entry, 8052, 0, oldtext);
OLC_VAL(d) = 1;
break;
case '3':
write_to_output(d, "Enter min level:-\r\n] ");
OLC_MODE(d) = HEDIT_MIN_LEVEL;
break;
default:
write_to_output(d, "Invalid choice!\r\n");
hedit_disp_menu(d);
break;
}
return;
case HEDIT_KEYWORDS:
if (OLC_HELP(d)->keywords)
free(OLC_HELP(d)->keywords);
if (strlen(arg) > MAX_HELP_KEYWORDS)
arg[MAX_HELP_KEYWORDS - 1] = '\0';
strip_cr(arg);
OLC_HELP(d)->keywords = strdup((arg && *arg) ? arg : "UNDEFINED");
break;
case HEDIT_ENTRY:
/*
* We will NEVER get here, we hope.
*/
mudlog(TRUE, LVL_BUILDER, BRF, "SYSERR: Reached HEDIT_ENTRY case in parse_hedit");
break;
case HEDIT_MIN_LEVEL:
number = atoi(arg);
if ((number < 0) || (number > LVL_IMPL))
write_to_output(d, "That is not a valid choice!\r\nEnter min level:-\r\n] ");
else {
OLC_HELP(d)->min_level = number;
break;
}
return;
default:
/*
* We should never get here.
*/
mudlog(TRUE, LVL_BUILDER, BRF, "SYSERR: Reached default case in parse_hedit");
break;
}
/*
* If we get this far, something has been changed.
*/
OLC_VAL(d) = 1;
hedit_disp_menu(d);
}
void hedit_string_cleanup(struct descriptor_data *d, int terminator)
{
switch (OLC_MODE(d)) {
case HEDIT_ENTRY:
default:
hedit_disp_menu(d);
break;
}
}
ACMD(do_helpcheck)
{
char buf[MAX_STRING_LENGTH];
int i, w = 0;
char arg[64];
ACMD(do_action);
if(!help_table) {
send_to_char(ch, "The help_table doesn't exist!\r\n");
return;
}
sprintf(buf, "\r\n");
strcpy(buf, "Commands without help entries:\r\n");
strcat(buf, "-------------------------------------------------------------------\r\n");
for(i = 1; *(complete_cmd_info[i].command) != '\n'; i++) {
snprintf(arg, sizeof(arg), "%s", complete_cmd_info[i].command);
if(search_help(arg) <= 0) {
if(complete_cmd_info[i].command_pointer == do_action)
continue;
w++;
w = w%3;
sprintf(buf + strlen(buf), " %-20.20s%s", complete_cmd_info[i].command, (w ? "|":"\r\n"));
}
}
if(w)
strcat(buf, "\r\n");
if(ch->desc)
page_string(ch->desc, buf, 1);
*buf = '\0';
}
ACMD(do_hindex)
{
int len, count = 0, i;
char buf[MAX_STRING_LENGTH];
skip_spaces(&argument);
if (!*argument) {
send_to_char(ch, "Usage: hindex <string>\r\n");
return;
}
len = sprintf(buf, "Help index entries based on '%s':\r\n", argument);
for (i = 0; i <= top_of_h_table; i++)
if (is_abbrev(argument, help_table[i].keywords))
len += snprintf(buf + len, sizeof(buf) - len, "%-20.20s%s",
help_table[i].keywords, (++count % 3 ? "" : "\r\n"));
if (count % 3)
len += snprintf(buf + len, sizeof(buf) - len, "\r\n");
if (!count)
len += snprintf(buf + len, sizeof(buf) - len, " None.\r\n");
page_string(ch->desc, buf, TRUE);
}
void free_help(struct help_index_element *help)
{
if (help->keywords)
free(help->keywords);
if (help_table->entry && !help_table->duplicate)
free(help->entry);
free(help);
}
void free_help_table(void)
{
int i;
if (help_table) {
for (i = 0; i <= top_of_h_table; i++) {
if (help_table[i].keywords)
free(help_table[i].keywords);
if (help_table[i].entry && !help_table[i].duplicate)
free(help_table[i].entry);
}
free(help_table);
}
top_of_h_table = 0;
}

616
src/house.c Normal file
View file

@ -0,0 +1,616 @@
/* ************************************************************************
* File: house.c Part of CircleMUD *
* Usage: Handling of player houses *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "comm.h"
#include "handler.h"
#include "db.h"
#include "interpreter.h"
#include "utils.h"
#include "house.h"
#include "constants.h"
/* external functions */
struct obj_data *Obj_from_store(struct obj_file_elem object, int *location);
int Obj_to_store(struct obj_data *obj, FILE *fl, int location);
/* local globals */
struct house_control_rec house_control[MAX_HOUSES];
int num_of_houses = 0;
/* local functions */
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen);
int House_load(room_vnum vnum);
int House_save(struct obj_data *obj, FILE *fp);
void House_restore_weight(struct obj_data *obj);
void House_delete_file(room_vnum vnum);
int find_house(room_vnum vnum);
void House_save_control(void);
void hcontrol_list_houses(struct char_data *ch);
void hcontrol_build_house(struct char_data *ch, char *arg);
void hcontrol_destroy_house(struct char_data *ch, char *arg);
void hcontrol_pay_house(struct char_data *ch, char *arg);
ACMD(do_hcontrol);
ACMD(do_house);
/* First, the basics: finding the filename; loading/saving objects */
/* Return a filename given a house vnum */
int House_get_filename(room_vnum vnum, char *filename, size_t maxlen)
{
if (vnum == NOWHERE)
return (0);
snprintf(filename, maxlen, LIB_HOUSE"%d.house", vnum);
return (1);
}
/* Load all objects for a house */
int House_load(room_vnum vnum)
{
FILE *fl;
char filename[MAX_STRING_LENGTH];
struct obj_file_elem object;
room_rnum rnum;
int i;
if ((rnum = real_room(vnum)) == NOWHERE)
return (0);
if (!House_get_filename(vnum, filename, sizeof(filename)))
return (0);
if (!(fl = fopen(filename, "r+b"))) /* no file found */
return (0);
while (!feof(fl)) {
fread(&object, sizeof(struct obj_file_elem), 1, fl);
if (ferror(fl)) {
perror("SYSERR: Reading house file in House_load");
fclose(fl);
return (0);
}
if (!feof(fl))
obj_to_room(Obj_from_store(object, &i), rnum);
}
fclose(fl);
return (1);
}
/* Save all objects for a house (recursive; initial call must be followed
by a call to House_restore_weight) Assumes file is open already. */
int House_save(struct obj_data *obj, FILE *fp)
{
struct obj_data *tmp;
int result;
if (obj) {
House_save(obj->contains, fp);
House_save(obj->next_content, fp);
result = Obj_to_store(obj, fp, 0);
if (!result)
return (0);
for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj)
GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
}
return (1);
}
/* restore weight of containers after House_save has changed them for saving */
void House_restore_weight(struct obj_data *obj)
{
if (obj) {
House_restore_weight(obj->contains);
House_restore_weight(obj->next_content);
if (obj->in_obj)
GET_OBJ_WEIGHT(obj->in_obj) += GET_OBJ_WEIGHT(obj);
}
}
/* Save all objects in a house */
void House_crashsave(room_vnum vnum)
{
int rnum;
char buf[MAX_STRING_LENGTH];
FILE *fp;
if ((rnum = real_room(vnum)) == NOWHERE)
return;
if (!House_get_filename(vnum, buf, sizeof(buf)))
return;
if (!(fp = fopen(buf, "wb"))) {
perror("SYSERR: Error saving house file");
return;
}
if (!House_save(world[rnum].contents, fp)) {
fclose(fp);
return;
}
fclose(fp);
House_restore_weight(world[rnum].contents);
REMOVE_BIT(ROOM_FLAGS(rnum), ROOM_HOUSE_CRASH);
}
/* Delete a house save file */
void House_delete_file(room_vnum vnum)
{
char filename[MAX_INPUT_LENGTH];
FILE *fl;
if (!House_get_filename(vnum, filename, sizeof(filename)))
return;
if (!(fl = fopen(filename, "rb"))) {
if (errno != ENOENT)
log("SYSERR: Error deleting house file #%d. (1): %s", vnum, strerror(errno));
return;
}
fclose(fl);
if (remove(filename) < 0)
log("SYSERR: Error deleting house file #%d. (2): %s", vnum, strerror(errno));
}
/* List all objects in a house file */
void House_listrent(struct char_data *ch, room_vnum vnum)
{
FILE *fl;
char filename[MAX_STRING_LENGTH];
char buf[MAX_STRING_LENGTH];
struct obj_file_elem object;
struct obj_data *obj;
int i;
if (!House_get_filename(vnum, filename, sizeof(filename)))
return;
if (!(fl = fopen(filename, "rb"))) {
send_to_char(ch, "No objects on file for house #%d.\r\n", vnum);
return;
}
*buf = '\0';
while (!feof(fl)) {
fread(&object, sizeof(struct obj_file_elem), 1, fl);
if (ferror(fl)) {
fclose(fl);
return;
}
if (!feof(fl) && (obj = Obj_from_store(object, &i)) != NULL) {
send_to_char(ch, " [%5d] (%5dau) %s\r\n", GET_OBJ_VNUM(obj), GET_OBJ_RENT(obj), obj->short_description);
free_obj(obj);
}
}
fclose(fl);
}
/******************************************************************
* Functions for house administration (creation, deletion, etc. *
*****************************************************************/
int find_house(room_vnum vnum)
{
int i;
for (i = 0; i < num_of_houses; i++)
if (house_control[i].vnum == vnum)
return (i);
return (NOWHERE);
}
/* Save the house control information */
void House_save_control(void)
{
FILE *fl;
if (!(fl = fopen(HCONTROL_FILE, "wb"))) {
perror("SYSERR: Unable to open house control file.");
return;
}
/* write all the house control recs in one fell swoop. Pretty nifty, eh? */
fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl);
fclose(fl);
}
/* call from boot_db - will load control recs, load objs, set atrium bits */
/* should do sanity checks on vnums & remove invalid records */
void House_boot(void)
{
struct house_control_rec temp_house;
room_rnum real_house, real_atrium;
FILE *fl;
memset((char *)house_control,0,sizeof(struct house_control_rec)*MAX_HOUSES);
if (!(fl = fopen(HCONTROL_FILE, "rb"))) {
if (errno == ENOENT)
log(" House control file '%s' does not exist.", HCONTROL_FILE);
else
perror("SYSERR: " HCONTROL_FILE);
return;
}
while (!feof(fl) && num_of_houses < MAX_HOUSES) {
fread(&temp_house, sizeof(struct house_control_rec), 1, fl);
if (feof(fl))
break;
if (get_name_by_id(temp_house.owner) == NULL)
continue; /* owner no longer exists -- skip */
if ((real_house = real_room(temp_house.vnum)) == NOWHERE)
continue; /* this vnum doesn't exist -- skip */
if (find_house(temp_house.vnum) != NOWHERE)
continue; /* this vnum is already a house -- skip */
if ((real_atrium = real_room(temp_house.atrium)) == NOWHERE)
continue; /* house doesn't have an atrium -- skip */
if (temp_house.exit_num < 0 || temp_house.exit_num >= NUM_OF_DIRS)
continue; /* invalid exit num -- skip */
if (TOROOM(real_house, temp_house.exit_num) != real_atrium)
continue; /* exit num mismatch -- skip */
house_control[num_of_houses++] = temp_house;
SET_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE);
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
House_load(temp_house.vnum);
}
fclose(fl);
House_save_control();
}
/* "House Control" functions */
const char *HCONTROL_FORMAT =
"Usage: hcontrol build <house vnum> <exit direction> <player name>\r\n"
" hcontrol destroy <house vnum>\r\n"
" hcontrol pay <house vnum>\r\n"
" hcontrol show\r\n";
void hcontrol_list_houses(struct char_data *ch)
{
int i;
char *timestr, *temp;
char built_on[128], last_pay[128], own_name[MAX_NAME_LENGTH + 1];
if (!num_of_houses) {
send_to_char(ch, "No houses have been defined.\r\n");
return;
}
send_to_char(ch,
"Address Atrium Build Date Guests Owner Last Paymt\r\n"
"------- ------ ---------- ------ ------------ ----------\r\n");
for (i = 0; i < num_of_houses; i++) {
/* Avoid seeing <UNDEF> entries from self-deleted people. -gg 6/21/98 */
if ((temp = get_name_by_id(house_control[i].owner)) == NULL)
continue;
if (house_control[i].built_on) {
timestr = asctime(localtime(&(house_control[i].built_on)));
*(timestr + 10) = '\0';
strlcpy(built_on, timestr, sizeof(built_on));
} else
strcpy(built_on, "Unknown"); /* strcpy: OK (for 'strlen("Unknown") < 128') */
if (house_control[i].last_payment) {
timestr = asctime(localtime(&(house_control[i].last_payment)));
*(timestr + 10) = '\0';
strlcpy(last_pay, timestr, sizeof(built_on));
} else
strcpy(last_pay, "None"); /* strcpy: OK (for 'strlen("None") < 128') */
/* Now we need a copy of the owner's name to capitalize. -gg 6/21/98 */
strcpy(own_name, temp); /* strcpy: OK (names guaranteed <= MAX_NAME_LENGTH+1) */
send_to_char(ch, "%7d %7d %-10s %2d %-12s %s\r\n",
house_control[i].vnum, house_control[i].atrium, built_on,
house_control[i].num_of_guests, CAP(own_name), last_pay);
House_list_guests(ch, i, TRUE);
}
}
void hcontrol_build_house(struct char_data *ch, char *arg)
{
char arg1[MAX_INPUT_LENGTH];
struct house_control_rec temp_house;
room_vnum virt_house, virt_atrium;
room_rnum real_house, real_atrium;
sh_int exit_num;
long owner;
if (num_of_houses >= MAX_HOUSES) {
send_to_char(ch, "Max houses already defined.\r\n");
return;
}
/* first arg: house's vnum */
arg = one_argument(arg, arg1);
if (!*arg1) {
send_to_char(ch, "%s", HCONTROL_FORMAT);
return;
}
virt_house = atoi(arg1);
if ((real_house = real_room(virt_house)) == NOWHERE) {
send_to_char(ch, "No such room exists.\r\n");
return;
}
if ((find_house(virt_house)) != NOWHERE) {
send_to_char(ch, "House already exists.\r\n");
return;
}
/* second arg: direction of house's exit */
arg = one_argument(arg, arg1);
if (!*arg1) {
send_to_char(ch, "%s", HCONTROL_FORMAT);
return;
}
if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) {
send_to_char(ch, "'%s' is not a valid direction.\r\n", arg1);
return;
}
if (TOROOM(real_house, exit_num) == NOWHERE) {
send_to_char(ch, "There is no exit %s from room %d.\r\n", dirs[exit_num], virt_house);
return;
}
real_atrium = TOROOM(real_house, exit_num);
virt_atrium = GET_ROOM_VNUM(real_atrium);
if (TOROOM(real_atrium, rev_dir[exit_num]) != real_house) {
send_to_char(ch, "A house's exit must be a two-way door.\r\n");
return;
}
/* third arg: player's name */
one_argument(arg, arg1);
if (!*arg1) {
send_to_char(ch, "%s", HCONTROL_FORMAT);
return;
}
if ((owner = get_id_by_name(arg1)) < 0) {
send_to_char(ch, "Unknown player '%s'.\r\n", arg1);
return;
}
temp_house.mode = HOUSE_PRIVATE;
temp_house.vnum = virt_house;
temp_house.atrium = virt_atrium;
temp_house.exit_num = exit_num;
temp_house.built_on = time(0);
temp_house.last_payment = 0;
temp_house.owner = owner;
temp_house.num_of_guests = 0;
house_control[num_of_houses++] = temp_house;
SET_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE);
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
House_crashsave(virt_house);
send_to_char(ch, "House built. Mazel tov!\r\n");
House_save_control();
}
void hcontrol_destroy_house(struct char_data *ch, char *arg)
{
int i, j;
room_rnum real_atrium, real_house;
if (!*arg) {
send_to_char(ch, "%s", HCONTROL_FORMAT);
return;
}
if ((i = find_house(atoi(arg))) == NOWHERE) {
send_to_char(ch, "Unknown house.\r\n");
return;
}
if ((real_atrium = real_room(house_control[i].atrium)) == NOWHERE)
log("SYSERR: House %d had invalid atrium %d!", atoi(arg), house_control[i].atrium);
else
REMOVE_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
if ((real_house = real_room(house_control[i].vnum)) == NOWHERE)
log("SYSERR: House %d had invalid vnum %d!", atoi(arg), house_control[i].vnum);
else
REMOVE_BIT(ROOM_FLAGS(real_house), ROOM_HOUSE | ROOM_PRIVATE | ROOM_HOUSE_CRASH);
House_delete_file(house_control[i].vnum);
for (j = i; j < num_of_houses - 1; j++)
house_control[j] = house_control[j + 1];
num_of_houses--;
send_to_char(ch, "House deleted.\r\n");
House_save_control();
/*
* Now, reset the ROOM_ATRIUM flag on all existing houses' atriums,
* just in case the house we just deleted shared an atrium with another
* house. --JE 9/19/94
*/
for (i = 0; i < num_of_houses; i++)
if ((real_atrium = real_room(house_control[i].atrium)) != NOWHERE)
SET_BIT(ROOM_FLAGS(real_atrium), ROOM_ATRIUM);
}
void hcontrol_pay_house(struct char_data *ch, char *arg)
{
int i;
if (!*arg)
send_to_char(ch, "%s", HCONTROL_FORMAT);
else if ((i = find_house(atoi(arg))) == NOWHERE)
send_to_char(ch, "Unknown house.\r\n");
else {
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "Payment for house %s collected by %s.", arg, GET_NAME(ch));
house_control[i].last_payment = time(0);
House_save_control();
send_to_char(ch, "Payment recorded.\r\n");
}
}
/* The hcontrol command itself, used by imms to create/destroy houses */
ACMD(do_hcontrol)
{
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
half_chop(argument, arg1, arg2);
if (is_abbrev(arg1, "build"))
hcontrol_build_house(ch, arg2);
else if (is_abbrev(arg1, "destroy"))
hcontrol_destroy_house(ch, arg2);
else if (is_abbrev(arg1, "pay"))
hcontrol_pay_house(ch, arg2);
else if (is_abbrev(arg1, "show"))
hcontrol_list_houses(ch);
else
send_to_char(ch, "%s", HCONTROL_FORMAT);
}
/* The house command, used by mortal house owners to assign guests */
ACMD(do_house)
{
char arg[MAX_INPUT_LENGTH];
int i, j, id;
one_argument(argument, arg);
if (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOUSE))
send_to_char(ch, "You must be in your house to set guests.\r\n");
else if ((i = find_house(GET_ROOM_VNUM(IN_ROOM(ch)))) == NOWHERE)
send_to_char(ch, "Um.. this house seems to be screwed up.\r\n");
else if (GET_IDNUM(ch) != house_control[i].owner)
send_to_char(ch, "Only the primary owner can set guests.\r\n");
else if (!*arg)
House_list_guests(ch, i, FALSE);
else if ((id = get_id_by_name(arg)) < 0)
send_to_char(ch, "No such player.\r\n");
else if (id == GET_IDNUM(ch))
send_to_char(ch, "It's your house!\r\n");
else {
for (j = 0; j < house_control[i].num_of_guests; j++)
if (house_control[i].guests[j] == id) {
for (; j < house_control[i].num_of_guests; j++)
house_control[i].guests[j] = house_control[i].guests[j + 1];
house_control[i].num_of_guests--;
House_save_control();
send_to_char(ch, "Guest deleted.\r\n");
return;
}
if (house_control[i].num_of_guests == MAX_GUESTS) {
send_to_char(ch, "You have too many guests.\r\n");
return;
}
j = house_control[i].num_of_guests++;
house_control[i].guests[j] = id;
House_save_control();
send_to_char(ch, "Guest added.\r\n");
}
}
/* Misc. administrative functions */
/* crash-save all the houses */
void House_save_all(void)
{
int i;
room_rnum real_house;
for (i = 0; i < num_of_houses; i++)
if ((real_house = real_room(house_control[i].vnum)) != NOWHERE)
if (ROOM_FLAGGED(real_house, ROOM_HOUSE_CRASH))
House_crashsave(house_control[i].vnum);
}
/* note: arg passed must be house vnum, so there. */
int House_can_enter(struct char_data *ch, room_vnum house)
{
int i, j;
if (GET_LEVEL(ch) >= LVL_GRGOD || (i = find_house(house)) == NOWHERE)
return (1);
switch (house_control[i].mode) {
case HOUSE_PRIVATE:
if (GET_IDNUM(ch) == house_control[i].owner)
return (1);
for (j = 0; j < house_control[i].num_of_guests; j++)
if (GET_IDNUM(ch) == house_control[i].guests[j])
return (1);
}
return (0);
}
void House_list_guests(struct char_data *ch, int i, int quiet)
{
int j, num_printed;
char *temp;
if (house_control[i].num_of_guests == 0) {
if (!quiet)
send_to_char(ch, " Guests: None\r\n");
return;
}
send_to_char(ch, " Guests: ");
for (num_printed = j = 0; j < house_control[i].num_of_guests; j++) {
/* Avoid <UNDEF>. -gg 6/21/98 */
if ((temp = get_name_by_id(house_control[i].guests[j])) == NULL)
continue;
num_printed++;
send_to_char(ch, "%c%s ", UPPER(*temp), temp + 1);
}
if (num_printed == 0)
send_to_char(ch, "all dead");
send_to_char(ch, "\r\n");
}

38
src/house.h Normal file
View file

@ -0,0 +1,38 @@
#define MAX_HOUSES 100
#define MAX_GUESTS 10
#define HOUSE_PRIVATE 0
struct house_control_rec {
room_vnum vnum; /* vnum of this house */
room_vnum atrium; /* vnum of atrium */
sh_int exit_num; /* direction of house's exit */
time_t built_on; /* date this house was built */
int mode; /* mode of ownership */
long owner; /* idnum of house's owner */
int num_of_guests; /* how many guests for house */
long guests[MAX_GUESTS]; /* idnums of house's guests */
time_t last_payment; /* date of last house payment */
long spare0;
long spare1;
long spare2;
long spare3;
long spare4;
long spare5;
long spare6;
long spare7;
};
#define TOROOM(room, dir) (world[room].dir_option[dir] ? \
world[room].dir_option[dir]->to_room : NOWHERE)
void House_listrent(struct char_data *ch, room_vnum vnum);
void House_boot(void);
void House_save_all(void);
int House_can_enter(struct char_data *ch, room_vnum house);
void House_crashsave(room_vnum vnum);
void House_list_guests(struct char_data *ch, int i, int quiet);

4
src/htmlh-head Normal file
View file

@ -0,0 +1,4 @@
<html>
<body>
<pre>
<a name="file">

3
src/htmlh-tail Normal file
View file

@ -0,0 +1,3 @@
</pre>
</body>
</html>

716
src/improved-edit.c Normal file
View file

@ -0,0 +1,716 @@
/*
improved-edit.c Routines specific to the improved editor.
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "comm.h"
#include "interpreter.h"
#include "improved-edit.h"
int format_script(struct descriptor_data *d);
void send_editor_help(struct descriptor_data *d)
{
if (using_improved_editor)
write_to_output(d, "Instructions: /s to save, /h for more options.\r\n");
else
write_to_output(d, "Instructions: Type @ on a line by itself to end.\r\n");
}
#if CONFIG_IMPROVED_EDITOR
int improved_editor_execute(struct descriptor_data *d, char *str)
{
char actions[MAX_INPUT_LENGTH];
if (*str != '/')
return STRINGADD_OK;
strncpy(actions, str + 2, sizeof(actions) - 1);
actions[sizeof(actions) - 1] = '\0';
*str = '\0';
switch (str[1]) {
case 'a':
return STRINGADD_ABORT;
case 'c':
if (*(d->str)) {
free(*d->str);
*(d->str) = NULL;
write_to_output(d, "Current buffer cleared.\r\n");
} else
write_to_output(d, "Current buffer empty.\r\n");
break;
case 'd':
parse_action(PARSE_DELETE, actions, d);
break;
case 'e':
parse_action(PARSE_EDIT, actions, d);
break;
case 'f':
if (*(d->str))
parse_action(PARSE_FORMAT, actions, d);
else
write_to_output(d, "Current buffer empty.\r\n");
break;
case 'i':
if (*(d->str))
parse_action(PARSE_INSERT, actions, d);
else
write_to_output(d, "Current buffer empty.\r\n");
break;
case 'h':
parse_action(PARSE_HELP, actions, d);
break;
case 'l':
if (*d->str)
parse_action(PARSE_LIST_NORM, actions, d);
else
write_to_output(d, "Current buffer empty.\r\n");
break;
case 'n':
if (*d->str)
parse_action(PARSE_LIST_NUM, actions, d);
else
write_to_output(d, "Current buffer empty.\r\n");
break;
case 'r':
parse_action(PARSE_REPLACE, actions, d);
break;
case 's':
return STRINGADD_SAVE;
default:
write_to_output(d, "Invalid option.\r\n");
break;
}
return STRINGADD_ACTION;
}
/*
* Handle some editor commands.
*/
void parse_action(int command, char *string, struct descriptor_data *d)
{
int indent = 0, rep_all = 0, flags = 0, replaced, i, line_low, line_high, j = 0;
unsigned int total_len;
char *s, *t, temp;
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
switch (command) {
case PARSE_HELP:
write_to_output(d,
"Editor command formats: /<letter>\r\n\r\n"
"/a - aborts editor\r\n"
"/c - clears buffer\r\n"
"/d# - deletes a line #\r\n"
"/e# <text> - changes the line at # with <text>\r\n"
"/f - formats text\r\n"
"/fi - indented formatting of text\r\n"
"/h - list text editor commands\r\n"
"/i# <text> - inserts <text> before line #\r\n"
"/l - lists buffer\r\n"
"/n - lists buffer with line numbers\r\n"
"/r 'a' 'b' - replace 1st occurance of text <a> in buffer with text <b>\r\n"
"/ra 'a' 'b'- replace all occurances of text <a> within buffer with text <b>\r\n"
" usage: /r[a] 'pattern' 'replacement'\r\n"
"/s - saves text\r\n");
break;
case PARSE_FORMAT:
if (STATE(d) == CON_TRIGEDIT) {
write_to_output(d, "Script %sformatted.\r\n", format_script(d) ? "": "not ");
return;
}
while (isalpha(string[j]) && j < 2) {
if (string[j++] == 'i' && !indent) {
indent = TRUE;
flags += FORMAT_INDENT;
}
}
switch (sscanf((indent ? string + 1 : string), " %d - %d ", &line_low, &line_high))
{
case -1:
case 0:
line_low = 1;
line_high = 999999;
break;
case 1:
line_high = line_low;
break;
case 2:
if (line_high < line_low) {
write_to_output(d, "That range is invalid.\\r\\n");
return;
}
break;
}
/* in case line_low is negative or zero */
line_low = MAX(1, line_low);
format_text(d->str, flags, d, d->max_str, line_low, line_high);
write_to_output(d, "Text formatted with%s indent.\r\n", (indent ? "" : "out"));
break;
case PARSE_REPLACE:
while (isalpha(string[j]) && j < 2)
if (string[j++] == 'a' && !indent)
rep_all = 1;
if ((s = strtok(string, "'")) == NULL) {
write_to_output(d, "Invalid format.\r\n");
return;
} else if ((s = strtok(NULL, "'")) == NULL) {
write_to_output(d, "Target string must be enclosed in single quotes.\r\n");
return;
} else if ((t = strtok(NULL, "'")) == NULL) {
write_to_output(d, "No replacement string.\r\n");
return;
} else if ((t = strtok(NULL, "'")) == NULL) {
write_to_output(d, "Replacement string must be enclosed in single quotes.\r\n");
return;
/*wb's fix for empty buffer replacement crashing */
} else if ((!*d->str)) {
return;
} else if ((total_len = ((strlen(t) - strlen(s)) + strlen(*d->str))) <= d->max_str) {
if ((replaced = replace_str(d->str, s, t, rep_all, d->max_str)) > 0) {
write_to_output(d, "Replaced %d occurance%sof '%s' with '%s'.\r\n", replaced, ((replaced != 1) ? "s " : " "), s, t);
} else if (replaced == 0) {
write_to_output(d, "String '%s' not found.\r\n", s);
} else
write_to_output(d, "ERROR: Replacement string causes buffer overflow, aborted replace.\r\n");
} else
write_to_output(d, "Not enough space left in buffer.\r\n");
break;
case PARSE_DELETE:
switch (sscanf(string, " %d - %d ", &line_low, &line_high)) {
case 0:
write_to_output(d, "You must specify a line number or range to delete.\r\n");
return;
case 1:
line_high = line_low;
break;
case 2:
if (line_high < line_low) {
write_to_output(d, "That range is invalid.\r\n");
return;
}
break;
}
i = 1;
total_len = 1;
if ((s = *d->str) == NULL) {
write_to_output(d, "Buffer is empty.\r\n");
return;
} else if (line_low > 0) {
while (s && i < line_low)
if ((s = strchr(s, '\n')) != NULL) {
i++;
s++;
}
if (s == NULL || i < line_low) {
write_to_output(d, "Line(s) out of range; not deleting.\r\n");
return;
}
t = s;
while (s && i < line_high)
if ((s = strchr(s, '\n')) != NULL) {
i++;
total_len++;
s++;
}
if (s && (s = strchr(s, '\n')) != NULL) {
while (*(++s))
*(t++) = *s;
} else
total_len--;
*t = '\0';
RECREATE(*d->str, char, strlen(*d->str) + 3);
write_to_output(d, "%d line%sdeleted.\r\n", total_len, (total_len != 1 ? "s " : " "));
} else {
write_to_output(d, "Invalid, line numbers to delete must be higher than 0.\r\n");
return;
}
break;
case PARSE_LIST_NORM:
/*
* Note: Rv's buf, buf1, buf2, and arg variables are defined to 32k so
* they are probly ok for what to do here.
*/
*buf = '\0';
if (*string)
switch (sscanf(string, " %d - %d ", &line_low, &line_high)) {
case 0:
line_low = 1;
line_high = 999999;
break;
case 1:
line_high = line_low;
break;
} else {
line_low = 1;
line_high = 999999;
}
if (line_low < 1) {
write_to_output(d, "Line numbers must be greater than 0.\r\n");
return;
} else if (line_high < line_low) {
write_to_output(d, "That range is invalid.\r\n");
return;
}
*buf = '\0';
if (line_high < 999999 || line_low > 1)
sprintf(buf, "Current buffer range [%d - %d]:\r\n", line_low, line_high);
i = 1;
total_len = 0;
s = *d->str;
while (s && (i < line_low))
if ((s = strchr(s, '\n')) != NULL) {
i++;
s++;
}
if (i < line_low || s == NULL) {
write_to_output(d, "Line(s) out of range; no buffer listing.\r\n");
return;
}
t = s;
while (s && i <= line_high)
if ((s = strchr(s, '\n')) != NULL) {
i++;
total_len++;
s++;
}
if (s) {
temp = *s;
*s = '\0';
strcat(buf, t);
*s = temp;
} else
strcat(buf, t);
/*
* This is kind of annoying...but some people like it.
*/
sprintf(buf + strlen(buf), "\r\n%d line%sshown.\r\n", total_len, (total_len != 1) ? "s " : " ");
page_string(d, buf, TRUE);
break;
case PARSE_LIST_NUM:
/*
* Note: Rv's buf, buf1, buf2, and arg variables are defined to 32k so
* they are probly ok for what to do here.
*/
*buf = '\0';
if (*string)
switch (sscanf(string, " %d - %d ", &line_low, &line_high)) {
case 0:
line_low = 1;
line_high = 999999;
break;
case 1:
line_high = line_low;
break;
} else {
line_low = 1;
line_high = 999999;
}
if (line_low < 1) {
write_to_output(d, "Line numbers must be greater than 0.\r\n");
return;
}
if (line_high < line_low) {
write_to_output(d, "That range is invalid.\r\n");
return;
}
*buf = '\0';
i = 1;
total_len = 0;
s = *d->str;
while (s && i < line_low)
if ((s = strchr(s, '\n')) != NULL) {
i++;
s++;
}
if (i < line_low || s == NULL) {
write_to_output(d, "Line(s) out of range; no buffer listing.\r\n");
return;
}
t = s;
while (s && i <= line_high)
if ((s = strchr(s, '\n')) != NULL) {
i++;
total_len++;
s++;
temp = *s;
*s = '\0';
sprintf(buf, "%s%4d: ", buf, (i - 1));
strcat(buf, t);
*s = temp;
t = s;
}
if (s && t) {
temp = *s;
*s = '\0';
strcat(buf, t);
*s = temp;
} else if (t)
strcat(buf, t);
page_string(d, buf, TRUE);
break;
case PARSE_INSERT:
half_chop(string, buf, buf2);
if (*buf == '\0') {
write_to_output(d, "You must specify a line number before which to insert text.\r\n");
return;
}
line_low = atoi(buf);
strcat(buf2, "\r\n");
i = 1;
*buf = '\0';
if ((s = *d->str) == NULL) {
write_to_output(d, "Buffer is empty, nowhere to insert.\r\n");
return;
}
if (line_low > 0) {
while (s && (i < line_low))
if ((s = strchr(s, '\n')) != NULL) {
i++;
s++;
}
if (i < line_low || s == NULL) {
write_to_output(d, "Line number out of range; insert aborted.\r\n");
return;
}
temp = *s;
*s = '\0';
if ((strlen(*d->str) + strlen(buf2) + strlen(s + 1) + 3) > d->max_str) {
*s = temp;
write_to_output(d, "Insert text pushes buffer over maximum size, insert aborted.\r\n");
return;
}
if (*d->str && **d->str)
strcat(buf, *d->str);
*s = temp;
strcat(buf, buf2);
if (s && *s)
strcat(buf, s);
RECREATE(*d->str, char, strlen(buf) + 3);
strcpy(*d->str, buf);
write_to_output(d, "Line inserted.\r\n");
} else {
write_to_output(d, "Line number must be higher than 0.\r\n");
return;
}
break;
case PARSE_EDIT:
half_chop(string, buf, buf2);
if (*buf == '\0') {
write_to_output(d, "You must specify a line number at which to change text.\r\n");
return;
}
line_low = atoi(buf);
strcat(buf2, "\r\n");
i = 1;
*buf = '\0';
if ((s = *d->str) == NULL) {
write_to_output(d, "Buffer is empty, nothing to change.\r\n");
return;
}
if (line_low > 0) {
/*
* Loop through the text counting \n characters until we get to the line.
*/
while (s && i < line_low)
if ((s = strchr(s, '\n')) != NULL) {
i++;
s++;
}
/*
* Make sure that there was a THAT line in the text.
*/
if (s == NULL || i < line_low) {
write_to_output(d, "Line number out of range; change aborted.\r\n");
return;
}
/*
* If s is the same as *d->str that means I'm at the beginning of the
* message text and I don't need to put that into the changed buffer.
*/
if (s != *d->str) {
/*
* First things first .. we get this part into the buffer.
*/
temp = *s;
*s = '\0';
/*
* Put the first 'good' half of the text into storage.
*/
strcat(buf, *d->str);
*s = temp;
}
/*
* Put the new 'good' line into place.
*/
strcat(buf, buf2);
if ((s = strchr(s, '\n')) != NULL) {
/*
* This means that we are at the END of the line, we want out of
* there, but we want s to point to the beginning of the line
* AFTER the line we want edited
*/
s++;
/*
* Now put the last 'good' half of buffer into storage.
*/
strcat(buf, s);
}
/*
* Check for buffer overflow.
*/
if (strlen(buf) > d->max_str) {
write_to_output(d, "Change causes new length to exceed buffer maximum size, aborted.\r\n");
return;
}
/*
* Change the size of the REAL buffer to fit the new text.
*/
RECREATE(*d->str, char, strlen(buf) + 3);
strcpy(*d->str, buf);
write_to_output(d, "Line changed.\r\n");
} else {
write_to_output(d, "Line number must be higher than 0.\r\n");
return;
}
break;
default:
write_to_output(d, "Invalid option.\r\n");
mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: invalid command passed to parse_action");
return;
}
}
/*
* Re-formats message type formatted char *.
* (for strings edited with d->str) (mostly olc and mail)
*/
int format_text(char **ptr_string, int mode, struct descriptor_data *d, unsigned int maxlen, int low, int high)
{
int line_chars, cap_next = TRUE, cap_next_next = FALSE, color_chars = 0, i, pass_line = 0;
char *flow, *start = NULL, temp;
char formatted[MAX_STRING_LENGTH] = "";
/* Fix memory overrun. */
if (d->max_str > MAX_STRING_LENGTH) {
log("SYSERR: format_text: max_str is greater than buffer size.");
return 0;
}
/* XXX: Want to make sure the string doesn't grow either... */
if ((flow = *ptr_string) == NULL)
return 0;
char str[MAX_STRING_LENGTH];
strcpy(str, flow);
for (i = 0; i < low - 1; i++) {
start = strtok(str, "\n");
if (!start) {
write_to_output(d, "There aren't that many lines!\r\n");
return 0;
}
strcat(formatted, strcat(start, "\n"));
flow = strstr(flow, "\n");
strcpy(str, ++flow);
}
if (IS_SET(mode, FORMAT_INDENT)) {
strcat(formatted, " ");
line_chars = 3;
} else {
line_chars = 0;
}
while (*flow && i < high) {
while (*flow && strchr("\n\r\f\t\v ", *flow)) {
if (*flow == '\n' && !pass_line)
if (i++ >= high) {
pass_line = 1;
break;
}
flow++;
}
if (*flow) {
start = flow;
while (*flow && !strchr("\n\r\f\t\v .?!", *flow)) {
if (*flow == '@') {
if (*(flow + 1) == '@')
color_chars++;
else
color_chars += 2;
flow++;
}
flow++;
}
if (cap_next_next) {
cap_next_next = FALSE;
cap_next = TRUE;
}
/*
* This is so that if we stopped on a sentence .. we move off the
* sentence delimiter.
*/
while (strchr(".!?", *flow)) {
cap_next_next = TRUE;
flow++;
}
/*
* special case: if we're at the end of the last line, and the last
* character is a delimiter, the flow++ above will have *flow pointing
* to the \r (or \n) character after the delimiter. Thus *flow will
* be non-null, and an extra (blank) line might be added erroneously.
* We fix it by skipping the newline characters in between.
*
* Welcor 04/04
*/
if (strchr("\n\r", *flow)) {
*flow = '\0'; /* terminate 'start' string */
flow++; /* we know this is safe */
if (*flow == '\n' && i++ >= high)
pass_line = 1;
while (*flow && strchr("\n\r", *flow) && !pass_line) {
flow++; /* skip to next non-delimiter */
if (*flow == '\n' && i++ >= high)
pass_line = 1;
}
temp = *flow; /* save this char */
} else {
temp = *flow;
*flow = '\0';
}
if (line_chars + strlen(start) + 1 - color_chars > PAGE_WIDTH) {
strcat(formatted, "\r\n");
line_chars = 0;
color_chars = count_color_chars(start);
}
if (!cap_next) {
if (line_chars > 0) {
strcat(formatted, " ");
line_chars++;
}
} else {
cap_next = FALSE;
CAP(start);
}
line_chars += strlen(start);
strcat(formatted, start);
*flow = temp;
}
if (cap_next_next && *flow) {
if (line_chars + 3 - color_chars > PAGE_WIDTH) {
strcat(formatted, "\r\n");
line_chars = 0;
color_chars = count_color_chars(start);
} else if (*flow == '\"' || *flow == '\'') {
char buf[MAX_STRING_LENGTH];
sprintf(buf, "%c ", *flow);
strcat(formatted, buf);
flow++;
line_chars++;
} else {
strcat(formatted, " ");
line_chars += 2;
}
}
}
if (*flow)
strcat(formatted, "\r\n");
strcat(formatted, flow);
if (!*flow)
strcat(formatted, "\r\n");
if (strlen(formatted) + 1 > maxlen)
formatted[maxlen - 1] = '\0';
RECREATE(*ptr_string, char, MIN(maxlen, strlen(formatted) + 1));
strcpy(*ptr_string, formatted);
return 1;
}
int replace_str(char **string, char *pattern, char *replacement, int rep_all, unsigned int max_size)
{
char *replace_buffer = NULL;
char *flow, *jetsam, temp;
int len, i;
if ((strlen(*string) - strlen(pattern)) + strlen(replacement) > max_size)
return -1;
CREATE(replace_buffer, char, max_size);
i = 0;
jetsam = *string;
flow = *string;
*replace_buffer = '\0';
if (rep_all) {
while ((flow = (char *)strstr(flow, pattern)) != NULL) {
i++;
temp = *flow;
*flow = '\0';
if ((strlen(replace_buffer) + strlen(jetsam) + strlen(replacement)) > max_size) {
i = -1;
break;
}
strcat(replace_buffer, jetsam);
strcat(replace_buffer, replacement);
*flow = temp;
flow += strlen(pattern);
jetsam = flow;
}
strcat(replace_buffer, jetsam);
} else {
if ((flow = (char *)strstr(*string, pattern)) != NULL) {
i++;
flow += strlen(pattern);
len = ((char *)flow - (char *)*string) - strlen(pattern);
strncpy(replace_buffer, *string, len);
strcat(replace_buffer, replacement);
strcat(replace_buffer, flow);
}
}
if (i <= 0)
return 0;
else {
RECREATE(*string, char, strlen(replace_buffer) + 3);
strcpy(*string, replace_buffer);
}
free(replace_buffer);
return i;
}
#endif

37
src/improved-edit.h Normal file
View file

@ -0,0 +1,37 @@
/*
* This is here to allow different code for the basic and improved editor.
* If do not wish to use the improved editor, put #if 0 below, otherwise
* you should leave the setting at #if 1.
*/
#define CONFIG_IMPROVED_EDITOR 1
#define using_improved_editor CONFIG_IMPROVED_EDITOR
void parse_action(int command, char *string, struct descriptor_data *d);
int improved_editor_execute(struct descriptor_data *d, char *string);
int format_text(char **ptr_string, int mode, struct descriptor_data *d, unsigned int maxlen, int low, int high);
int replace_str(char **string, char *pattern, char *replacement, int rep_all, unsigned int max_size);
void send_editor_help(struct descriptor_data *d);
/*
* Action modes for parse_action().
*/
#define PARSE_FORMAT 0
#define PARSE_REPLACE 1
#define PARSE_HELP 2
#define PARSE_DELETE 3
#define PARSE_INSERT 4
#define PARSE_LIST_NORM 5
#define PARSE_LIST_NUM 6
#define PARSE_EDIT 7
/*
* Defines for the action variable.
*/
#define STRINGADD_OK 0 /* Just keep adding text. */
#define STRINGADD_SAVE 1 /* Save current text. */
#define STRINGADD_ABORT 2 /* Abort edit, restore old text. */
#define STRINGADD_ACTION 4 /* Editor action, don't append \r\n. */
/* Settings for formatter. */
#define FORMAT_INDENT (1 << 0)

1821
src/interpreter.c Normal file

File diff suppressed because it is too large Load diff

242
src/interpreter.h Normal file
View file

@ -0,0 +1,242 @@
/* ************************************************************************
* File: interpreter.h Part of CircleMUD *
* Usage: header file: public procs, macro defs, subcommand defines *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#define ACMD(name) \
void name(struct char_data *ch, char *argument, int cmd, int subcmd)
ACMD(do_move);
#define 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)
void command_interpreter(struct char_data *ch, char *argument);
int search_block(char *arg, const char **list, int exact);
char lower( char c );
char *one_argument(char *argument, char *first_arg);
char *one_word(char *argument, char *first_arg);
char *any_one_arg(char *argument, char *first_arg);
char *two_arguments(char *argument, char *first_arg, char *second_arg);
int fill_word(char *argument);
void half_chop(char *string, char *arg1, char *arg2);
void nanny(struct descriptor_data *d, char *arg);
int is_abbrev(const char *arg1, const char *arg2);
int is_number(const char *str);
int find_command(const char *command);
void skip_spaces(char **string);
char *delete_doubledollar(char *string);
/* for compatibility with 2.20: */
#define argument_interpreter(a, b, c) two_arguments(a, b, c)
/* WARNING: if you have added diagonal directions and have them at the
* beginning of the command list.. change this value to 11 or 15 (depending) */
/* reserve these commands to come straight from the cmd list then start
* sorting */
#define RESERVE_CMDS 7
struct command_info {
const char *command;
const char *sort_as;
byte minimum_position;
void (*command_pointer)
(struct char_data *ch, char *argument, int cmd, int subcmd);
sh_int minimum_level;
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
/*
* Alert! Changed from 'struct alias' to 'struct alias_data' in bpl15
* because a Windows 95 compiler gives a warning about it having similiar
* named member.
*/
struct alias_data {
char *alias;
char *replacement;
int type;
struct alias_data *next;
};
#define ALIAS_SIMPLE 0
#define ALIAS_COMPLEX 1
#define ALIAS_SEP_CHAR ';'
#define ALIAS_VAR_CHAR '$'
#define ALIAS_GLOB_CHAR '*'
/*
* SUBCOMMANDS
* You can define these however you want to, and the definitions of the
* subcommands are independent from function to function.
*/
/* 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 */
#define SCMD_INFO 0
#define SCMD_HANDBOOK 1
#define SCMD_CREDITS 2
#define SCMD_NEWS 3
#define SCMD_WIZLIST 4
#define SCMD_POLICIES 5
#define SCMD_VERSION 6
#define SCMD_IMMLIST 7
#define SCMD_MOTD 8
#define SCMD_IMOTD 9
#define SCMD_CLEAR 10
#define SCMD_WHOAMI 11
/* do_gen_tog */
#define SCMD_NOSUMMON 0
#define SCMD_NOHASSLE 1
#define SCMD_BRIEF 2
#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_ROOMFLAGS 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
/* do_wizutil */
#define SCMD_REROLL 0
#define SCMD_PARDON 1
#define SCMD_NOTITLE 2
#define SCMD_SQUELCH 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_olc */
#define SCMD_OASIS_REDIT 0
#define SCMD_OASIS_OEDIT 1
#define SCMD_OASIS_ZEDIT 2
#define SCMD_OASIS_MEDIT 3
#define SCMD_OASIS_SEDIT 4
#define SCMD_OASIS_CEDIT 5
#define SCMD_OLC_SAVEINFO 7
#define SCMD_OASIS_RLIST 8
#define SCMD_OASIS_MLIST 9
#define SCMD_OASIS_OLIST 10
#define SCMD_OASIS_SLIST 11
#define SCMD_OASIS_ZLIST 12
#define SCMD_OASIS_TRIGEDIT 13
#define SCMD_OASIS_AEDIT 14
#define SCMD_OASIS_TLIST 15
#define SCMD_OASIS_LINKS 16
#define SCMD_OASIS_HEDIT 17
/* do_last */
#define SCMD_LIST_ALL 1

21
src/licheck Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
cat << EOF
CircleMUD is freeware (it doesn't cost anything), but it is copyrighted
and has a license. You must read and agree to abide by the license before
using CircleMUD.
This message will only appear once (the first time you compile the server),
but is contained in the file doc/license.txt if you'd like to refer back to
it in the future.
Press return to read the license.
EOF
read temp
cat ../doc/license.txt | $1
echo
echo Press return or Q to ACCEPT the terms of this license.
echo Press Control-C if you DO NOT ACCEPT the terms of this license.
read temp
touch .accepted

475
src/limits.c Normal file
View file

@ -0,0 +1,475 @@
/* ************************************************************************
* File: limits.c Part of CircleMUD *
* Usage: limits & gain funcs for HMV, exp, hunger/thirst, idle time *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "spells.h"
#include "comm.h"
#include "db.h"
#include "handler.h"
#include "interpreter.h"
#include "dg_scripts.h"
/* 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);
/* When age < 15 return the value p0 */
/* When age in 15..29 calculate the line between p1 & p2 */
/* When age in 30..44 calculate the line between p2 & p3 */
/* When age in 45..59 calculate the line between p3 & p4 */
/* When age in 60..79 calculate the line between p4 & p5 */
/* 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)
{
if (grafage < 15)
return (p0); /* < 15 */
else if (grafage <= 29)
return (p1 + (((grafage - 15) * (p2 - p1)) / 15)); /* 15..29 */
else if (grafage <= 44)
return (p2 + (((grafage - 30) * (p3 - p2)) / 15)); /* 30..44 */
else if (grafage <= 59)
return (p3 + (((grafage - 45) * (p4 - p3)) / 15)); /* 45..59 */
else if (grafage <= 79)
return (p4 + (((grafage - 60) * (p5 - p4)) / 20)); /* 60..79 */
else
return (p6); /* >= 80 */
}
/*
* The hit_limit, mana_limit, and move_limit functions are gone. They
* added an unnecessary level of complexity to the internal structure,
* weren't particularly useful, and led to some annoying bugs. From the
* players' point of view, the only difference the removal of these
* functions will make is that a character's age will now only affect
* the HMV gain per tick, and _not_ the HMV maximums.
*/
/* manapoint gain pr. game hour */
int mana_gain(struct char_data *ch)
{
int gain;
if (IS_NPC(ch)) {
/* Neat and fast */
gain = GET_LEVEL(ch);
} else {
gain = graf(age(ch)->year, 4, 8, 12, 16, 12, 10, 8);
/* Class calculations */
/* Skill/Spell calculations */
/* Position calculations */
switch (GET_POS(ch)) {
case POS_SLEEPING:
gain *= 2;
break;
case POS_RESTING:
gain += (gain / 2); /* Divide by 2 */
break;
case POS_SITTING:
gain += (gain / 4); /* Divide by 4 */
break;
}
if (IS_MAGIC_USER(ch) || IS_CLERIC(ch))
gain *= 2;
if ((GET_COND(ch, FULL) == 0) || (GET_COND(ch, THIRST) == 0))
gain /= 4;
}
if (AFF_FLAGGED(ch, AFF_POISON))
gain /= 4;
return (gain);
}
/* Hitpoint gain pr. game hour */
int hit_gain(struct char_data *ch)
{
int gain;
if (IS_NPC(ch)) {
/* Neat and fast */
gain = GET_LEVEL(ch);
} else {
gain = graf(age(ch)->year, 8, 12, 20, 32, 16, 10, 4);
/* Class/Level calculations */
/* Skill/Spell calculations */
/* Position calculations */
switch (GET_POS(ch)) {
case POS_SLEEPING:
gain += (gain / 2); /* Divide by 2 */
break;
case POS_RESTING:
gain += (gain / 4); /* Divide by 4 */
break;
case POS_SITTING:
gain += (gain / 8); /* Divide by 8 */
break;
}
if (IS_MAGIC_USER(ch) || IS_CLERIC(ch))
gain /= 2; /* Ouch. */
if ((GET_COND(ch, FULL) == 0) || (GET_COND(ch, THIRST) == 0))
gain /= 4;
}
if (AFF_FLAGGED(ch, AFF_POISON))
gain /= 4;
return (gain);
}
/* move gain pr. game hour */
int move_gain(struct char_data *ch)
{
int gain;
if (IS_NPC(ch)) {
/* Neat and fast */
gain = GET_LEVEL(ch);
} else {
gain = graf(age(ch)->year, 16, 20, 24, 20, 16, 12, 10);
/* Class/Level calculations */
/* Skill/Spell calculations */
/* Position calculations */
switch (GET_POS(ch)) {
case POS_SLEEPING:
gain += (gain / 2); /* Divide by 2 */
break;
case POS_RESTING:
gain += (gain / 4); /* Divide by 4 */
break;
case POS_SITTING:
gain += (gain / 8); /* Divide by 8 */
break;
}
if ((GET_COND(ch, FULL) == 0) || (GET_COND(ch, THIRST) == 0))
gain /= 4;
}
if (AFF_FLAGGED(ch, AFF_POISON))
gain /= 4;
return (gain);
}
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)
free(GET_TITLE(ch));
GET_TITLE(ch) = strdup(title);
}
void run_autowiz(void)
{
#if defined(CIRCLE_UNIX) || defined(CIRCLE_WINDOWS)
if (CONFIG_USE_AUTOWIZ) {
size_t res;
char buf[256];
#if defined(CIRCLE_UNIX)
res = snprintf(buf, sizeof(buf), "nice ../bin/autowiz %d %s %d %s %d &",
CONFIG_MIN_WIZLIST_LEV, WIZLIST_FILE, LVL_IMMORT, IMMLIST_FILE, (int) getpid());
#elif defined(CIRCLE_WINDOWS)
res = snprintf(buf, sizeof(buf), "autowiz %d %s %d %s",
CONFIG_MIN_WIZLIST_LEV, WIZLIST_FILE, LVL_IMMORT, IMMLIST_FILE);
#endif /* CIRCLE_WINDOWS */
/* Abusing signed -> unsigned conversion to avoid '-1' check. */
if (res < sizeof(buf)) {
mudlog(CMP, LVL_IMMORT, FALSE, "Initiating autowiz.");
system(buf);
reboot_wizlists();
} else
log("Cannot run autowiz: command-line doesn't fit in buffer.");
}
#endif /* CIRCLE_UNIX || CIRCLE_WINDOWS */
}
void gain_exp(struct char_data *ch, int gain)
{
int is_altered = FALSE;
int num_levels = 0;
if (!IS_NPC(ch) && ((GET_LEVEL(ch) < 1 || GET_LEVEL(ch) >= LVL_IMMORT)))
return;
if (IS_NPC(ch)) {
GET_EXP(ch) += gain;
return;
}
if (gain > 0) {
gain = MIN(CONFIG_MAX_EXP_GAIN, gain); /* put a cap on the max gain per kill */
GET_EXP(ch) += gain;
while (GET_LEVEL(ch) < LVL_IMMORT - CONFIG_IMMORT_LEVEL_OK &&
GET_EXP(ch) >= level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1)) {
GET_LEVEL(ch) += 1;
num_levels++;
advance_level(ch);
is_altered = TRUE;
}
if (is_altered) {
mudlog(BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s advanced %d level%s to level %d.",
GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch));
if (num_levels == 1)
send_to_char(ch, "You rise a level!\r\n");
else
send_to_char(ch, "You rise %d levels!\r\n", num_levels);
set_title(ch, NULL);
if (GET_LEVEL(ch) >= LVL_IMMORT)
run_autowiz();
}
} else if (gain < 0) {
gain = MAX(-CONFIG_MAX_EXP_LOSS, gain); /* Cap max exp lost per death */
GET_EXP(ch) += gain;
if (GET_EXP(ch) < 0)
GET_EXP(ch) = 0;
}
}
void gain_exp_regardless(struct char_data *ch, int gain)
{
int is_altered = FALSE;
int num_levels = 0;
GET_EXP(ch) += gain;
if (GET_EXP(ch) < 0)
GET_EXP(ch) = 0;
if (!IS_NPC(ch)) {
while (GET_LEVEL(ch) < LVL_IMPL &&
GET_EXP(ch) >= level_exp(GET_CLASS(ch), GET_LEVEL(ch) + 1)) {
GET_LEVEL(ch) += 1;
num_levels++;
advance_level(ch);
is_altered = TRUE;
}
if (is_altered) {
mudlog(BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s advanced %d level%s to level %d.",
GET_NAME(ch), num_levels, num_levels == 1 ? "" : "s", GET_LEVEL(ch));
if (num_levels == 1)
send_to_char(ch, "You rise a level!\r\n");
else
send_to_char(ch, "You rise %d levels!\r\n", num_levels);
set_title(ch, NULL);
if (GET_LEVEL(ch) >= LVL_IMMORT)
run_autowiz();
}
}
}
void gain_condition(struct char_data *ch, int condition, int value)
{
bool intoxicated;
if (IS_NPC(ch) || GET_COND(ch, condition) == -1) /* No change */
return;
intoxicated = (GET_COND(ch, DRUNK) > 0);
GET_COND(ch, condition) += value;
GET_COND(ch, condition) = MAX(0, GET_COND(ch, condition));
GET_COND(ch, condition) = MIN(24, GET_COND(ch, condition));
if (GET_COND(ch, condition) || PLR_FLAGGED(ch, PLR_WRITING))
return;
switch (condition) {
case FULL:
send_to_char(ch, "You are hungry.\r\n");
break;
case THIRST:
send_to_char(ch, "You are thirsty.\r\n");
break;
case DRUNK:
if (intoxicated)
send_to_char(ch, "You are now sober.\r\n");
break;
default:
break;
}
}
void check_idling(struct char_data *ch)
{
if (++(ch->char_specials.timer) > CONFIG_IDLE_VOID) {
if (GET_WAS_IN(ch) == NOWHERE && IN_ROOM(ch) != NOWHERE) {
GET_WAS_IN(ch) = IN_ROOM(ch);
if (FIGHTING(ch)) {
stop_fighting(FIGHTING(ch));
stop_fighting(ch);
}
act("$n disappears into the void.", TRUE, ch, 0, 0, TO_ROOM);
send_to_char(ch, "You have been idle, and are pulled into a void.\r\n");
save_char(ch);
Crash_crashsave(ch);
char_from_room(ch);
char_to_room(ch, 1);
} else if (ch->char_specials.timer > CONFIG_IDLE_RENT_TIME) {
if (IN_ROOM(ch) != NOWHERE)
char_from_room(ch);
char_to_room(ch, 3);
if (ch->desc) {
STATE(ch->desc) = CON_DISCONNECT;
/*
* For the 'if (d->character)' test in close_socket().
* -gg 3/1/98 (Happy anniversary.)
*/
ch->desc->character = NULL;
ch->desc = NULL;
}
if (CONFIG_FREE_RENT)
Crash_rentsave(ch, 0);
else
Crash_idlesave(ch);
mudlog(CMP, LVL_GOD, TRUE, "%s force-rented and extracted (idle).", GET_NAME(ch));
add_llog_entry(ch, LAST_IDLEOUT);
extract_char(ch);
}
}
}
/* Update PCs, NPCs, and objects */
void point_update(void)
{
struct char_data *i, *next_char;
struct obj_data *j, *next_thing, *jj, *next_thing2;
/* characters */
for (i = character_list; i; i = next_char) {
next_char = i->next;
gain_condition(i, FULL, -1);
gain_condition(i, DRUNK, -1);
gain_condition(i, THIRST, -1);
if (GET_POS(i) >= POS_STUNNED) {
GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i));
GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i));
GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i));
if (AFF_FLAGGED(i, AFF_POISON))
if (damage(i, i, 2, SPELL_POISON) == -1)
continue; /* Oops, they died. -gg 6/24/98 */
if (GET_POS(i) <= POS_STUNNED)
update_pos(i);
} else if (GET_POS(i) == POS_INCAP) {
if (damage(i, i, 1, TYPE_SUFFERING) == -1)
continue;
} else if (GET_POS(i) == POS_MORTALLYW) {
if (damage(i, i, 2, TYPE_SUFFERING) == -1)
continue;
}
if (!IS_NPC(i)) {
update_char_objects(i);
if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL)
check_idling(i);
}
}
/* objects */
for (j = object_list; j; j = next_thing) {
next_thing = j->next; /* Next in object list */
/* If this is a corpse */
if (IS_CORPSE(j)) {
/* timer count down */
if (GET_OBJ_TIMER(j) > 0)
GET_OBJ_TIMER(j)--;
if (!GET_OBJ_TIMER(j)) {
if (j->carried_by)
act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
}
for (jj = j->contains; jj; jj = next_thing2) {
next_thing2 = jj->next_content; /* Next in inventory */
obj_from_obj(jj);
if (j->in_obj)
obj_to_obj(jj, j->in_obj);
else if (j->carried_by)
obj_to_room(jj, IN_ROOM(j->carried_by));
else if (IN_ROOM(j) != NOWHERE)
obj_to_room(jj, IN_ROOM(j));
else
core_dump();
}
extract_obj(j);
}
}
/* If the timer is set, count it down and at 0, try the trigger */
/* note to .rej hand-patchers: make this last in your point-update() */
else if (GET_OBJ_TIMER(j)>0) {
GET_OBJ_TIMER(j)--;
if (!GET_OBJ_TIMER(j))
timer_otrigger(j);
}
}
}

973
src/magic.c Normal file
View file

@ -0,0 +1,973 @@
/* ************************************************************************
* File: magic.c Part of CircleMUD *
* Usage: low-level functions for magic; spell template code *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "spells.h"
#include "handler.h"
#include "db.h"
#include "interpreter.h"
#include "constants.h"
#include "dg_scripts.h"
/* external variables */
extern int mini_mud;
extern struct spell_info_type spell_info[];
/* external functions */
byte saving_throws(int class_num, int type, int level); /* class.c */
void clearMemory(struct char_data *ch);
void weight_change_object(struct obj_data *obj, int weight);
/* 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);
/*
* Saving throws are now in class.c as of bpl13.
*/
/*
* Negative apply_saving_throw[] values make saving throws better!
* Then, so do negative modifiers. Though people may be used to
* the reverse of that. It's due to the code modifying the target
* saving throw instead of the random number of the character as
* in some other systems.
*/
int mag_savingthrow(struct char_data *ch, int type, int modifier)
{
/* NPCs use warrior tables according to some book */
int class_sav = CLASS_WARRIOR;
int save;
if (!IS_NPC(ch))
class_sav = GET_CLASS(ch);
save = saving_throws(class_sav, type, GET_LEVEL(ch));
save += GET_SAVE(ch, type);
save += modifier;
/* Throwing a 0 is always a failure. */
if (MAX(1, save) < rand_number(0, 99))
return (TRUE);
/* Oops, failed. Sorry. */
return (FALSE);
}
/* affect_update: called from comm.c (causes spells to wear off) */
void affect_update(void)
{
struct affected_type *af, *next;
struct char_data *i;
for (i = character_list; i; i = i->next)
for (af = i->affected; af; af = next) {
next = af->next;
if (af->duration >= 1)
af->duration--;
else if (af->duration == -1) /* No action */
af->duration = -1; /* GODs only! unlimited */
else {
if ((af->type > 0) && (af->type <= MAX_SPELLS))
if (!af->next || (af->next->type != af->type) ||
(af->next->duration > 0))
if (spell_info[af->type].wear_off_msg)
send_to_char(i, "%s\r\n", spell_info[af->type].wear_off_msg);
affect_remove(i, af);
}
}
}
/*
* mag_materials:
* Checks for up to 3 vnums (spell reagents) in the player's inventory.
*
* No spells implemented in Circle use mag_materials, but you can use
* it to implement your own spells which require ingredients (i.e., some
* heal spell which requires a rare herb or some such.)
*/
int mag_materials(struct char_data *ch, int item0, int item1, int item2,
int extract, int verbose)
{
struct obj_data *tobj;
struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;
for (tobj = ch->carrying; tobj; tobj = tobj->next_content) {
if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) {
obj0 = tobj;
item0 = -1;
} else if ((item1 > 0) && (GET_OBJ_VNUM(tobj) == item1)) {
obj1 = tobj;
item1 = -1;
} else if ((item2 > 0) && (GET_OBJ_VNUM(tobj) == item2)) {
obj2 = tobj;
item2 = -1;
}
}
if ((item0 > 0) || (item1 > 0) || (item2 > 0)) {
if (verbose) {
switch (rand_number(0, 2)) {
case 0:
send_to_char(ch, "A wart sprouts on your nose.\r\n");
break;
case 1:
send_to_char(ch, "Your hair falls out in clumps.\r\n");
break;
case 2:
send_to_char(ch, "A huge corn develops on your big toe.\r\n");
break;
}
}
return (FALSE);
}
if (extract) {
if (item0 < 0)
extract_obj(obj0);
if (item1 < 0)
extract_obj(obj1);
if (item2 < 0)
extract_obj(obj2);
}
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);
}
return (TRUE);
}
/*
* Every spell that does damage comes through here. This calculates the
* amount of damage, adds in any modifiers, determines what the saves are,
* tests for save and calls damage().
*
* -1 = dead, otherwise the amount of damage done.
*/
int mag_damage(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype)
{
int dam = 0;
if (victim == NULL || ch == NULL)
return (0);
switch (spellnum) {
/* Mostly mages */
case SPELL_MAGIC_MISSILE:
case SPELL_CHILL_TOUCH: /* chill touch also has an affect */
if (IS_MAGIC_USER(ch))
dam = dice(1, 8) + 1;
else
dam = dice(1, 6) + 1;
break;
case SPELL_BURNING_HANDS:
if (IS_MAGIC_USER(ch))
dam = dice(3, 8) + 3;
else
dam = dice(3, 6) + 3;
break;
case SPELL_SHOCKING_GRASP:
if (IS_MAGIC_USER(ch))
dam = dice(5, 8) + 5;
else
dam = dice(5, 6) + 5;
break;
case SPELL_LIGHTNING_BOLT:
if (IS_MAGIC_USER(ch))
dam = dice(7, 8) + 7;
else
dam = dice(7, 6) + 7;
break;
case SPELL_COLOR_SPRAY:
if (IS_MAGIC_USER(ch))
dam = dice(9, 8) + 9;
else
dam = dice(9, 6) + 9;
break;
case SPELL_FIREBALL:
if (IS_MAGIC_USER(ch))
dam = dice(11, 8) + 11;
else
dam = dice(11, 6) + 11;
break;
/* Mostly clerics */
case SPELL_DISPEL_EVIL:
dam = dice(6, 8) + 6;
if (IS_EVIL(ch)) {
victim = ch;
dam = GET_HIT(ch) - 1;
} else if (IS_GOOD(victim)) {
act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
return (0);
}
break;
case SPELL_DISPEL_GOOD:
dam = dice(6, 8) + 6;
if (IS_GOOD(ch)) {
victim = ch;
dam = GET_HIT(ch) - 1;
} else if (IS_EVIL(victim)) {
act("The gods protect $N.", FALSE, ch, 0, victim, TO_CHAR);
return (0);
}
break;
case SPELL_CALL_LIGHTNING:
dam = dice(7, 8) + 7;
break;
case SPELL_HARM:
dam = dice(8, 8) + 8;
break;
case SPELL_ENERGY_DRAIN:
if (GET_LEVEL(victim) <= 2)
dam = 100;
else
dam = dice(1, 10);
break;
/* Area spells */
case SPELL_EARTHQUAKE:
dam = dice(2, 8) + level;
break;
} /* switch(spellnum) */
/* divide damage by two if victim makes his saving throw */
if (mag_savingthrow(victim, savetype, 0))
dam /= 2;
/* and finally, inflict the damage */
return (damage(ch, victim, dam, spellnum));
}
/*
* Every spell that does an affect comes through here. This determines
* the effect, whether it is added or replacement, whether it is legal or
* not, etc.
*
* affect_join(vict, aff, add_dur, avg_dur, add_mod, avg_mod)
*/
#define MAX_SPELL_AFFECTS 5 /* change if more needed */
void mag_affects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype)
{
struct affected_type af[MAX_SPELL_AFFECTS];
bool accum_affect = FALSE, accum_duration = FALSE;
const char *to_vict = NULL, *to_room = NULL;
int i;
if (victim == NULL || ch == NULL)
return;
for (i = 0; i < MAX_SPELL_AFFECTS; i++) {
af[i].type = spellnum;
af[i].bitvector = 0;
af[i].modifier = 0;
af[i].location = APPLY_NONE;
}
switch (spellnum) {
case SPELL_CHILL_TOUCH:
af[0].location = APPLY_STR;
if (mag_savingthrow(victim, savetype, 0))
af[0].duration = 1;
else
af[0].duration = 4;
af[0].modifier = -1;
accum_duration = TRUE;
to_vict = "You feel your strength wither!";
break;
case SPELL_ARMOR:
af[0].location = APPLY_AC;
af[0].modifier = -20;
af[0].duration = 24;
accum_duration = TRUE;
to_vict = "You feel someone protecting you.";
break;
case SPELL_BLESS:
af[0].location = APPLY_HITROLL;
af[0].modifier = 2;
af[0].duration = 6;
af[1].location = APPLY_SAVING_SPELL;
af[1].modifier = -1;
af[1].duration = 6;
accum_duration = TRUE;
to_vict = "You feel righteous.";
break;
case SPELL_BLINDNESS:
if (MOB_FLAGGED(victim,MOB_NOBLIND) || mag_savingthrow(victim, savetype, 0)) {
send_to_char(ch, "You fail.\r\n");
return;
}
af[0].location = APPLY_HITROLL;
af[0].modifier = -4;
af[0].duration = 2;
af[0].bitvector = AFF_BLIND;
af[1].location = APPLY_AC;
af[1].modifier = 40;
af[1].duration = 2;
af[1].bitvector = AFF_BLIND;
to_room = "$n seems to be blinded!";
to_vict = "You have been blinded!";
break;
case SPELL_CURSE:
if (mag_savingthrow(victim, savetype, 0)) {
send_to_char(ch, "%s", CONFIG_NOEFFECT);
return;
}
af[0].location = APPLY_HITROLL;
af[0].duration = 1 + (GET_LEVEL(ch) / 2);
af[0].modifier = -1;
af[0].bitvector = AFF_CURSE;
af[1].location = APPLY_DAMROLL;
af[1].duration = 1 + (GET_LEVEL(ch) / 2);
af[1].modifier = -1;
af[1].bitvector = AFF_CURSE;
accum_duration = TRUE;
accum_affect = TRUE;
to_room = "$n briefly glows red!";
to_vict = "You feel very uncomfortable.";
break;
case SPELL_DETECT_ALIGN:
af[0].duration = 12 + level;
af[0].bitvector = AFF_DETECT_ALIGN;
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;
case SPELL_DETECT_INVIS:
af[0].duration = 12 + level;
af[0].bitvector = AFF_DETECT_INVIS;
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;
case SPELL_DETECT_MAGIC:
af[0].duration = 12 + level;
af[0].bitvector = AFF_DETECT_MAGIC;
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;
case SPELL_INFRAVISION:
af[0].duration = 12 + level;
af[0].bitvector = AFF_INFRAVISION;
accum_duration = TRUE;
to_vict = "Your eyes glow red.";
to_room = "$n's eyes glow red.";
break;
case SPELL_INVISIBLE:
if (!victim)
victim = ch;
af[0].duration = 12 + (GET_LEVEL(ch) / 4);
af[0].modifier = -40;
af[0].location = APPLY_AC;
af[0].bitvector = AFF_INVISIBLE;
accum_duration = TRUE;
to_vict = "You vanish.";
to_room = "$n slowly fades out of existence.";
break;
case SPELL_POISON:
if (mag_savingthrow(victim, savetype, 0)) {
send_to_char(ch, "%s", CONFIG_NOEFFECT);
return;
}
af[0].location = APPLY_STR;
af[0].duration = GET_LEVEL(ch);
af[0].modifier = -2;
af[0].bitvector = AFF_POISON;
to_vict = "You feel very sick.";
to_room = "$n gets violently ill!";
break;
case SPELL_PROT_FROM_EVIL:
af[0].duration = 24;
af[0].bitvector = AFF_PROTECT_EVIL;
accum_duration = TRUE;
to_vict = "You feel invulnerable!";
break;
case SPELL_SANCTUARY:
af[0].duration = 4;
af[0].bitvector = AFF_SANCTUARY;
accum_duration = TRUE;
to_vict = "A white aura momentarily surrounds you.";
to_room = "$n is surrounded by a white aura.";
break;
case SPELL_SLEEP:
if (!CONFIG_PK_ALLOWED && !IS_NPC(ch) && !IS_NPC(victim))
return;
if (MOB_FLAGGED(victim, MOB_NOSLEEP))
return;
if (mag_savingthrow(victim, savetype, 0))
return;
af[0].duration = 4 + (GET_LEVEL(ch) / 4);
af[0].bitvector = AFF_SLEEP;
if (GET_POS(victim) > POS_SLEEPING) {
send_to_char(victim, "You feel very sleepy... Zzzz......\r\n");
act("$n goes to sleep.", TRUE, victim, 0, 0, TO_ROOM);
GET_POS(victim) = POS_SLEEPING;
}
break;
case SPELL_STRENGTH:
if (GET_ADD(victim) == 100)
return;
af[0].location = APPLY_STR;
af[0].duration = (GET_LEVEL(ch) / 2) + 4;
af[0].modifier = 1 + (level > 18);
accum_duration = TRUE;
accum_affect = TRUE;
to_vict = "You feel stronger!";
break;
case SPELL_SENSE_LIFE:
to_vict = "Your feel your awareness improve.";
af[0].duration = GET_LEVEL(ch);
af[0].bitvector = AFF_SENSE_LIFE;
accum_duration = TRUE;
break;
case SPELL_WATERWALK:
af[0].duration = 24;
af[0].bitvector = AFF_WATERWALK;
accum_duration = TRUE;
to_vict = "You feel webbing between your toes.";
break;
}
/*
* If this is a mob that has this affect set in its mob file, do not
* perform the affect. This prevents people from un-sancting mobs
* by sancting them and waiting for it to fade, for example.
*/
if (IS_NPC(victim) && !affected_by_spell(victim, spellnum))
for (i = 0; i < MAX_SPELL_AFFECTS; i++)
if (AFF_FLAGGED(victim, af[i].bitvector)) {
send_to_char(ch, "%s", CONFIG_NOEFFECT);
return;
}
/*
* If the victim is already affected by this spell, and the spell does
* not have an accumulative effect, then fail the spell.
*/
if (affected_by_spell(victim,spellnum) && !(accum_duration||accum_affect)) {
send_to_char(ch, "%s", CONFIG_NOEFFECT);
return;
}
for (i = 0; i < MAX_SPELL_AFFECTS; i++)
if (af[i].bitvector || (af[i].location != APPLY_NONE))
affect_join(victim, af+i, accum_duration, FALSE, accum_affect, FALSE);
if (to_vict != NULL)
act(to_vict, FALSE, victim, 0, ch, TO_CHAR);
if (to_room != NULL)
act(to_room, TRUE, victim, 0, ch, TO_ROOM);
}
/*
* This function is used to provide services to mag_groups. This function
* is the one you should change to add new group spells.
*/
void perform_mag_groups(int level, struct char_data *ch,
struct char_data *tch, int spellnum, int savetype)
{
switch (spellnum) {
case SPELL_GROUP_HEAL:
mag_points(level, ch, tch, SPELL_HEAL, savetype);
break;
case SPELL_GROUP_ARMOR:
mag_affects(level, ch, tch, SPELL_ARMOR, savetype);
break;
case SPELL_GROUP_RECALL:
spell_recall(level, ch, tch, NULL);
break;
}
}
/*
* Every spell that affects the group should run through here
* perform_mag_groups contains the switch statement to send us to the right
* magic.
*
* group spells affect everyone grouped with the caster who is in the room,
* caster last.
*
* To add new group spells, you shouldn't have to change anything in
* mag_groups -- just add a new case to perform_mag_groups.
*/
void mag_groups(int level, struct char_data *ch, int spellnum, int savetype)
{
struct char_data *tch, *k;
struct follow_type *f, *f_next;
if (ch == NULL)
return;
if (!AFF_FLAGGED(ch, AFF_GROUP))
return;
if (ch->master != NULL)
k = ch->master;
else
k = ch;
for (f = k->followers; f; f = f_next) {
f_next = f->next;
tch = f->follower;
if (IN_ROOM(tch) != IN_ROOM(ch))
continue;
if (!AFF_FLAGGED(tch, AFF_GROUP))
continue;
if (ch == tch)
continue;
perform_mag_groups(level, ch, tch, spellnum, savetype);
}
if ((k != ch) && AFF_FLAGGED(k, AFF_GROUP))
perform_mag_groups(level, ch, k, spellnum, savetype);
perform_mag_groups(level, ch, ch, spellnum, savetype);
}
/*
* mass spells affect every creature in the room except the caster.
*
* No spells of this class currently implemented.
*/
void mag_masses(int level, struct char_data *ch, int spellnum, int savetype)
{
struct char_data *tch, *tch_next;
for (tch = world[IN_ROOM(ch)].people; tch; tch = tch_next) {
tch_next = tch->next_in_room;
if (tch == ch)
continue;
switch (spellnum) {
}
}
}
/*
* Every spell that affects an area (room) runs through here. These are
* generally offensive spells. This calls mag_damage to do the actual
* damage -- all spells listed here must also have a case in mag_damage()
* in order for them to work.
*
* area spells have limited targets within the room.
*/
void mag_areas(int level, struct char_data *ch, int spellnum, int savetype)
{
struct char_data *tch, *next_tch;
const char *to_char = NULL, *to_room = NULL;
if (ch == NULL)
return;
/*
* to add spells to this fn, just add the message here plus an entry
* in mag_damage for the damaging part of the spell.
*/
switch (spellnum) {
case SPELL_EARTHQUAKE:
to_char = "You gesture and the earth begins to shake all around you!";
to_room ="$n gracefully gestures and the earth begins to shake violently!";
break;
}
if (to_char != NULL)
act(to_char, FALSE, ch, 0, 0, TO_CHAR);
if (to_room != NULL)
act(to_room, FALSE, ch, 0, 0, TO_ROOM);
for (tch = world[IN_ROOM(ch)].people; tch; tch = next_tch) {
next_tch = tch->next_in_room;
/*
* The skips: 1: the caster
* 2: immortals
* 3: if no pk on this mud, skips over all players
* 4: pets (charmed NPCs)
*/
if (tch == ch)
continue;
if (!IS_NPC(tch) && GET_LEVEL(tch) >= LVL_IMMORT)
continue;
if (!CONFIG_PK_ALLOWED && !IS_NPC(ch) && !IS_NPC(tch))
continue;
if (!IS_NPC(ch) && IS_NPC(tch) && AFF_FLAGGED(tch, AFF_CHARM))
continue;
/* Doesn't matter if they die here so we don't check. -gg 6/24/98 */
mag_damage(level, ch, tch, spellnum, 1);
}
}
/*
* Every spell which summons/gates/conjours a mob comes through here.
*
* None of these spells are currently implemented in CircleMUD; these
* were taken as examples from the JediMUD code. Summons can be used
* for spells like clone, ariel servant, etc.
*
* 10/15/97 (gg) - Implemented Animate Dead and Clone.
*/
/*
* These use act(), don't put the \r\n.
*/
const char *mag_summon_msgs[] = {
"\r\n",
"$n makes a strange magical gesture; you feel a strong breeze!",
"$n animates a corpse!",
"$N appears from a cloud of thick blue smoke!",
"$N appears from a cloud of thick green smoke!",
"$N appears from a cloud of thick red smoke!",
"$N disappears in a thick black cloud!"
"As $n makes a strange magical gesture, you feel a strong breeze.",
"As $n makes a strange magical gesture, you feel a searing heat.",
"As $n makes a strange magical gesture, you feel a sudden chill.",
"As $n makes a strange magical gesture, you feel the dust swirl.",
"$n magically divides!",
"$n animates a corpse!"
};
/*
* Keep the \r\n because these use send_to_char.
*/
const char *mag_summon_fail_msgs[] = {
"\r\n",
"There are no such creatures.\r\n",
"Uh oh...\r\n",
"Oh dear.\r\n",
"Gosh durnit!\r\n",
"The elements resist!\r\n",
"You failed.\r\n",
"There is no corpse!\r\n"
};
/* These mobiles do not exist. */
#define MOB_MONSUM_I 130
#define MOB_MONSUM_II 140
#define MOB_MONSUM_III 150
#define MOB_GATE_I 160
#define MOB_GATE_II 170
#define MOB_GATE_III 180
/* Defined mobiles. */
#define MOB_ELEMENTAL_BASE 20 /* Only one for now. */
#define MOB_CLONE 10
#define MOB_ZOMBIE 11
#define MOB_AERIALSERVANT 19
void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int savetype)
{
struct char_data *mob = NULL;
struct obj_data *tobj, *next_obj;
int pfail = 0, msg = 0, fmsg = 0, num = 1, handle_corpse = FALSE, i;
mob_vnum mob_num;
if (ch == NULL)
return;
switch (spellnum) {
case SPELL_CLONE:
msg = 10;
fmsg = rand_number(2, 6); /* Random fail message. */
mob_num = MOB_CLONE;
pfail = 50; /* 50% failure, should be based on something later. */
break;
case SPELL_ANIMATE_DEAD:
if (obj == NULL || !IS_CORPSE(obj)) {
act(mag_summon_fail_msgs[7], FALSE, ch, 0, 0, TO_CHAR);
return;
}
handle_corpse = TRUE;
msg = 11;
fmsg = rand_number(2, 6); /* Random fail message. */
mob_num = MOB_ZOMBIE;
pfail = 10; /* 10% failure, should vary in the future. */
break;
default:
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM)) {
send_to_char(ch, "You are too giddy to have any followers!\r\n");
return;
}
if (rand_number(0, 101) < pfail) {
send_to_char(ch, "%s", mag_summon_fail_msgs[fmsg]);
return;
}
for (i = 0; i < num; i++) {
if (!(mob = read_mobile(mob_num, VIRTUAL))) {
send_to_char(ch, "You don't quite remember how to make that creature.\r\n");
return;
}
char_to_room(mob, IN_ROOM(ch));
IS_CARRYING_W(mob) = 0;
IS_CARRYING_N(mob) = 0;
SET_BIT(AFF_FLAGS(mob), AFF_CHARM);
if (spellnum == SPELL_CLONE) {
/* Don't mess up the prototype; use new string copies. */
mob->player.name = strdup(GET_NAME(ch));
mob->player.short_descr = strdup(GET_NAME(ch));
}
act(mag_summon_msgs[msg], FALSE, ch, 0, mob, TO_ROOM);
load_mtrigger(mob);
add_follower(mob, ch);
}
if (handle_corpse) {
for (tobj = obj->contains; tobj; tobj = next_obj) {
next_obj = tobj->next_content;
obj_from_obj(tobj);
obj_to_char(tobj, mob);
}
extract_obj(obj);
}
}
void mag_points(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype)
{
int healing = 0, move = 0;
if (victim == NULL)
return;
switch (spellnum) {
case SPELL_CURE_LIGHT:
healing = dice(1, 8) + 1 + (level / 4);
send_to_char(victim, "You feel better.\r\n");
break;
case SPELL_CURE_CRITIC:
healing = dice(3, 8) + 3 + (level / 4);
send_to_char(victim, "You feel a lot better!\r\n");
break;
case SPELL_HEAL:
healing = 100 + dice(3, 8);
send_to_char(victim, "A warm feeling floods your body.\r\n");
break;
}
GET_HIT(victim) = MIN(GET_MAX_HIT(victim), GET_HIT(victim) + healing);
GET_MOVE(victim) = MIN(GET_MAX_MOVE(victim), GET_MOVE(victim) + move);
update_pos(victim);
}
void mag_unaffects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int type)
{
int spell = 0, msg_not_affected = TRUE;
const char *to_vict = NULL, *to_room = NULL;
if (victim == NULL)
return;
switch (spellnum) {
case SPELL_HEAL:
/*
* Heal also restores health, so don't give the "no effect" message
* if the target isn't afflicted by the 'blindness' spell.
*/
msg_not_affected = FALSE;
/* fall-through */
case SPELL_CURE_BLIND:
spell = SPELL_BLINDNESS;
to_vict = "Your vision returns!";
to_room = "There's a momentary gleam in $n's eyes.";
break;
case SPELL_REMOVE_POISON:
spell = SPELL_POISON;
to_vict = "A warm feeling runs through your body!";
to_room = "$n looks better.";
break;
case SPELL_REMOVE_CURSE:
spell = SPELL_CURSE;
to_vict = "You don't feel so unlucky.";
break;
default:
log("SYSERR: unknown spellnum %d passed to mag_unaffects.", spellnum);
return;
}
if (!affected_by_spell(victim, spell)) {
if (msg_not_affected)
send_to_char(ch, "%s", CONFIG_NOEFFECT);
return;
}
affect_from_char(victim, spell);
if (to_vict != NULL)
act(to_vict, FALSE, victim, 0, ch, TO_CHAR);
if (to_room != NULL)
act(to_room, TRUE, victim, 0, ch, TO_ROOM);
}
void mag_alter_objs(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int savetype)
{
const char *to_char = NULL, *to_room = NULL;
if (obj == NULL)
return;
switch (spellnum) {
case SPELL_BLESS:
if (!OBJ_FLAGGED(obj, ITEM_BLESS) &&
(GET_OBJ_WEIGHT(obj) <= 5 * GET_LEVEL(ch))) {
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_BLESS);
to_char = "$p glows briefly.";
}
break;
case SPELL_CURSE:
if (!OBJ_FLAGGED(obj, ITEM_NODROP)) {
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_NODROP);
if (GET_OBJ_TYPE(obj) == ITEM_WEAPON)
GET_OBJ_VAL(obj, 2)--;
to_char = "$p briefly glows red.";
}
break;
case SPELL_INVISIBLE:
if (!OBJ_FLAGGED(obj, ITEM_NOINVIS | ITEM_INVISIBLE)) {
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_INVISIBLE);
to_char = "$p vanishes.";
}
break;
case SPELL_POISON:
if (((GET_OBJ_TYPE(obj) == ITEM_DRINKCON) ||
(GET_OBJ_TYPE(obj) == ITEM_FOUNTAIN) ||
(GET_OBJ_TYPE(obj) == ITEM_FOOD)) && !GET_OBJ_VAL(obj, 3)) {
GET_OBJ_VAL(obj, 3) = 1;
to_char = "$p steams briefly.";
}
break;
case SPELL_REMOVE_CURSE:
if (OBJ_FLAGGED(obj, ITEM_NODROP)) {
REMOVE_BIT(GET_OBJ_EXTRA(obj), ITEM_NODROP);
if (GET_OBJ_TYPE(obj) == ITEM_WEAPON)
GET_OBJ_VAL(obj, 2)++;
to_char = "$p briefly glows blue.";
}
break;
case SPELL_REMOVE_POISON:
if (((GET_OBJ_TYPE(obj) == ITEM_DRINKCON) ||
(GET_OBJ_TYPE(obj) == ITEM_FOUNTAIN) ||
(GET_OBJ_TYPE(obj) == ITEM_FOOD)) && GET_OBJ_VAL(obj, 3)) {
GET_OBJ_VAL(obj, 3) = 0;
to_char = "$p steams briefly.";
}
break;
}
if (to_char == NULL)
send_to_char(ch, "%s", CONFIG_NOEFFECT);
else
act(to_char, TRUE, ch, obj, 0, TO_CHAR);
if (to_room != NULL)
act(to_room, TRUE, ch, obj, 0, TO_ROOM);
else if (to_char != NULL)
act(to_char, TRUE, ch, obj, 0, TO_ROOM);
}
void mag_creations(int level, struct char_data *ch, int spellnum)
{
struct obj_data *tobj;
obj_vnum z;
if (ch == NULL)
return;
/* level = MAX(MIN(level, LVL_IMPL), 1); - Hm, not used. */
switch (spellnum) {
case SPELL_CREATE_FOOD:
z = 10;
break;
default:
send_to_char(ch, "Spell unimplemented, it would seem.\r\n");
return;
}
if (!(tobj = read_object(z, VIRTUAL))) {
send_to_char(ch, "I seem to have goofed.\r\n");
log("SYSERR: spell_creations, spell %d, obj %d: obj not found",
spellnum, z);
return;
}
obj_to_char(tobj, ch);
act("$n creates $p.", FALSE, ch, tobj, 0, TO_ROOM);
act("You create $p.", FALSE, ch, tobj, 0, TO_CHAR);
load_otrigger(tobj);
}

437
src/mail.c Normal file
View file

@ -0,0 +1,437 @@
/* ************************************************************************
* File: mail.c Part of CircleMUD *
* Usage: Internal funcs and player spec-procs of mud-mail system *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
/******* MUD MAIL SYSTEM MAIN FILE ***************************************
Written by Jeremy Elson (jelson@circlemud.org)
*************************************************************************/
/* And completely rewritten by Welcor 16th of december, 2005 */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "interpreter.h"
#include "handler.h"
#include "mail.h"
/* external variables */
extern int no_mail;
extern struct player_index_element *player_table;
/* external functions */
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);
/* -------------------------------------------------------------------------- */
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;
if ((player_i = get_ptable_by_name(name)) >= 0) {
if (!IS_SET(player_table[player_i].flags, PINDEX_DELETED))
ret = TRUE;
}
return ret;
}
void free_mail_record(struct mail_t *record)
{
if (record->body)
free(record->body);
free(record);
}
struct mail_t *read_mail_record(FILE *mail_file)
{
char line[READ_SIZE];
long sender, recipient;
time_t sent_time;
struct mail_t *record;
if (!get_line(mail_file, line))
return NULL;
if (sscanf(line, "### %ld %ld %ld", &recipient, &sender, &sent_time) != 3) {
log("Mail system - fatal error - malformed mail header");
log("Line was: %s", line);
return NULL;
}
CREATE(record, struct mail_t, 1);
record->recipient = recipient;
record->sender = sender;
record->sent_time = sent_time;
record->body = fread_string(mail_file, "read mail record");
return record;
}
void write_mail_record(FILE *mail_file, struct mail_t *record)
{
fprintf(mail_file, "### %ld %ld %ld\n"
"%s~\n",
record->recipient,
record->sender,
record->sent_time,
record->body );
}
/*
* int scan_file(none)
* Returns false if mail file is corrupted or true if everything correct.
*
* This is called once during boot-up. It scans through the mail file
* and indexes all entries currently in the mail file.
*/
int scan_file(void)
{
FILE *mail_file;
int count = 0;
struct mail_t *record;
if (!(mail_file = fopen(MAIL_FILE, "r"))) {
log(" Mail file non-existant... creating new file.");
touch(MAIL_FILE);
return TRUE;
}
record = read_mail_record(mail_file);
while (record) {
free_mail_record(record);
record = read_mail_record(mail_file);
count++;
}
fclose(mail_file);
log(" Mail file read -- %d messages.", count);
return TRUE;
}
/*
* int has_mail(long #1)
* #1 - id number of the person to check for mail.
* Returns true or false.
*
* A simple little function which tells you if the guy has mail or not.
*/
int has_mail(long recipient)
{
FILE *mail_file;
struct mail_t *record;
if (!(mail_file = fopen(MAIL_FILE, "r"))) {
perror("read_delete: Mail file not accessible.");
return FALSE;
}
record = read_mail_record(mail_file);
while (record) {
if (record->recipient == recipient) {
free_mail_record(record);
fclose(mail_file);
return TRUE;
}
free_mail_record(record);
record = read_mail_record(mail_file);
}
fclose(mail_file);
return FALSE;
}
/*
* void store_mail(long #1, long #2, char * #3)
* #1 - id number of the person to mail to.
* #2 - id number of the person the mail is from.
* #3 - The actual message to send.
*
* call store_mail to store mail. (hard, huh? :-) ) Pass 3 arguments:
* who the mail is to (long), who it's from (long), and a pointer to the
* actual message text (char *).
*/
void store_mail(long to, long from, char *message_pointer)
{
FILE *mail_file;
struct mail_t *record;
if (!(mail_file = fopen(MAIL_FILE, "a"))) {
perror("store_mail: Mail file not accessible.");
return;
}
CREATE(record, struct mail_t, 1);
record->recipient = to;
record->sender = from;
record->sent_time = time(0);
record->body = message_pointer;
write_mail_record(mail_file, record);
free(record); /* don't free the body */
fclose(mail_file);
}
/*
* char *read_delete(long #1)
* #1 - The id number of the person we're checking mail for.
* Returns the message text of the mail received.
*
* Retrieves one messsage for a player. The mail is then discarded from
* the file.
*
* Expects mail to exist.
*/
char *read_delete(long recipient)
{
FILE *mail_file, *new_file;
struct mail_t *record, *record_to_keep = NULL;
char buf[MAX_STRING_LENGTH];
if (!(mail_file = fopen(MAIL_FILE, "r"))) {
perror("read_delete: Mail file not accessible.");
return strdup("Mail system malfunction - please report this");
}
if (!(new_file = fopen(MAIL_FILE_TMP, "w"))) {
perror("read_delete: new Mail file not accessible.");
fclose(mail_file);
return strdup("Mail system malfunction - please report this");
}
record = read_mail_record(mail_file);
while (record) {
if (!record_to_keep && record->recipient == recipient) {
record_to_keep = record;
record = read_mail_record(mail_file);
continue; /* don't write and free this one just yet */
}
write_mail_record(new_file, record);
free_mail_record(record);
record = read_mail_record(mail_file);
}
if (!record_to_keep)
sprintf(buf, "Mail system error - please report");
else {
char *tmstr, *from, *to;
tmstr = asctime(localtime(&record_to_keep->sent_time));
*(tmstr + strlen(tmstr) - 1) = '\0';
from = get_name_by_id(record_to_keep->sender);
to = get_name_by_id(record_to_keep->recipient);
snprintf(buf, sizeof(buf),
" * * * * Midgaard Mail System * * * *\r\n"
"Date: %s\r\n"
"To : %s\r\n"
"From: %s\r\n"
"\r\n"
"%s",
tmstr,
to ? to : "Unknown",
from ? from : "Unknown",
record_to_keep->body ? record_to_keep->body : "No message" );
free_mail_record(record_to_keep);
}
fclose(mail_file);
fclose(new_file);
remove(MAIL_FILE);
rename(MAIL_FILE_TMP, MAIL_FILE);
return strdup(buf);
}
/****************************************************************
* Below is the spec_proc for a postmaster using the above *
* routines. Written by Jeremy Elson (jelson@circlemud.org) *
****************************************************************/
SPECIAL(postmaster)
{
if (!ch->desc || IS_NPC(ch))
return (0); /* so mobs don't get caught here */
if (!(CMD_IS("mail") || CMD_IS("check") || CMD_IS("receive")))
return (0);
if (no_mail) {
send_to_char(ch, "Sorry, the mail system is having technical difficulties.\r\n");
return (0);
}
if (CMD_IS("mail")) {
postmaster_send_mail(ch, (struct char_data *)me, cmd, argument);
return (1);
} else if (CMD_IS("check")) {
postmaster_check_mail(ch, (struct char_data *)me, cmd, argument);
return (1);
} else if (CMD_IS("receive")) {
postmaster_receive_mail(ch, (struct char_data *)me, cmd, argument);
return (1);
} else
return (0);
}
void postmaster_send_mail(struct char_data *ch, struct char_data *mailman,
int cmd, char *arg)
{
long recipient;
char buf[MAX_INPUT_LENGTH], **mailwrite;
if (GET_LEVEL(ch) < MIN_MAIL_LEVEL) {
snprintf(buf, sizeof(buf), "$n tells you, 'Sorry, you have to be level %d to send mail!'", MIN_MAIL_LEVEL);
act(buf, FALSE, mailman, 0, ch, TO_VICT);
return;
}
one_argument(arg, buf);
if (!*buf) { /* you'll get no argument from me! */
act("$n tells you, 'You need to specify an addressee!'",
FALSE, mailman, 0, ch, TO_VICT);
return;
}
if (GET_GOLD(ch) < STAMP_PRICE && GET_LEVEL(ch) < LVL_IMMORT) {
snprintf(buf, sizeof(buf), "$n tells you, 'A stamp costs %d coin%s.'\r\n"
"$n tells you, '...which I see you can't afford.'", STAMP_PRICE,
STAMP_PRICE == 1 ? "" : "s");
act(buf, FALSE, mailman, 0, ch, TO_VICT);
return;
}
if ((recipient = get_id_by_name(buf)) < 0 || !mail_recip_ok(buf)) {
act("$n tells you, 'No one by that name is registered here!'",
FALSE, mailman, 0, ch, TO_VICT);
return;
}
act("$n starts to write some mail.", TRUE, ch, 0, 0, TO_ROOM);
snprintf(buf, sizeof(buf), "$n tells you, 'I'll take %d coins for the stamp.'\r\n"
"$n tells you, 'Write your message. (/s saves /h for help).'",
STAMP_PRICE);
act(buf, FALSE, mailman, 0, ch, TO_VICT);
if (GET_LEVEL(ch) < LVL_IMMORT)
GET_GOLD(ch) -= STAMP_PRICE;
SET_BIT(PLR_FLAGS(ch), PLR_MAILING); /* string_write() sets writing. */
/* Start writing! */
CREATE(mailwrite, char *, 1);
string_write(ch->desc, mailwrite, MAX_MAIL_SIZE, recipient, NULL);
}
void postmaster_check_mail(struct char_data *ch, struct char_data *mailman,
int cmd, char *arg)
{
if (has_mail(GET_IDNUM(ch)))
act("$n tells you, 'You have mail waiting.'", FALSE, mailman, 0, ch, TO_VICT);
else
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,
int cmd, char *arg)
{
char buf[256];
struct obj_data *obj;
if (!has_mail(GET_IDNUM(ch))) {
snprintf(buf, sizeof(buf), "$n tells you, 'Sorry, you don't have any mail waiting.'");
act(buf, FALSE, mailman, 0, ch, TO_VICT);
return;
}
while (has_mail(GET_IDNUM(ch))) {
obj = read_object(1, VIRTUAL); /*a pair of wings will work :)*/
obj->name = strdup("mail paper letter");
obj->short_description = strdup("a piece of mail");
obj->description = strdup("Someone has left a piece of mail here.");
GET_OBJ_TYPE(obj) = ITEM_NOTE;
GET_OBJ_WEAR(obj) = ITEM_WEAR_TAKE;
GET_OBJ_WEIGHT(obj) = 1;
GET_OBJ_COST(obj) = 30;
GET_OBJ_RENT(obj) = 10;
obj->action_description = read_delete(GET_IDNUM(ch));
if (obj->action_description == NULL)
obj->action_description =
strdup("Mail system error - please report. Error #11.\r\n");
obj_to_char(obj, ch);
act("$n gives you a piece of mail.", FALSE, mailman, 0, ch, TO_VICT);
act("$N gives $n a piece of mail.", FALSE, ch, 0, mailman, TO_ROOM);
}
}

119
src/mail.h Normal file
View file

@ -0,0 +1,119 @@
/* ************************************************************************
* File: mail.h Part of CircleMUD *
* Usage: header file for mail system *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
/******* MUD MAIL SYSTEM HEADER FILE **********************
*** written by Jeremy Elson (jelson@circlemud.org) ***
*********************************************************/
/* INSTALLATION INSTRUCTIONS in MAIL.C */
/* You can modify the following constants to fit your own MUD. */
/* minimum level a player must be to send mail */
#define MIN_MAIL_LEVEL 1
/* # of gold coins required to send mail */
#define STAMP_PRICE 150
/* Maximum size of mail in bytes (arbitrary) */
#define MAX_MAIL_SIZE 4096
/* size of mail file allocation blocks */
#define BLOCK_SIZE 100
/*
* 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 to make sure it is >0 when choosing values
* for NAME_SIZE and BLOCK_SIZE. 100 is a nice round number for
* BLOCK_SIZE and is the default ... why bother trying to change it
* anyway?
*
* The mail system will always allocate disk space in chunks of size
* BLOCK_SIZE.
*/
/* USER CHANGABLE DEFINES ABOVE **
***************************************************************************
** DON'T TOUCH DEFINES BELOW */
int scan_file(void);
int has_mail(long recipient);
void store_mail(long to, long from, char *message_pointer);
char *read_delete(long recipient);
struct mail_t {
long recipient;
long sender;
time_t sent_time;
char *body;
};
/* old stuff below */
#define HEADER_BLOCK (-1)
#define LAST_BLOCK (-2)
#define DELETED_BLOCK (-3)
/*
* note: next_block is part of header_blk in a data block; we can't combine
* them here because we have to be able to differentiate a data block from a
* header block when booting mail system.
*/
struct header_data_type {
long next_block; /* if header block, link to next block */
long from; /* idnum of the mail's sender */
long to; /* idnum of mail's recipient */
time_t mail_time; /* when was the letter mailed? */
};
/* size of the data part of a header block */
#define HEADER_BLOCK_DATASIZE \
(BLOCK_SIZE - sizeof(long) - sizeof(struct header_data_type) - sizeof(char))
/* size of the data part of a data block */
#define DATA_BLOCK_DATASIZE (BLOCK_SIZE - sizeof(long) - sizeof(char))
/* note that an extra space is allowed in all string fields for the
terminating null character. */
struct header_block_type_d {
long block_type; /* is this a header or data block? */
struct header_data_type header_data; /* other header data */
char txt[HEADER_BLOCK_DATASIZE+1]; /* actual text plus 1 for null */
};
struct data_block_type_d {
long block_type; /* -1 if header block, -2 if last data block
in mail, otherwise a link to the next */
char txt[DATA_BLOCK_DATASIZE+1]; /* actual text plus 1 for null */
};
typedef struct header_block_type_d header_block_type;
typedef struct data_block_type_d data_block_type;
struct position_list_type_d {
long position;
struct position_list_type_d *next;
};
typedef struct position_list_type_d position_list_type;
struct mail_index_type_d {
long recipient; /* who is this mail for? */
position_list_type *list_start; /* list of mail positions */
struct mail_index_type_d *next; /* link to next one */
};
typedef struct mail_index_type_d mail_index_type;

1149
src/medit.c Normal file

File diff suppressed because it is too large Load diff

287
src/mobact.c Normal file
View file

@ -0,0 +1,287 @@
/* ************************************************************************
* File: mobact.c Part of CircleMUD *
* Usage: Functions for generating intelligent (?) behavior in mobiles *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "spells.h"
#include "constants.h"
/* external globals */
extern int no_specials;
/* external functions */
ACMD(do_get);
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);
#define MOB_AGGR_TO_ALIGN (MOB_AGGR_EVIL | MOB_AGGR_NEUTRAL | MOB_AGGR_GOOD)
void mobile_activity(void)
{
struct char_data *ch, *next_ch, *vict;
struct obj_data *obj, *best_obj;
int door, found, max;
memory_rec *names;
for (ch = character_list; ch; ch = next_ch) {
next_ch = ch->next;
if (!IS_MOB(ch))
continue;
/* Examine call for special procedure */
if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
log("SYSERR: %s (#%d): Attempting to call non-existing mob function.",
GET_NAME(ch), GET_MOB_VNUM(ch));
REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC);
} else {
char actbuf[MAX_INPUT_LENGTH] = "";
if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, actbuf))
continue; /* go to next char */
}
}
/* If the mob has no specproc, do the default actions */
if (FIGHTING(ch) || !AWAKE(ch))
continue;
/* hunt a victim, if applicable */
hunt_victim(ch);
/* Scavenger (picking up objects) */
if (MOB_FLAGGED(ch, MOB_SCAVENGER))
if (world[IN_ROOM(ch)].contents && !rand_number(0, 10)) {
max = 1;
best_obj = NULL;
for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content)
if (CAN_GET_OBJ(ch, obj) && GET_OBJ_COST(obj) > max) {
best_obj = obj;
max = GET_OBJ_COST(obj);
}
if (best_obj != NULL) {
obj_from_room(best_obj);
obj_to_char(best_obj, ch);
act("$n gets $p.", FALSE, ch, best_obj, 0, TO_ROOM);
}
}
/* Mob Movement */
if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) &&
((door = rand_number(0, 18)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
!ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) &&
(!MOB_FLAGGED(ch, MOB_STAY_ZONE) ||
(world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) {
perform_move(ch, door, 1);
}
/* Aggressive Mobs */
if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) {
found = FALSE;
for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
continue;
if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict))
continue;
if (MOB_FLAGGED(ch, MOB_AGGRESSIVE ) ||
(MOB_FLAGGED(ch, MOB_AGGR_EVIL ) && IS_EVIL(vict)) ||
(MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) ||
(MOB_FLAGGED(ch, MOB_AGGR_GOOD ) && IS_GOOD(vict))) {
/* Can a master successfully control the charmed monster? */
if (aggressive_mob_on_a_leash(ch, ch->master, vict))
continue;
hit(ch, vict, TYPE_UNDEFINED);
found = TRUE;
}
}
}
/* Mob Memory */
if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
found = FALSE;
for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
continue;
for (names = MEMORY(ch); names && !found; names = names->next) {
if (names->id != GET_IDNUM(vict))
continue;
/* Can a master successfully control the charmed monster? */
if (aggressive_mob_on_a_leash(ch, ch->master, vict))
continue;
found = TRUE;
act("'Hey! You're the fiend that attacked me!!!', exclaims $n.", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, vict, TYPE_UNDEFINED);
}
}
}
/*
* Charmed Mob Rebellion
*
* In order to rebel, there need to be more charmed monsters
* than the person can feasibly control at a time. Then the
* mobiles have a chance based on the charisma of their leader.
*
* 1-4 = 0, 5-7 = 1, 8-10 = 2, 11-13 = 3, 14-16 = 4, 17-19 = 5, etc.
*/
if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && num_followers_charmed(ch->master) > (GET_CHA(ch->master) - 2) / 3) {
if (!aggressive_mob_on_a_leash(ch, ch->master, ch->master)) {
if (CAN_SEE(ch, ch->master) && !PRF_FLAGGED(ch->master, PRF_NOHASSLE))
hit(ch, ch->master, TYPE_UNDEFINED);
stop_follower(ch);
}
}
/* Helper Mobs */
if (MOB_FLAGGED(ch, MOB_HELPER) && !AFF_FLAGGED(ch, AFF_BLIND | AFF_CHARM)) {
found = FALSE;
for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) {
if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict))
continue;
if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict))
continue;
act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM);
hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
found = TRUE;
}
}
/* Add new mobile actions here */
} /* end for() */
}
/* Mob Memory Routines */
/* make ch remember victim */
void remember(struct char_data *ch, struct char_data *victim)
{
memory_rec *tmp;
bool present = FALSE;
if (!IS_NPC(ch) || IS_NPC(victim) || PRF_FLAGGED(victim, PRF_NOHASSLE))
return;
for (tmp = MEMORY(ch); tmp && !present; tmp = tmp->next)
if (tmp->id == GET_IDNUM(victim))
present = TRUE;
if (!present) {
CREATE(tmp, memory_rec, 1);
tmp->next = MEMORY(ch);
tmp->id = GET_IDNUM(victim);
MEMORY(ch) = tmp;
}
}
/* make ch forget victim */
void forget(struct char_data *ch, struct char_data *victim)
{
memory_rec *curr, *prev = NULL;
if (!(curr = MEMORY(ch)))
return;
while (curr && curr->id != GET_IDNUM(victim)) {
prev = curr;
curr = curr->next;
}
if (!curr)
return; /* person wasn't there at all. */
if (curr == MEMORY(ch))
MEMORY(ch) = curr->next;
else
prev->next = curr->next;
free(curr);
}
/* erase ch's memory */
void clearMemory(struct char_data *ch)
{
memory_rec *curr, *next;
curr = MEMORY(ch);
while (curr) {
next = curr->next;
free(curr);
curr = next;
}
MEMORY(ch) = NULL;
}
/*
* 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 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 int snarl_cmd;
int dieroll;
if (!master || !AFF_FLAGGED(slave, AFF_CHARM))
return (FALSE);
if (!snarl_cmd)
snarl_cmd = find_command("snarl");
/* Sit. Down boy! HEEEEeeeel! */
dieroll = rand_number(1, 20);
if (dieroll != 1 && (dieroll == 20 || dieroll > 10 - GET_CHA(master) + GET_INT(slave))) {
if (snarl_cmd > 0 && attack && !rand_number(0, 3)) {
char victbuf[MAX_NAME_LENGTH + 1];
strncpy(victbuf, GET_NAME(attack), sizeof(victbuf)); /* strncpy: OK */
victbuf[sizeof(victbuf) - 1] = '\0';
do_action(slave, victbuf, snarl_cmd, 0);
}
/* Success! But for how long? Hehe. */
return (TRUE);
}
/* So sorry, now you're a player killer... Tsk tsk. */
return (FALSE);
}

541
src/modify.c Normal file
View file

@ -0,0 +1,541 @@
/* ************************************************************************
* File: modify.c Part of CircleMUD *
* Usage: Run-time modification of game variables *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "comm.h"
#include "spells.h"
#include "mail.h"
#include "boards.h"
#include "improved-edit.h"
#include "oasis.h"
#include "tedit.h"
void show_string(struct descriptor_data *d, char *input);
extern struct spell_info_type spell_info[];
extern const char *unused_spellname; /* spell_parser.c */
/* local functions */
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",
"short",
"long",
"description",
"title",
"delete-description",
"\n"
};
/* maximum length for text field x+1 */
int length[] =
{
15,
60,
256,
240,
60
};
/* ************************************************************************
* modification of malloc'ed strings *
************************************************************************ */
/*
* Put '#if 1' here to erase ~, or roll your own method. A common idea
* is smash/show tilde to convert the tilde to another innocuous character
* to save and then back to display it. Whatever you do, at least keep the
* function around because other MUD packages use it, like mudFTP.
* -gg 9/9/98
*/
void smash_tilde(char *str)
{
/*
* Erase any _line ending_ tildes inserted in the editor.
* The load mechanism can't handle those, yet.
* -- Welcor 04/2003
*/
char *p = str;
for (; *p; p++)
if (*p == '~' && (*(p+1)=='\r' || *(p+1)=='\n' || *(p+1)=='\0'))
*p=' ';
}
/*
* Basic API function to start writing somewhere.
*
* 'data' isn't used in stock CircleMUD but you can use it to pass whatever
* else you may want through it. The improved editor patch when updated
* could use it to pass the old text buffer, for instance.
*/
void string_write(struct descriptor_data *d, char **writeto, size_t len, long mailto, void *data)
{
if (d->character && !IS_NPC(d->character))
SET_BIT(PLR_FLAGS(d->character), PLR_WRITING);
if (using_improved_editor)
d->backstr = (char *)data;
else if (data)
free(data);
d->str = writeto;
d->max_str = len;
d->mail_to = mailto;
}
/*
* Add user input to the 'current' string (as defined by d->str).
* This is still overly complex.
*/
void string_add(struct descriptor_data *d, char *str)
{
int action;
/* determine if this is the terminal string, and truncate if so */
/* changed to only accept '@' at the beginning of line - J. Elson 1/17/94 */
delete_doubledollar(str);
smash_tilde(str);
/* determine if this is the terminal string, and truncate if so */
/* changed to only accept '@' at the beginning of line - J. Elson 1/17/94 */
/* changed to only accept '@' if it's by itself - fnord 10/15/2004 */
if ((action = (*str == '@' && !str[1])))
*str = '\0';
else
if ((action = improved_editor_execute(d, str)) == STRINGADD_ACTION)
return;
if (action != STRINGADD_OK)
/* Do nothing. */ ;
else if (!(*d->str)) {
if (strlen(str) + 3 > d->max_str) { /* \r\n\0 */
send_to_char(d->character, "String too long - Truncated.\r\n");
strcpy(&str[d->max_str - 3], "\r\n"); /* strcpy: OK (size checked) */
CREATE(*d->str, char, d->max_str);
strcpy(*d->str, str); /* strcpy: OK (size checked) */
if (!using_improved_editor)
action = STRINGADD_SAVE;
} else {
CREATE(*d->str, char, strlen(str) + 3);
strcpy(*d->str, str); /* strcpy: OK (size checked) */
}
} else {
if (strlen(str) + strlen(*d->str) + 3 > d->max_str) { /* \r\n\0 */
send_to_char(d->character, "String too long. Last line skipped.\r\n");
if (!using_improved_editor)
action = STRINGADD_SAVE;
else if (action == STRINGADD_OK)
action = STRINGADD_ACTION; /* No appending \r\n\0, but still let them save. */
} else {
RECREATE(*d->str, char, strlen(*d->str) + strlen(str) + 3); /* \r\n\0 */
strcat(*d->str, str); /* strcat: OK (size precalculated) */
}
}
/*
* Common cleanup code.
*/
switch (action) {
case STRINGADD_ABORT:
switch (STATE(d)) {
case CON_CEDIT:
case CON_TEDIT:
case CON_REDIT:
case CON_MEDIT:
case CON_OEDIT:
case CON_PLR_DESC:
case CON_TRIGEDIT:
case CON_HEDIT:
free(*d->str);
*d->str = d->backstr;
d->backstr = NULL;
d->str = NULL;
break;
default:
log("SYSERR: string_add: Aborting write from unknown origin.");
break;
}
break;
case STRINGADD_SAVE:
if (d->str && *d->str && **d->str == '\0') {
free(*d->str);
*d->str = strdup("Nothing.\r\n");
}
if (d->backstr)
free(d->backstr);
d->backstr = NULL;
break;
case STRINGADD_ACTION:
break;
}
/* Ok, now final cleanup. */
if (action == STRINGADD_SAVE || action == STRINGADD_ABORT) {
int i;
struct {
int mode;
void (*func)(struct descriptor_data *d, int action);
} cleanup_modes[] = {
{ CON_CEDIT , cedit_string_cleanup },
{ CON_MEDIT , medit_string_cleanup },
{ CON_OEDIT , oedit_string_cleanup },
{ CON_REDIT , redit_string_cleanup },
{ CON_TEDIT , tedit_string_cleanup },
{ CON_TRIGEDIT, trigedit_string_cleanup },
{ CON_PLR_DESC , exdesc_string_cleanup },
{ CON_PLAYING, playing_string_cleanup },
{ CON_HEDIT, hedit_string_cleanup },
{ -1, NULL }
};
for (i = 0; cleanup_modes[i].func; i++)
if (STATE(d) == cleanup_modes[i].mode)
(*cleanup_modes[i].func)(d, action);
/* Common post cleanup code. */
d->str = NULL;
d->mail_to = 0;
d->max_str = 0;
if (d->character && !IS_NPC(d->character))
REMOVE_BIT(PLR_FLAGS(d->character), PLR_MAILING | PLR_WRITING);
} else if (action != STRINGADD_ACTION && strlen(*d->str) + 3 <= d->max_str) /* 3 = \r\n\0 */
strcat(*d->str, "\r\n");
}
void playing_string_cleanup(struct descriptor_data *d, int action)
{
if (PLR_FLAGGED(d->character, PLR_MAILING)) {
if (action == STRINGADD_SAVE && *d->str) {
store_mail(d->mail_to, GET_IDNUM(d->character), *d->str);
write_to_output(d, "Message sent!\r\n");
} else
write_to_output(d, "Mail aborted.\r\n");
free(*d->str);
free(d->str);
}
/*
* We have no way of knowing which slot the post was sent to so we can only give the message...
*/
if (d->mail_to >= BOARD_MAGIC) {
Board_save_board(d->mail_to - BOARD_MAGIC);
if (action == STRINGADD_ABORT)
write_to_output(d, "Post not aborted, use REMOVE <post #>.\r\n");
}
}
void exdesc_string_cleanup(struct descriptor_data *d, int action)
{
if (action == STRINGADD_ABORT)
write_to_output(d, "Description aborted.\r\n");
write_to_output(d, "%s", CONFIG_MENU);
STATE(d) = CON_MENU;
}
/* **********************************************************************
* Modification of character skills *
********************************************************************** */
ACMD(do_skillset)
{
struct char_data *vict;
char name[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH], help[MAX_STRING_LENGTH];
int skill, value, i, qend;
argument = one_argument(argument, name);
if (!*name) { /* no arguments. print an informative text */
send_to_char(ch, "Syntax: skillset <name> '<skill>' <value>\r\n"
"Skill being one of the following:\r\n");
for (qend = 0, i = 0; i <= TOP_SPELL_DEFINE; i++) {
if (spell_info[i].name == unused_spellname) /* This is valid. */
continue;
send_to_char(ch, "%18s", spell_info[i].name);
if (qend++ % 4 == 3)
send_to_char(ch, "\r\n");
}
if (qend % 4 != 0)
send_to_char(ch, "\r\n");
return;
}
if (!(vict = get_char_vis(ch, name, NULL, FIND_CHAR_WORLD))) {
send_to_char(ch, "%s", CONFIG_NOPERSON);
return;
}
skip_spaces(&argument);
/* If there is no chars in argument */
if (!*argument) {
send_to_char(ch, "Skill name expected.\r\n");
return;
}
if (*argument != '\'') {
send_to_char(ch, "Skill must be enclosed in: ''\r\n");
return;
}
/* Locate the last quote and lowercase the magic words (if any) */
for (qend = 1; argument[qend] && argument[qend] != '\''; qend++)
argument[qend] = LOWER(argument[qend]);
if (argument[qend] != '\'') {
send_to_char(ch, "Skill must be enclosed in: ''\r\n");
return;
}
strcpy(help, (argument + 1)); /* strcpy: OK (MAX_INPUT_LENGTH <= MAX_STRING_LENGTH) */
help[qend - 1] = '\0';
if ((skill = find_skill_num(help)) <= 0) {
send_to_char(ch, "Unrecognized skill.\r\n");
return;
}
argument += qend + 1; /* skip to next parameter */
argument = one_argument(argument, buf);
if (!*buf) {
send_to_char(ch, "Learned value expected.\r\n");
return;
}
value = atoi(buf);
if (value < 0) {
send_to_char(ch, "Minimum value for learned is 0.\r\n");
return;
}
if (value > 100) {
send_to_char(ch, "Max value for learned is 100.\r\n");
return;
}
if (IS_NPC(vict)) {
send_to_char(ch, "You can't set NPC skills.\r\n");
return;
}
/*
* find_skill_num() guarantees a valid spell_info[] index, or -1, and we
* checked for the -1 above so we are safe here.
*/
SET_SKILL(vict, skill, value);
mudlog(BRF, LVL_IMMORT, TRUE, "%s changed %s's %s to %d.", GET_NAME(ch), GET_NAME(vict), spell_info[skill].name, value);
send_to_char(ch, "You change %s's %s to %d.\r\n", GET_NAME(vict), spell_info[skill].name, value);
}
/*********************************************************************
* New Pagination Code
* Michael Buselli submitted the following code for an enhanced pager
* for CircleMUD. All functions below are his. --JE 8 Mar 96
*
*********************************************************************/
/* 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.
*/
char *next_page(char *str, struct char_data *ch)
{
int col = 1, line = 1;
for (;; str++) {
/* If end of string, return NULL. */
if (*str == '\0')
return (NULL);
/* If we're at the start of the next page, return this fact. */
else if (line > (GET_PAGE_LENGTH(ch) - (PRF_FLAGGED(ch, PRF_COMPACT) ? 1 : 2)))
return (str);
/* Check for the begining of an ANSI color code block. */
else if (*str == '\x1B')
str++;
else if (*str == '@') {
if (*(str + 1) != '@')
str++;
}
/* Check for everything else. */
else {
/* Carriage return puts us in column one. */
if (*str == '\r')
col = 1;
/* Newline puts us on the next line. */
else if (*str == '\n')
line++;
/* We need to check here and see if we are over the page width,
* and if so, compensate by going to the begining of the next line.
*/
else if (col++ > PAGE_WIDTH) {
col = 1;
line++;
}
}
}
}
/* Function that returns the number of pages in the string. */
int count_pages(char *str, struct char_data *ch)
{
int pages;
for (pages = 1; (str = next_page(str, ch)); pages++);
return (pages);
}
/* This function assigns all the pointers for showstr_vector for the
* page_string function, after showstr_vector has been allocated and
* showstr_count set.
*/
void paginate_string(char *str, struct descriptor_data *d)
{
int i;
if (d->showstr_count)
*(d->showstr_vector) = str;
for (i = 1; i < d->showstr_count && str; i++)
str = d->showstr_vector[i] = next_page(str, d->character);
d->showstr_page = 0;
}
/* The call that gets the paging ball rolling... */
void page_string(struct descriptor_data *d, char *str, int keep_internal)
{
char actbuf[MAX_INPUT_LENGTH] = "";
if (!d)
return;
if (!str || !*str)
return;
if ((GET_PAGE_LENGTH(d->character) < 5 || GET_PAGE_LENGTH(d->character) > 254))
GET_PAGE_LENGTH(d->character) = PAGE_LENGTH;
d->showstr_count = count_pages(str, d->character);
CREATE(d->showstr_vector, char *, d->showstr_count);
if (keep_internal) {
d->showstr_head = strdup(str);
paginate_string(d->showstr_head, d);
} else
paginate_string(str, d);
show_string(d, actbuf);
}
/* The call that displays the next page. */
void show_string(struct descriptor_data *d, char *input)
{
char buffer[MAX_STRING_LENGTH], buf[MAX_INPUT_LENGTH];
int diff;
any_one_arg(input, buf);
/* Q is for quit. :) */
if (LOWER(*buf) == 'q') {
free(d->showstr_vector);
d->showstr_vector = NULL;
d->showstr_count = 0;
if (d->showstr_head) {
free(d->showstr_head);
d->showstr_head = NULL;
}
return;
}
/* R is for refresh, so back up one page internally so we can display
* it again.
*/
else if (LOWER(*buf) == 'r')
d->showstr_page = MAX(0, d->showstr_page - 1);
/* B is for back, so back up two pages internally so we can display the
* correct page here.
*/
else if (LOWER(*buf) == 'b')
d->showstr_page = MAX(0, d->showstr_page - 2);
/* Feature to 'goto' a page. Just type the number of the page and you
* are there!
*/
else if (isdigit(*buf))
d->showstr_page = MAX(0, MIN(atoi(buf) - 1, d->showstr_count - 1));
else if (*buf) {
send_to_char(d->character, "Valid commands while paging are RETURN, Q, R, B, or a numeric value.\r\n");
return;
}
/* If we're displaying the last page, just send it to the character, and
* then free up the space we used.
*/
/* also send a @n - to make color stop bleeding. -- Welcor */
if (d->showstr_page + 1 >= d->showstr_count) {
send_to_char(d->character, "%s@n", d->showstr_vector[d->showstr_page]);
free(d->showstr_vector);
d->showstr_vector = NULL;
d->showstr_count = 0;
if (d->showstr_head) {
free(d->showstr_head);
d->showstr_head = NULL;
}
}
/* Or if we have more to show.... */
else {
diff = d->showstr_vector[d->showstr_page + 1] - d->showstr_vector[d->showstr_page];
if (diff > MAX_STRING_LENGTH - 3) /* 3=\r\n\0 */
diff = MAX_STRING_LENGTH - 3;
strncpy(buffer, d->showstr_vector[d->showstr_page], diff); /* strncpy: OK (size truncated above) */
/*
* Fix for prompt overwriting last line in compact mode submitted by
* Peter Ajamian <peter@pajamian.dhs.org> on 04/21/2001
*/
if (buffer[diff - 2] == '\r' && buffer[diff - 1]=='\n')
buffer[diff] = '\0';
else if (buffer[diff - 2] == '\n' && buffer[diff - 1] == '\r')
/* This is backwards. Fix it. */
strcpy(buffer + diff - 2, "\r\n"); /* strcpy: OK (size checked) */
else if (buffer[diff - 1] == '\r' || buffer[diff - 1] == '\n')
/* Just one of \r\n. Overwrite it. */
strcpy(buffer + diff - 1, "\r\n"); /* strcpy: OK (size checked) */
else
/* Tack \r\n onto the end to fix bug with prompt overwriting last line. */
strcpy(buffer + diff, "\r\n"); /* strcpy: OK (size checked) */
send_to_char(d->character, "%s", buffer);
d->showstr_page++;
}
}

422
src/oasis.c Normal file
View file

@ -0,0 +1,422 @@
/************************************************************************
* OasisOLC - General / oasis.c v2.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "interpreter.h"
#include "comm.h"
#include "db.h"
#include "shop.h"
#include "genolc.h"
#include "genmob.h"
#include "genshp.h"
#include "genzon.h"
#include "genwld.h"
#include "genobj.h"
#include "oasis.h"
#include "screen.h"
#include "dg_olc.h"
/******************************************************************************/
/** External Functions **/
/******************************************************************************/
int is_name(const char *str, const char *namelist);
/******************************************************************************/
/** Internal Data Structures **/
/******************************************************************************/
struct olc_scmd_info_t {
const char *text;
int con_type;
} olc_scmd_info[] = {
{ "room", CON_REDIT },
{ "object", CON_OEDIT },
{ "zone", CON_ZEDIT },
{ "mobile", CON_MEDIT },
{ "shop", CON_SEDIT },
{ "config", CON_CEDIT },
{ "trigger", CON_TRIGEDIT },
{ "action", CON_AEDIT },
{ "help", CON_HEDIT },
{ "\n", -1 }
};
const char *nrm, *grn, *cyn, *yel;
/******************************************************************************/
/** Internal Functions **/
/******************************************************************************/
void free_config(struct config_data *data);
/* -------------------------------------------------------------------------- */
/*
* Only player characters should be using OLC anyway.
*/
void clear_screen(struct descriptor_data *d)
{
if (PRF_FLAGGED(d->character, PRF_CLS))
write_to_output(d, "");
}
/* -------------------------------------------------------------------------- */
/*
* Exported ACMD do_oasis function.
*
* This function is the OLC interface. It deals with all the
* generic OLC stuff, then passes control to the sub-olc sections.
*
* UPDATE:
* I believe that yes, putting the code together that is common in all of the
* olc functions is good to a certain extent, but the do_oasis command was
* getting ridiculous. Therefore, I have separated them into separate
* functions that get called from in do_oasis....yes, similar code, but it is
* easier to handle.... - Kip Potter
*/
ACMD(do_oasis)
{
/*
* No screwing around as a mobile.
*/
if (IS_NPC(ch) || !ch->desc)
return;
/*
* Prevent forcing people in OLC to edit other stuff.
* 'force' just lets command_interpreter() handle the input,
* regardless of the state of the victim.
* This can wreck havoc if people are i OLC already
* - ie. their input would have been redirected by nanny(), and
* never get to command_interpreter().
* -- Welcor 09/03
* - thanks to Mark Garringer (zizazat@hotmail.com) for the bug report.
*/
if (STATE(ch->desc) != CON_PLAYING)
return;
switch (subcmd) {
/*
* The command to see what needs to be saved, typically 'olc'.
*/
case SCMD_OLC_SAVEINFO:
do_show_save_list(ch);
break;
case SCMD_OASIS_CEDIT:
do_oasis_cedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_ZEDIT:
do_oasis_zedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_REDIT:
do_oasis_redit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_OEDIT:
do_oasis_oedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_MEDIT:
do_oasis_medit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_SEDIT:
do_oasis_sedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_RLIST:
case SCMD_OASIS_MLIST:
case SCMD_OASIS_OLIST:
case SCMD_OASIS_SLIST:
case SCMD_OASIS_ZLIST:
case SCMD_OASIS_TLIST:
do_oasis_list(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_LINKS:
do_oasis_links(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_TRIGEDIT:
do_oasis_trigedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_AEDIT:
do_oasis_aedit(ch, argument, cmd, subcmd);
break;
case SCMD_OASIS_HEDIT:
do_oasis_hedit(ch, argument, cmd, subcmd);
break;
default:
log("SYSERR: (OLC) Invalid subcmd passed to do_oasis, subcmd - (%d)", subcmd);
return;
}
return;
}
/*------------------------------------------------------------*\
Exported utilities
\*------------------------------------------------------------*/
/*
* Set the colour string pointers for that which this char will
* see at color level NRM. Changing the entries here will change
* the colour scheme throughout the OLC.
*/
void get_char_colors(struct char_data *ch)
{
nrm = CCNRM(ch, C_NRM);
grn = CCGRN(ch, C_NRM);
cyn = CCCYN(ch, C_NRM);
yel = CCYEL(ch, C_NRM);
}
/*
* This procedure frees up the strings and/or the structures
* attatched to a descriptor, sets all flags back to how they
* should be.
*/
void cleanup_olc(struct descriptor_data *d, byte cleanup_type)
{
/*
* Clean up WHAT?
*/
if (d->olc == NULL)
return;
/*
* Check for a room. free_room doesn't perform
* sanity checks, we must be careful here.
*/
if (OLC_ROOM(d)) {
switch (cleanup_type) {
case CLEANUP_ALL:
/* free(OLC_SCRIPT(d)) equivalent */
free_proto_script(OLC_ROOM(d), WLD_TRIGGER);
free_room(OLC_ROOM(d));
break;
case CLEANUP_STRUCTS:
free(OLC_ROOM(d));
break;
case CLEANUP_CONFIG:
free_config(OLC_CONFIG(d));
break;
default: /* The caller has screwed up. */
log("SYSERR: cleanup_olc: Unknown type!");
break;
}
}
/*
* Check for an existing object in the OLC. The strings
* aren't part of the prototype any longer. They get added
* with strdup().
*/
if (OLC_OBJ(d)) {
free_object_strings(OLC_OBJ(d));
free(OLC_OBJ(d));
}
/*
* Check for a mob. free_mobile() makes sure strings are not in
* the prototype.
*/
if (OLC_MOB(d))
free_mobile(OLC_MOB(d));
/*
* Check for a zone. cleanup_type is irrelevant here, free() everything.
*/
if (OLC_ZONE(d)) {
free(OLC_ZONE(d)->name);
free(OLC_ZONE(d)->cmd);
free(OLC_ZONE(d));
}
/*
* Check for a shop. free_shop doesn't perform sanity checks, we must
* be careful here.
* OLC_SHOP(d) is a _copy_ - no pointers to the original. Just go ahead
* and free it all.
*/
if (OLC_SHOP(d))
free_shop(OLC_SHOP(d));
/*. Check for aedit stuff -- M. Scott */
if (OLC_ACTION(d)) {
switch(cleanup_type) {
case CLEANUP_ALL:
free_action(OLC_ACTION(d));
break;
case CLEANUP_STRUCTS:
free(OLC_ACTION(d));
break;
default:
/* Caller has screwed up */
break;
}
}
/* Used for cleanup of Hedit */
if (OLC_HELP(d)) {
switch(cleanup_type) {
case CLEANUP_ALL:
free_help(OLC_HELP(d));
break;
case CLEANUP_STRUCTS:
free(OLC_HELP(d));
break;
default:
break;
}
}
/* free storage if allocated (for tedit and aedit) */
/* and Triggers */
/*
* this is the command list - it's been copied to disk already,
* so just free it -- Welcor
*/
if (OLC_STORAGE(d)) {
free(OLC_STORAGE(d));
OLC_STORAGE(d) = NULL;
}
/*
* Free this one regardless. If we've left olc, we've either made
* a fresh copy of it in the trig index, or we lost connection.
* Either way, we need to get rid of this.
*/
if (OLC_TRIG(d)) {
free_trigger(OLC_TRIG(d));
OLC_TRIG(d) = NULL;
}
/*
* OLC_SCRIPT is always set as trig_proto of OLC_OBJ/MOB/ROOM.
* Therefore it should not be free'd here.
*/
/*
* Restore descriptor playing status.
*/
if (d->character) {
REMOVE_BIT(PLR_FLAGS(d->character), PLR_WRITING);
act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM);
if (cleanup_type == CLEANUP_CONFIG)
mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character));
else if (STATE(d) == CON_TEDIT)
mudlog(BRF, LVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character));
else if (STATE(d) == CON_HEDIT)
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s stops editing help files.", GET_NAME(d->character));
else
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character));
STATE(d) = CON_PLAYING;
}
free(d->olc);
d->olc = NULL;
}
/*
* This function is an exact duplicate of the tag_argument function found in
* one of the ascii patches located on the circlemud ftp website.
*/
void split_argument(char *argument, char *tag)
{
char *tmp = argument, *ttag = tag, *wrt = argument;
int i;
for (i = 0; *tmp; tmp++, i++) {
if (*tmp != ' ' && *tmp != '=')
*(ttag++) = *tmp;
else if (*tmp == '=')
break;
}
*ttag = '\0';
while (*tmp == '=' || *tmp == ' ')
tmp++;
while (*tmp)
*(wrt++) = *(tmp++);
*wrt = '\0';
}
void free_config(struct config_data *data)
{
/****************************************************************************/
/** Free strings. **/
/****************************************************************************/
free_strings(data, OASIS_CFG);
/****************************************************************************/
/** Free the data structure. **/
/****************************************************************************/
free(data);
}
/******************************************************************************/
/** **/
/** Function : can_edit_zone() **/
/** **/
/** Description : Checks to see if a builder can modify the specified **/
/** zone. **/
/** **/
/** Arguments : **/
/** ch **/
/** The character requesting access to modify this zone. **/
/** rnum **/
/** The real number of the zone attempted to be modified. **/
/** **/
/** Returns : Returns TRUE if the builder has access, otherwise **/
/** FALSE. **/
/** **/
/******************************************************************************/
int can_edit_zone(struct char_data *ch, zone_rnum rnum)
{
/* no access if called with bad arguments */
if (!ch->desc || IS_NPC(ch) || rnum == NOWHERE)
return FALSE;
if (rnum == HEDIT_PERMISSION)
return TRUE;
/* always access if ch is high enough level */
if (GET_LEVEL(ch) >= LVL_GRGOD)
return (TRUE);
/* always access if a player helped build the zone in the first place */
if (is_name(GET_NAME(ch), zone_table[rnum].builders))
return (TRUE);
/* no access if you haven't been assigned a zone */
if (GET_OLC_ZONE(ch) == NOWHERE) {
return FALSE;
}
/* no access if you're not at least LVL_BUILDER */
if (GET_LEVEL(ch) < LVL_BUILDER)
return FALSE;
/* always access if you're assigned to this zone */
if (real_zone(GET_OLC_ZONE(ch)) == rnum)
return TRUE;
return (FALSE);
}

730
src/oasis.h Normal file
View file

@ -0,0 +1,730 @@
/************************************************************************
* OasisOLC - General / oasis.h v2.0 *
* Original author: Levork *
* Copyright 1996 by Harvey Gilpin *
* Copyright 1997-2001 by George Greer (greerga@circlemud.org) *
************************************************************************/
#define _OASISOLC 0x206 /* 2.0.6 */
/*
* Used to determine what version of OasisOLC is installed.
*
* Ex: #if _OASISOLC >= OASIS_VERSION(2,0,0)
*/
#define OASIS_VERSION(x,y,z) (((x) << 8 | (y) << 4 | (z))
#define AEDIT_PERMISSION 999 /* arbitrary number higher than max zone vnum*/
#define HEDIT_PERMISSION 888 /* arbitrary number higher then max zone vnum*/
/*
* Set this to 1 to enable MobProg support. MobProgs are available on
* the CircleMUD FTP site in the "contrib/scripting/" directory.
*
* -- THIS WILL NOT WORK WITHOUT MobProgs INSTALLED. --
* -- OasisOLC DOES NOT COME WITH THEM. -- Loud enough for you?
*
* It might work with DG Scripts (successor to MobProgs) but I haven't
* tried, nor have I heard of anyone trying.
*/
#define CONFIG_OASIS_MPROG 0
/*
* Macros, defines, structs and globals for the OLC suite. You will need
* to adjust these numbers if you ever add more.
*/
#define NUM_ROOM_FLAGS 16
#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
#if CONFIG_OASIS_MPROG
/*
* Define this to how many MobProg scripts you have.
*/
#define NUM_PROGS 12
#endif
/* -------------------------------------------------------------------------- */
/*
* Limit information.
*/
#define MAX_ROOM_NAME 75
#define MAX_MOB_NAME 50
#define MAX_OBJ_NAME 50
#define MAX_ROOM_DESC 2048
#define MAX_EXIT_DESC 256
#define MAX_EXTRA_DESC 512
#define MAX_MOB_DESC 1024
#define MAX_OBJ_DESC 512
#define MAX_DUPLICATES 100 /* when loading in zedit */
/* arbitrary limits - roll your own */
/* max weapon is 50d50 .. avg. 625 dam... */
#define MAX_WEAPON_SDICE 50
#define MAX_WEAPON_NDICE 50
#define MAX_OBJ_WEIGHT 1000000
#define MAX_OBJ_COST 2000000
#define MAX_OBJ_RENT 2000000
#define MAX_CONTAINER_SIZE 10000
#define MAX_MOB_GOLD 100000
#define MAX_MOB_EXP 150000
/* this is one mud year.. */
#define MAX_OBJ_TIMER 1071000
/* this defines how much memory is alloacted for 'bit strings' when
* saving in OLC. Remember to change it if you go for longer bitvectors.
*/
#define BIT_STRING_LENGTH 33
/*
* The data types for miscellaneous functions.
*/
#define OASIS_WLD 0
#define OASIS_MOB 1
#define OASIS_OBJ 2
#define OASIS_ZON 3
#define OASIS_EXI 4
#define OASIS_CFG 5
/*
* Utilities exported from olc.c.
* -- Umm, shouldn't this say 'from oasis.c' now??? * Mythran
*/
void cleanup_olc(struct descriptor_data *d, byte cleanup_type);
void get_char_colors(struct char_data *ch);
void split_argument(char *argument, char *tag);
/*
* OLC structures.
*/
/* -------------------------------------------------------------------------- */
/*
* The following defines used to be in config.c.
*/
#define NO 0
#define YES 1
struct oasis_olc_data {
int mode; /* how to parse input */
zone_rnum zone_num; /* current zone */
room_vnum number; /* vnum of subject */
int value; /* mostly 'has changed' flag*/
char *storage; /* used for 'tedit' */
struct char_data *mob; /* used for 'medit' */
struct room_data *room; /* used for 'redit' */
struct obj_data *obj; /* used for 'oedit' */
struct zone_data *zone; /* used for 'zedit' */
struct shop_data *shop; /* used for 'sedit' */
struct config_data *config; /* used for 'cedit' */
struct extra_descr_data *desc; /* used in '[r|o|m]edit' */
#if CONFIG_OASIS_MPROG /* */
int total_mprogs; /* */
struct mob_prog_data *mprog; /* */
struct mob_prog_data *mprogl; /* */
#endif
struct social_messg *action; /* Aedit uses this one */
struct trig_data *trig;
int script_mode;
int trigger_position;
int item_type;
struct trig_proto_list *script; /* for assigning triggers in [r|o|m]edit*/
struct help_index_element*help; /* Hedit uses this */
};
/*
* Exported globals.
*/
extern const char *nrm, *grn, *cyn, *yel;
/*
* Descriptor access macros.
*/
#define OLC(d) ((d)->olc)
#define OLC_MODE(d) (OLC(d)->mode) /* Parse input mode. */
#define OLC_NUM(d) (OLC(d)->number) /* Room/Obj VNUM. */
#define OLC_VAL(d) (OLC(d)->value) /* Scratch variable. */
#define OLC_ZNUM(d) (OLC(d)->zone_num) /* Real zone number. */
#define OLC_STORAGE(d) (OLC(d)->storage) /* char pointer. */
#define OLC_ROOM(d) (OLC(d)->room) /* Room structure. */
#define OLC_OBJ(d) (OLC(d)->obj) /* Object structure. */
#define OLC_ZONE(d) (OLC(d)->zone) /* Zone structure. */
#define OLC_MOB(d) (OLC(d)->mob) /* Mob structure. */
#define OLC_SHOP(d) (OLC(d)->shop) /* Shop structure. */
#define OLC_DESC(d) (OLC(d)->desc) /* Extra description. */
#define OLC_CONFIG(d) (OLC(d)->config) /* Config structure. */
#define OLC_TRIG(d) (OLC(d)->trig) /* Trigger structure. */
#if CONFIG_OASIS_MPROG
#define OLC_MPROG(d) (OLC(d)->mprog) /* Temporary MobProg. */
#define OLC_MPROGL(d) (OLC(d)->mprogl) /* MobProg list. */
#define OLC_MTOTAL(d) (OLC(d)->total_mprogs) /* Total mprog number. */
#endif
#define OLC_ACTION(d) (OLC(d)->action) /* Action structure */
#define OLC_HELP(d) (OLC(d)->help) /* Hedit structure */
/*
* Other macros.
*/
#define OLC_EXIT(d) (OLC_ROOM(d)->dir_option[OLC_VAL(d)])
/*
* Cleanup types.
*/
#define CLEANUP_ALL 1 /* Free the whole lot. */
#define CLEANUP_STRUCTS 2 /* Don't free strings. */
#define CLEANUP_CONFIG 3 /* Used just to send proper message. */
/* Submodes of AEDIT connectedness */
#define AEDIT_CONFIRM_SAVESTRING 0
#define AEDIT_CONFIRM_EDIT 1
#define AEDIT_CONFIRM_ADD 2
#define AEDIT_MAIN_MENU 3
#define AEDIT_ACTION_NAME 4
#define AEDIT_SORT_AS 5
#define AEDIT_MIN_CHAR_POS 6
#define AEDIT_MIN_VICT_POS 7
#define AEDIT_HIDDEN_FLAG 8
#define AEDIT_MIN_CHAR_LEVEL 9
#define AEDIT_NOVICT_CHAR 10
#define AEDIT_NOVICT_OTHERS 11
#define AEDIT_VICT_CHAR_FOUND 12
#define AEDIT_VICT_OTHERS_FOUND 13
#define AEDIT_VICT_VICT_FOUND 14
#define AEDIT_VICT_NOT_FOUND 15
#define AEDIT_SELF_CHAR 16
#define AEDIT_SELF_OTHERS 17
#define AEDIT_VICT_CHAR_BODY_FOUND 18
#define AEDIT_VICT_OTHERS_BODY_FOUND 19
#define AEDIT_VICT_VICT_BODY_FOUND 20
#define AEDIT_OBJ_CHAR_FOUND 21
#define AEDIT_OBJ_OTHERS_FOUND 22
/*
* Submodes of OEDIT connectedness.
*/
#define OEDIT_MAIN_MENU 1
#define OEDIT_EDIT_NAMELIST 2
#define OEDIT_SHORTDESC 3
#define OEDIT_LONGDESC 4
#define OEDIT_ACTDESC 5
#define OEDIT_TYPE 6
#define OEDIT_EXTRAS 7
#define OEDIT_WEAR 8
#define OEDIT_WEIGHT 9
#define OEDIT_COST 10
#define OEDIT_COSTPERDAY 11
#define OEDIT_TIMER 12
#define OEDIT_VALUE_1 13
#define OEDIT_VALUE_2 14
#define OEDIT_VALUE_3 15
#define OEDIT_VALUE_4 16
#define OEDIT_APPLY 17
#define OEDIT_APPLYMOD 18
#define OEDIT_EXTRADESC_KEY 19
#define OEDIT_CONFIRM_SAVEDB 20
#define OEDIT_CONFIRM_SAVESTRING 21
#define OEDIT_PROMPT_APPLY 22
#define OEDIT_EXTRADESC_DESCRIPTION 23
#define OEDIT_EXTRADESC_MENU 24
#define OEDIT_LEVEL 25
#define OEDIT_PERM 26
#define OEDIT_DELETE 27
/*
* Submodes of REDIT connectedness.
*/
#define REDIT_MAIN_MENU 1
#define REDIT_NAME 2
#define REDIT_DESC 3
#define REDIT_FLAGS 4
#define REDIT_SECTOR 5
#define REDIT_EXIT_MENU 6
#define REDIT_CONFIRM_SAVEDB 7
#define REDIT_CONFIRM_SAVESTRING 8
#define REDIT_EXIT_NUMBER 9
#define REDIT_EXIT_DESCRIPTION 10
#define REDIT_EXIT_KEYWORD 11
#define REDIT_EXIT_KEY 12
#define REDIT_EXIT_DOORFLAGS 13
#define REDIT_EXTRADESC_MENU 14
#define REDIT_EXTRADESC_KEY 15
#define REDIT_EXTRADESC_DESCRIPTION 16
#define REDIT_DELETE 17
/*
* Submodes of ZEDIT connectedness.
*/
#define ZEDIT_MAIN_MENU 0
#define ZEDIT_DELETE_ENTRY 1
#define ZEDIT_NEW_ENTRY 2
#define ZEDIT_CHANGE_ENTRY 3
#define ZEDIT_COMMAND_TYPE 4
#define ZEDIT_IF_FLAG 5
#define ZEDIT_ARG1 6
#define ZEDIT_ARG2 7
#define ZEDIT_ARG3 8
#define ZEDIT_ZONE_NAME 9
#define ZEDIT_ZONE_LIFE 10
#define ZEDIT_ZONE_BOT 11
#define ZEDIT_ZONE_TOP 12
#define ZEDIT_ZONE_RESET 13
#define ZEDIT_CONFIRM_SAVESTRING 14
#define ZEDIT_ZONE_BUILDERS 15
#define ZEDIT_SARG1 20
#define ZEDIT_SARG2 21
/*
* Submodes of MEDIT connectedness.
*/
#define MEDIT_MAIN_MENU 0
#define MEDIT_ALIAS 1
#define MEDIT_S_DESC 2
#define MEDIT_L_DESC 3
#define MEDIT_D_DESC 4
#define MEDIT_NPC_FLAGS 5
#define MEDIT_AFF_FLAGS 6
#define MEDIT_CONFIRM_SAVESTRING 7
/*
* Numerical responses.
*/
#define MEDIT_NUMERICAL_RESPONSE 10
#define MEDIT_SEX 11
#define MEDIT_HITROLL 12
#define MEDIT_DAMROLL 13
#define MEDIT_NDD 14
#define MEDIT_SDD 15
#define MEDIT_NUM_HP_DICE 16
#define MEDIT_SIZE_HP_DICE 17
#define MEDIT_ADD_HP 18
#define MEDIT_AC 19
#define MEDIT_EXP 20
#define MEDIT_GOLD 21
#define MEDIT_POS 22
#define MEDIT_DEFAULT_POS 23
#define MEDIT_ATTACK 24
#define MEDIT_LEVEL 25
#define MEDIT_ALIGNMENT 26
#define MEDIT_DELETE 27
#if CONFIG_OASIS_MPROG
#define MEDIT_MPROG 27
#define MEDIT_CHANGE_MPROG 28
#define MEDIT_MPROG_COMLIST 29
#define MEDIT_MPROG_ARGS 30
#define MEDIT_MPROG_TYPE 31
#define MEDIT_PURGE_MPROG 32
#endif
/*
* Submodes of SEDIT connectedness.
*/
#define SEDIT_MAIN_MENU 0
#define SEDIT_CONFIRM_SAVESTRING 1
#define SEDIT_NOITEM1 2
#define SEDIT_NOITEM2 3
#define SEDIT_NOCASH1 4
#define SEDIT_NOCASH2 5
#define SEDIT_NOBUY 6
#define SEDIT_BUY 7
#define SEDIT_SELL 8
#define SEDIT_PRODUCTS_MENU 11
#define SEDIT_ROOMS_MENU 12
#define SEDIT_NAMELIST_MENU 13
#define SEDIT_NAMELIST 14
/*
* Numerical responses.
*/
#define SEDIT_NUMERICAL_RESPONSE 20
#define SEDIT_OPEN1 21
#define SEDIT_OPEN2 22
#define SEDIT_CLOSE1 23
#define SEDIT_CLOSE2 24
#define SEDIT_KEEPER 25
#define SEDIT_BUY_PROFIT 26
#define SEDIT_SELL_PROFIT 27
#define SEDIT_TYPE_MENU 29
#define SEDIT_DELETE_TYPE 30
#define SEDIT_DELETE_PRODUCT 31
#define SEDIT_NEW_PRODUCT 32
#define SEDIT_DELETE_ROOM 33
#define SEDIT_NEW_ROOM 34
#define SEDIT_SHOP_FLAGS 35
#define SEDIT_NOTRADE 36
/*
* Submodes of CEDIT connectedness.
*/
#define CEDIT_MAIN_MENU 0
#define CEDIT_CONFIRM_SAVESTRING 1
#define CEDIT_GAME_OPTIONS_MENU 2
#define CEDIT_CRASHSAVE_OPTIONS_MENU 3
#define CEDIT_OPERATION_OPTIONS_MENU 4
#define CEDIT_DISP_EXPERIENCE_MENU 5
#define CEDIT_ROOM_NUMBERS_MENU 6
#define CEDIT_AUTOWIZ_OPTIONS_MENU 7
#define CEDIT_OK 8
#define CEDIT_NOPERSON 9
#define CEDIT_NOEFFECT 10
#define CEDIT_DFLT_IP 11
#define CEDIT_DFLT_DIR 12
#define CEDIT_LOGNAME 13
#define CEDIT_MENU 14
#define CEDIT_WELC_MESSG 15
#define CEDIT_START_MESSG 16
/*
* Numerical responses.
*/
#define CEDIT_NUMERICAL_RESPONSE 20
#define CEDIT_LEVEL_CAN_SHOUT 21
#define CEDIT_HOLLER_MOVE_COST 22
#define CEDIT_TUNNEL_SIZE 23
#define CEDIT_MAX_EXP_GAIN 24
#define CEDIT_MAX_EXP_LOSS 25
#define CEDIT_MAX_NPC_CORPSE_TIME 26
#define CEDIT_MAX_PC_CORPSE_TIME 27
#define CEDIT_IDLE_VOID 28
#define CEDIT_IDLE_RENT_TIME 29
#define CEDIT_IDLE_MAX_LEVEL 30
#define CEDIT_DTS_ARE_DUMPS 31
#define CEDIT_LOAD_INTO_INVENTORY 32
#define CEDIT_TRACK_THROUGH_DOORS 33
#define CEDIT_IMMORT_LEVEL_OK 34
#define CEDIT_MAX_OBJ_SAVE 35
#define CEDIT_MIN_RENT_COST 36
#define CEDIT_AUTOSAVE_TIME 37
#define CEDIT_CRASH_FILE_TIMEOUT 38
#define CEDIT_RENT_FILE_TIMEOUT 39
#define CEDIT_MORTAL_START_ROOM 40
#define CEDIT_IMMORT_START_ROOM 41
#define CEDIT_FROZEN_START_ROOM 42
#define CEDIT_DONATION_ROOM_1 43
#define CEDIT_DONATION_ROOM_2 44
#define CEDIT_DONATION_ROOM_3 45
#define CEDIT_DFLT_PORT 46
#define CEDIT_MAX_PLAYING 47
#define CEDIT_MAX_FILESIZE 48
#define CEDIT_MAX_BAD_PWS 49
#define CEDIT_SITEOK_EVERYONE 50
#define CEDIT_NAMESERVER_IS_SLOW 51
#define CEDIT_USE_AUTOWIZ 52
#define CEDIT_MIN_WIZLIST_LEV 53
/* Hedit Submodes of connectedness. */
#define HEDIT_MAIN_MENU 0
#define HEDIT_ENTRY 1
#define HEDIT_MIN_LEVEL 2
#define HEDIT_KEYWORDS 3
#define HEDIT_CONFIRM_SAVESTRING 4
#define HEDIT_LIST 0 /* Define True, for logging help - FUTURE USE */
/* -------------------------------------------------------------------------- */
#ifndef __GENOLC_C__
/*
* 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 *);
int can_edit_zone(struct char_data *ch, zone_rnum rnum);
ACMD(do_oasis);
/*
* Prototypes, to be moved later.
*/
void medit_free_mobile(struct char_data *mob);
void medit_setup_new(struct descriptor_data *d);
void medit_setup_existing(struct descriptor_data *d, int rmob_num);
void init_mobile(struct char_data *mob);
void medit_save_internally(struct descriptor_data *d);
void medit_save_to_disk(zone_vnum zone_num);
void medit_disp_positions(struct descriptor_data *d);
void medit_disp_mprog(struct descriptor_data *d);
void medit_change_mprog(struct descriptor_data *d);
void medit_disp_mprog_types(struct descriptor_data *d);
void medit_disp_sex(struct descriptor_data *d);
void medit_disp_attack_types(struct descriptor_data *d);
void medit_disp_mob_flags(struct descriptor_data *d);
void medit_disp_aff_flags(struct descriptor_data *d);
void medit_disp_menu(struct descriptor_data *d);
void medit_parse(struct descriptor_data *d, char *arg);
void medit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_medit);
void oedit_setup_new(struct descriptor_data *d);
void oedit_setup_existing(struct descriptor_data *d, int real_num);
void oedit_save_internally(struct descriptor_data *d);
void oedit_save_to_disk(int zone_num);
void oedit_disp_container_flags_menu(struct descriptor_data *d);
void oedit_disp_extradesc_menu(struct descriptor_data *d);
void oedit_disp_prompt_apply_menu(struct descriptor_data *d);
void oedit_liquid_type(struct descriptor_data *d);
void oedit_disp_apply_menu(struct descriptor_data *d);
void oedit_disp_weapon_menu(struct descriptor_data *d);
void oedit_disp_spells_menu(struct descriptor_data *d);
void oedit_disp_val1_menu(struct descriptor_data *d);
void oedit_disp_val2_menu(struct descriptor_data *d);
void oedit_disp_val3_menu(struct descriptor_data *d);
void oedit_disp_val4_menu(struct descriptor_data *d);
void oedit_disp_type_menu(struct descriptor_data *d);
void oedit_disp_extra_menu(struct descriptor_data *d);
void oedit_disp_wear_menu(struct descriptor_data *d);
void oedit_disp_menu(struct descriptor_data *d);
void oedit_parse(struct descriptor_data *d, char *arg);
void oedit_disp_perm_menu(struct descriptor_data *d);
void oedit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_oedit);
void redit_string_cleanup(struct descriptor_data *d, int terminator);
void redit_setup_new(struct descriptor_data *d);
void redit_setup_existing(struct descriptor_data *d, int real_num);
void redit_save_internally(struct descriptor_data *d);
void redit_save_to_disk(zone_vnum zone_num);
void redit_disp_extradesc_menu(struct descriptor_data *d);
void redit_disp_exit_menu(struct descriptor_data *d);
void redit_disp_exit_flag_menu(struct descriptor_data *d);
void redit_disp_flag_menu(struct descriptor_data *d);
void redit_disp_sector_menu(struct descriptor_data *d);
void redit_disp_menu(struct descriptor_data *d);
void redit_parse(struct descriptor_data *d, char *arg);
void free_room(struct room_data *room);
ACMD(do_oasis_redit);
void sedit_setup_new(struct descriptor_data *d);
void sedit_setup_existing(struct descriptor_data *d, int rshop_num);
void sedit_save_internally(struct descriptor_data *d);
void sedit_save_to_disk(int zone_num);
void sedit_products_menu(struct descriptor_data *d);
void sedit_compact_rooms_menu(struct descriptor_data *d);
void sedit_rooms_menu(struct descriptor_data *d);
void sedit_namelist_menu(struct descriptor_data *d);
void sedit_shop_flags_menu(struct descriptor_data *d);
void sedit_no_trade_menu(struct descriptor_data *d);
void sedit_types_menu(struct descriptor_data *d);
void sedit_disp_menu(struct descriptor_data *d);
void sedit_parse(struct descriptor_data *d, char *arg);
ACMD(do_oasis_sedit);
void zedit_setup(struct descriptor_data *d, int room_num);
void zedit_new_zone(struct char_data *ch, zone_vnum vzone_num, room_vnum bottom, room_vnum top);
void zedit_create_index(int znum, char *type);
void zedit_save_internally(struct descriptor_data *d);
void zedit_save_to_disk(int zone_num);
void zedit_disp_menu(struct descriptor_data *d);
void zedit_disp_comtype(struct descriptor_data *d);
void zedit_disp_arg1(struct descriptor_data *d);
void zedit_disp_arg2(struct descriptor_data *d);
void zedit_disp_arg3(struct descriptor_data *d);
void zedit_parse(struct descriptor_data *d, char *arg);
ACMD(do_oasis_zedit);
void cedit_setup(struct descriptor_data *d);
void cedit_parse(struct descriptor_data *d, char *arg);
void cedit_save_to_disk( void );
void cedit_string_cleanup(struct descriptor_data *d, int terminator);
ACMD(do_oasis_cedit);
void trigedit_parse(struct descriptor_data *d, char *arg);
void trigedit_setup_existing(struct descriptor_data *d, int rtrg_num);
void trigedit_setup_new(struct descriptor_data *d);
ACMD(do_oasis_trigedit);
void aedit_disp_menu(struct descriptor_data * d);
void aedit_parse(struct descriptor_data * d, char *arg);
void aedit_setup_new(struct descriptor_data *d);
void aedit_setup_existing(struct descriptor_data *d, int real_num);
void aedit_save_to_disk(struct descriptor_data *d);
void aedit_save_internally(struct descriptor_data *d);
void free_action(struct social_messg *mess);
ACMD(do_oasis_aedit);
void hedit_save_to_disk(struct descriptor_data *d);
void hedit_setup_new(struct descriptor_data *d, char *new_key);
void hedit_setup_existing(struct descriptor_data *d, int rnum);
void hedit_parse(struct descriptor_data *d, char *arg);
void hedit_string_cleanup(struct descriptor_data *d, int terminator);
void free_help(struct help_index_element *help);
ACMD(do_oasis_hedit);
/* oasis_delete.c */
int free_strings(void *data, int type);
/* oasis_list.c */
ACMD(do_oasis_list);
ACMD(do_oasis_links);
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);
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 );
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);
void print_zone(struct char_data *ch, zone_rnum rnum);
#define CONTEXT_HELP_STRING "help"
#define CONTEXT_OEDIT_MAIN_MENU 1
#define CONTEXT_OEDIT_EDIT_NAMELIST 2
#define CONTEXT_OEDIT_SHORTDESC 3
#define CONTEXT_OEDIT_LONGDESC 4
#define CONTEXT_OEDIT_ACTDESC 5
#define CONTEXT_OEDIT_TYPE 6
#define CONTEXT_OEDIT_EXTRAS 7
#define CONTEXT_OEDIT_WEAR 8
#define CONTEXT_OEDIT_WEIGHT 9
#define CONTEXT_OEDIT_COST 10
#define CONTEXT_OEDIT_COSTPERDAY 11
#define CONTEXT_OEDIT_TIMER 12
#define CONTEXT_OEDIT_VALUE_1 13
#define CONTEXT_OEDIT_VALUE_2 14
#define CONTEXT_OEDIT_VALUE_3 15
#define CONTEXT_OEDIT_VALUE_4 16
#define CONTEXT_OEDIT_APPLY 17
#define CONTEXT_OEDIT_APPLYMOD 18
#define CONTEXT_OEDIT_EXTRADESC_KEY 19
#define CONTEXT_OEDIT_CONFIRM_SAVEDB 20
#define CONTEXT_OEDIT_CONFIRM_SAVESTRING 21
#define CONTEXT_OEDIT_PROMPT_APPLY 22
#define CONTEXT_OEDIT_EXTRADESC_DESCRIPTION 23
#define CONTEXT_OEDIT_EXTRADESC_MENU 24
#define CONTEXT_OEDIT_LEVEL 25
#define CONTEXT_OEDIT_PERM 26
#define CONTEXT_REDIT_MAIN_MENU 27
#define CONTEXT_REDIT_NAME 28
#define CONTEXT_REDIT_DESC 29
#define CONTEXT_REDIT_FLAGS 30
#define CONTEXT_REDIT_SECTOR 31
#define CONTEXT_REDIT_EXIT_MENU 32
#define CONTEXT_REDIT_CONFIRM_SAVEDB 33
#define CONTEXT_REDIT_CONFIRM_SAVESTRING 34
#define CONTEXT_REDIT_EXIT_NUMBER 35
#define CONTEXT_REDIT_EXIT_DESCRIPTION 36
#define CONTEXT_REDIT_EXIT_KEYWORD 37
#define CONTEXT_REDIT_EXIT_KEY 38
#define CONTEXT_REDIT_EXIT_DOORFLAGS 39
#define CONTEXT_REDIT_EXTRADESC_MENU 40
#define CONTEXT_REDIT_EXTRADESC_KEY 41
#define CONTEXT_REDIT_EXTRADESC_DESCRIPTION 42
#define CONTEXT_ZEDIT_MAIN_MENU 43
#define CONTEXT_ZEDIT_DELETE_ENTRY 44
#define CONTEXT_ZEDIT_NEW_ENTRY 45
#define CONTEXT_ZEDIT_CHANGE_ENTRY 46
#define CONTEXT_ZEDIT_COMMAND_TYPE 47
#define CONTEXT_ZEDIT_IF_FLAG 48
#define CONTEXT_ZEDIT_ARG1 49
#define CONTEXT_ZEDIT_ARG2 50
#define CONTEXT_ZEDIT_ARG3 51
#define CONTEXT_ZEDIT_ZONE_NAME 52
#define CONTEXT_ZEDIT_ZONE_LIFE 53
#define CONTEXT_ZEDIT_ZONE_BOT 54
#define CONTEXT_ZEDIT_ZONE_TOP 55
#define CONTEXT_ZEDIT_ZONE_RESET 56
#define CONTEXT_ZEDIT_CONFIRM_SAVESTRING 57
#define CONTEXT_ZEDIT_SARG1 58
#define CONTEXT_ZEDIT_SARG2 59
#define CONTEXT_MEDIT_MAIN_MENU 60
#define CONTEXT_MEDIT_ALIAS 61
#define CONTEXT_MEDIT_S_DESC 62
#define CONTEXT_MEDIT_L_DESC 63
#define CONTEXT_MEDIT_D_DESC 64
#define CONTEXT_MEDIT_NPC_FLAGS 65
#define CONTEXT_MEDIT_AFF_FLAGS 66
#define CONTEXT_MEDIT_CONFIRM_SAVESTRING 67
#define CONTEXT_MEDIT_SEX 68
#define CONTEXT_MEDIT_HITROLL 69
#define CONTEXT_MEDIT_DAMROLL 70
#define CONTEXT_MEDIT_NDD 71
#define CONTEXT_MEDIT_SDD 72
#define CONTEXT_MEDIT_NUM_HP_DICE 73
#define CONTEXT_MEDIT_SIZE_HP_DICE 74
#define CONTEXT_MEDIT_ADD_HP 75
#define CONTEXT_MEDIT_AC 76
#define CONTEXT_MEDIT_EXP 77
#define CONTEXT_MEDIT_GOLD 78
#define CONTEXT_MEDIT_POS 79
#define CONTEXT_MEDIT_DEFAULT_POS 80
#define CONTEXT_MEDIT_ATTACK 81
#define CONTEXT_MEDIT_LEVEL 82
#define CONTEXT_MEDIT_ALIGNMENT 83
#define CONTEXT_SEDIT_MAIN_MENU 84
#define CONTEXT_SEDIT_CONFIRM_SAVESTRING 85
#define CONTEXT_SEDIT_NOITEM1 86
#define CONTEXT_SEDIT_NOITEM2 87
#define CONTEXT_SEDIT_NOCASH1 88
#define CONTEXT_SEDIT_NOCASH2 89
#define CONTEXT_SEDIT_NOBUY 90
#define CONTEXT_SEDIT_BUY 91
#define CONTEXT_SEDIT_SELL 92
#define CONTEXT_SEDIT_PRODUCTS_MENU 93
#define CONTEXT_SEDIT_ROOMS_MENU 94
#define CONTEXT_SEDIT_NAMELIST_MENU 95
#define CONTEXT_SEDIT_NAMELIST 96
#define CONTEXT_SEDIT_OPEN1 97
#define CONTEXT_SEDIT_OPEN2 98
#define CONTEXT_SEDIT_CLOSE1 99
#define CONTEXT_SEDIT_CLOSE2 100
#define CONTEXT_SEDIT_KEEPER 101
#define CONTEXT_SEDIT_BUY_PROFIT 102
#define CONTEXT_SEDIT_SELL_PROFIT 103
#define CONTEXT_SEDIT_TYPE_MENU 104
#define CONTEXT_SEDIT_DELETE_TYPE 105
#define CONTEXT_SEDIT_DELETE_PRODUCT 106
#define CONTEXT_SEDIT_NEW_PRODUCT 107
#define CONTEXT_SEDIT_DELETE_ROOM 108
#define CONTEXT_SEDIT_NEW_ROOM 109
#define CONTEXT_SEDIT_SHOP_FLAGS 110
#define CONTEXT_SEDIT_NOTRADE 111
#define CONTEXT_TRIGEDIT_MAIN_MENU 112
#define CONTEXT_TRIGEDIT_TRIGTYPE 113
#define CONTEXT_TRIGEDIT_CONFIRM_SAVESTRING 114
#define CONTEXT_TRIGEDIT_NAME 115
#define CONTEXT_TRIGEDIT_INTENDED 116
#define CONTEXT_TRIGEDIT_TYPES 117
#define CONTEXT_TRIGEDIT_COMMANDS 118
#define CONTEXT_TRIGEDIT_NARG 119
#define CONTEXT_TRIGEDIT_ARGUMENT 120
#define CONTEXT_SCRIPT_MAIN_MENU 121
#define CONTEXT_SCRIPT_NEW_TRIGGER 122
#define CONTEXT_SCRIPT_DEL_TRIGGER 123
/* includes number 0 */
#define NUM_CONTEXTS 124
/* Prototypes for the context sensitive help system */
int find_context(struct descriptor_data *d);
int find_context_oedit(struct descriptor_data *d);
int find_context_redit(struct descriptor_data *d);
int find_context_zedit(struct descriptor_data *d);
int find_context_medit(struct descriptor_data *d);
int find_context_sedit(struct descriptor_data *d);
int find_context_trigedit(struct descriptor_data *d);
int find_context_script_edit(struct descriptor_data *d);
int context_help(struct descriptor_data *d, char *arg);
void boot_context_help(void);
void free_context_help(void);
#endif

390
src/oasis_copy.c Normal file
View file

@ -0,0 +1,390 @@
/******************************************************************************/
/** OasisOLC - InGame OLC Copying v2.0 **/
/** Original author: Levork **/
/** Copyright 1996 Harvey Gilpin **/
/** Copyright 1997-2001 George Greer (greerga@circlemud.org) **/
/** Copyright 2002 Kip Potter [Mythran] (kip_potter@hotmail.com) **/
/******************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "genolc.h"
#include "genzon.h"
#include "genwld.h"
#include "oasis.h"
#include "improved-edit.h"
#include "constants.h"
/******************************************************************************/
/** Internal Functions **/
/******************************************************************************/
ACMD(do_dig);
ACMD(do_room_copy);
room_vnum redit_find_new_vnum(zone_rnum zone);
int buildwalk(struct char_data *ch, int dir);
/******************************************************************************/
/** Commands **/
/******************************************************************************/
ACMD(do_dig)
{
char sdir[MAX_INPUT_LENGTH], sroom[MAX_INPUT_LENGTH], *new_room_name;
room_vnum rvnum = NOWHERE;
room_rnum rrnum = NOWHERE;
zone_rnum zone;
int dir = 0, rawvnum;
struct descriptor_data *d = ch->desc; /* will save us some typing */
/* Grab the room's name (if available). */
new_room_name = two_arguments(argument, sdir, sroom);
skip_spaces(&new_room_name);
/* Can't dig if we don't know where to go. */
if (!*sdir || !*sroom) {
send_to_char(ch, "Format: dig <direction> <room> - to create an exit\r\n"
" dig <direction> -1 - to delete an exit\r\n");
return;
}
rawvnum = atoi(sroom);
if (rawvnum == -1)
rvnum = NOWHERE;
else
rvnum = (room_vnum)rawvnum;
rrnum = real_room(rvnum);
dir = search_block(sdir, dirs, FALSE);
zone = world[IN_ROOM(ch)].zone;
if (dir < 0) {
send_to_char(ch, "Can not create an exit to the '%s'.\r\n", sdir);
return;
}
/* Make sure that the builder has access to the zone he's in. */
if ((zone == NOWHERE) || !can_edit_zone(ch, zone)) {
send_to_char(ch, "You do not have permission to edit this zone.\r\n");
return;
}
/*
* Lets not allow digging to limbo.
* After all, it'd just get us more errors on 'show errors'
*/
if (rvnum == 0) {
send_to_char(ch, "The target exists, but you can't dig to limbo!\r\n");
return;
}
/*
* target room == -1 removes the exit
*/
if (rvnum == NOTHING) {
if (W_EXIT(IN_ROOM(ch), dir)) {
/* free the old pointers, if any */
if (W_EXIT(IN_ROOM(ch), dir)->general_description)
free(W_EXIT(IN_ROOM(ch), dir)->general_description);
if (W_EXIT(IN_ROOM(ch), dir)->keyword)
free(W_EXIT(IN_ROOM(ch), dir)->keyword);
free(W_EXIT(IN_ROOM(ch), dir));
W_EXIT(IN_ROOM(ch), dir) = NULL;
add_to_save_list(zone_table[world[IN_ROOM(ch)].zone].number, SL_WLD);
send_to_char(ch, "You remove the exit to the %s.\r\n", dirs[dir]);
return;
}
send_to_char(ch, "There is no exit to the %s.\r\n"
"No exit removed.\r\n", dirs[dir]);
return;
}
/*
* Can't dig in a direction, if it's already a door.
*/
if (W_EXIT(IN_ROOM(ch), dir)) {
send_to_char(ch, "There already is an exit to the %s.\r\n", dirs[dir]);
return;
}
/* Make sure that the builder has access to the zone he's linking to. */
zone = real_zone_by_thing(rvnum);
if (zone == NOWHERE) {
send_to_char(ch, "You cannot link to a non-existing zone!\r\n");
return;
}
if (!can_edit_zone(ch, zone)) {
send_to_char(ch, "You do not have permission to edit room #%d.\r\n", rvnum);
return;
}
/*
* Now we know the builder is allowed to make the link
*/
/* If the room doesn't exist, create it.*/
if (rrnum == NOWHERE) {
/*
* Give the descriptor an olc struct.
* This way we can let redit_save_internally handle the room adding.
*/
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: do_dig: Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
OLC_ZNUM(d) = zone;
OLC_NUM(d) = rvnum;
CREATE(OLC_ROOM(d), struct room_data, 1);
/* Copy the room's name. */
if (*new_room_name)
OLC_ROOM(d)->name = strdup(new_room_name);
else
OLC_ROOM(d)->name = strdup("An unfinished room");
/* Copy the room's description.*/
OLC_ROOM(d)->description = strdup("You are in an unfinished room.\r\n");
OLC_ROOM(d)->zone = OLC_ZNUM(d);
OLC_ROOM(d)->number = NOWHERE;
/*
* Save the new room to memory.
* redit_save_internally handles adding the room in the right place, etc.
*/
redit_save_internally(d);
OLC_VAL(d) = 0;
send_to_char(ch, "New room (%d) created.\r\n", rvnum);
cleanup_olc(d, CLEANUP_STRUCTS);
/*
* update rrnum to the correct room rnum after adding the room
*/
rrnum = real_room(rvnum);
}
/*
* Now dig.
*/
CREATE(W_EXIT(IN_ROOM(ch), dir), struct room_direction_data, 1);
W_EXIT(IN_ROOM(ch), dir)->general_description = NULL;
W_EXIT(IN_ROOM(ch), dir)->keyword = NULL;
W_EXIT(IN_ROOM(ch), dir)->to_room = rrnum;
add_to_save_list(zone_table[world[IN_ROOM(ch)].zone].number, SL_WLD);
send_to_char(ch, "You make an exit %s to room %d (%s).\r\n",
dirs[dir], rvnum, world[rrnum].name);
/*
* check if we can dig from there to here.
*/
if (W_EXIT(rrnum, rev_dir[dir]))
send_to_char(ch, "Can not dig from %d to here. The target room already has an exit to the %s.\r\n",
rvnum, dirs[rev_dir[dir]]);
else {
CREATE(W_EXIT(rrnum, rev_dir[dir]), struct room_direction_data, 1);
W_EXIT(rrnum, rev_dir[dir])->general_description = NULL;
W_EXIT(rrnum, rev_dir[dir])->keyword = NULL;
W_EXIT(rrnum, rev_dir[dir])->to_room = IN_ROOM(ch);
add_to_save_list(zone_table[world[rrnum].zone].number, SL_WLD);
}
}
ACMD(do_room_copy)
{
struct room_data *room_src, *room_dst;
int room_num, j, buf_num;
zone_rnum dst_zone;
struct descriptor_data *dsc;
char buf[MAX_INPUT_LENGTH];
one_argument(argument, buf);
if (!*buf) {
send_to_char(ch, "Usage: rclone <target room>\r\n");
return;
}
if (real_room((buf_num = atoi(buf))) != NOWHERE) {
send_to_char(ch, "That room already exist!\r\n");
return;
}
if ((dst_zone = real_zone_by_thing(buf_num)) == NOWHERE) {
send_to_char(ch, "Sorry, there is no zone for that number!\r\n");
return;
}
if (!can_edit_zone(ch, dst_zone) ||
!can_edit_zone(ch, world[IN_ROOM(ch)].zone) ) {
send_to_char(ch, "You may only copy rooms within your designated zone(s)!\r\n");
return;
}
room_src = &world[IN_ROOM(ch)];
CREATE(room_dst, struct room_data, 1);
room_dst->zone = dst_zone;
/*
* Allocate space for all strings.
*/
send_to_char(ch, "Cloning room....\r\n");
room_dst->name = str_udup(world[IN_ROOM(ch)].name);
room_dst->description = str_udup(world[IN_ROOM(ch)].description);
room_dst->description = str_udup(world[IN_ROOM(ch)].description);
room_dst->number = buf_num;
room_dst->room_flags = ROOM_FLAGS(IN_ROOM(ch));
room_dst->sector_type = world[IN_ROOM(ch)].sector_type;
/*
* Extra descriptions, if necessary.
*/
send_to_char(ch, "Cloning extra descriptions....\r\n");
if (world[IN_ROOM(ch)].ex_description) {
struct extra_descr_data *tdesc, *temp, *temp2;
CREATE(temp, struct extra_descr_data, 1);
room_dst->ex_description = temp;
for (tdesc = world[IN_ROOM(ch)].ex_description; tdesc; tdesc = tdesc->next) {
temp->keyword = strdup(tdesc->keyword);
temp->description = strdup(tdesc->description);
if (tdesc->next) {
CREATE(temp2, struct extra_descr_data, 1);
temp->next = temp2;
temp = temp2;
} else
temp->next = NULL;
}
}
/*
* Now save the room in the right place:
*/
send_to_char(ch, "Saving new room...\r\n");
if ((room_num = add_room(room_dst)) == NOWHERE) {
send_to_char(ch, "Something went wrong...\r\n");
log("SYSERR: do_room_copy: Something failed! (%d)", room_num);
return;
}
/* Idea contributed by C.Raehl 4/27/99 */
for (dsc = descriptor_list; dsc; dsc = dsc->next) {
if (dsc == ch->desc)
continue;
if (STATE(dsc) == CON_ZEDIT) {
for (j = 0; OLC_ZONE(dsc)->cmd[j].command != 'S'; j++)
switch (OLC_ZONE(dsc)->cmd[j].command) {
case 'O':
case 'M':
OLC_ZONE(dsc)->cmd[j].arg3 += (OLC_ZONE(dsc)->cmd[j].arg3 >= room_num);
break;
case 'D':
OLC_ZONE(dsc)->cmd[j].arg2 += (OLC_ZONE(dsc)->cmd[j].arg2 >= room_num);
/* Fall through */
case 'R':
OLC_ZONE(dsc)->cmd[j].arg1 += (OLC_ZONE(dsc)->cmd[j].arg1 >= room_num);
break;
}
} else if (STATE(dsc) == CON_REDIT) {
for (j = 0; j < NUM_OF_DIRS; j++)
if (OLC_ROOM(dsc)->dir_option[j])
if (OLC_ROOM(dsc)->dir_option[j]->to_room >= room_num)
OLC_ROOM(dsc)->dir_option[j]->to_room++;
}
}
add_to_save_list(real_zone_by_thing(atoi(buf)), SL_WLD);
redit_save_to_disk(real_zone_by_thing(atoi(buf)));
send_to_char(ch, "Room cloned to %d.\r\nAll Done.\r\n", buf_num);
}
/****************************************************************************
* BuildWalk - OasisOLC Extension by D. Tyler Barnes *
****************************************************************************/
/* For buildwalk. Finds the next free vnum in the zone */
room_vnum redit_find_new_vnum(zone_rnum zone)
{
room_vnum vnum = genolc_zone_bottom(zone);
room_rnum rnum = real_room(vnum);
if (rnum == NOWHERE)
return NOWHERE;
for(;;) {
if (vnum > zone_table[zone].top)
return(NOWHERE);
if (rnum > top_of_world || world[rnum].number > vnum)
break;
rnum++;
vnum++;
}
return(vnum);
}
int buildwalk(struct char_data *ch, int dir)
{
char buf[MAX_INPUT_LENGTH];
room_vnum vnum;
room_rnum rnum;
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_BUILDWALK) &&
GET_LEVEL(ch) >= LVL_BUILDER) {
get_char_colors(ch);
if (!can_edit_zone(ch, world[IN_ROOM(ch)].zone)) {
send_to_char(ch, "You do not have build permissions in this zone.\r\n");
} else if ((vnum = redit_find_new_vnum(world[IN_ROOM(ch)].zone)) == NOWHERE) {
send_to_char(ch, "No free vnums are available in this zone!\r\n");
} else {
struct descriptor_data *d = ch->desc;
/*
* Give the descriptor an olc struct.
* This way we can let redit_save_internally handle the room adding.
*/
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: buildwalk(): Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
OLC_ZNUM(d) = world[IN_ROOM(ch)].zone;
OLC_NUM(d) = vnum;
CREATE(OLC_ROOM(d), struct room_data, 1);
OLC_ROOM(d)->name = strdup("New BuildWalk Room");
sprintf(buf, "This unfinished room was created by %s.\r\n", GET_NAME(ch));
OLC_ROOM(d)->description = strdup(buf);
OLC_ROOM(d)->zone = OLC_ZNUM(d);
OLC_ROOM(d)->number = NOWHERE;
/*
* Save the new room to memory.
* redit_save_internally handles adding the room in the right place, etc.
*/
redit_save_internally(d);
OLC_VAL(d) = 0;
/* Link rooms */
rnum = real_room(vnum);
CREATE(EXIT(ch, dir), struct room_direction_data, 1);
EXIT(ch, dir)->to_room = rnum;
CREATE(world[rnum].dir_option[rev_dir[dir]], struct room_direction_data, 1);
world[rnum].dir_option[rev_dir[dir]]->to_room = IN_ROOM(ch);
/* Report room creation to user */
send_to_char(ch, "%sRoom #%d created by BuildWalk.%s\r\n", yel, vnum, nrm);
cleanup_olc(d, CLEANUP_STRUCTS);
return (1);
}
}
return(0);
}

129
src/oasis_delete.c Normal file
View file

@ -0,0 +1,129 @@
/************************************************************************
* OasisOLC - InGame OLC Deletion v2.0 *
* Original author: Levork *
* Copyright 1996 Harvey Gilpin *
* Copyright 1997-2001 George Greer (greerga@circlemud.org) *
* Copyright 2002 Kip Potter [Mythran] (kip_potter@hotmail.com) *
************************************************************************/
/*
+-----------------------------------------------------------------------+
| As of right now, all I have made is the ability to delete rooms. |
| Deleting the rest of the area (objects, zones, mobiles) will be |
| a little more difficult. This is because they are broader and |
| deleting one is more tedious (but not impossible). I will (hopefully)|
| be adding more deletion code after this patch. |
| -- Mythran |
+-----------------------------------------------------------------------+
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "genolc.h"
#include "oasis.h"
#include "improved-edit.h"
/************************************************************************\
** Description : **
** Free's strings from any object, room, mobiles, or player. **
** **
** Return Value: **
** TRUE if successful, otherwise, it returns FALSE. **
** **
** Parameters : **
** type - The OLC type constant relating to the data type of data. **
\************************************************************************/
int free_strings(void *data, int type)
{
struct room_data *room;
struct config_data *config;
int i;
switch (type) {
case OASIS_WLD:
room = (struct room_data *) data;
/* Free Descriptions */
if (room->name)
free(room->name);
if (room->description)
free(room->description);
if (room->ex_description)
free_ex_descriptions(room->ex_description);
/* Return the return value of free_strings(). */
return (free_strings(room, OASIS_EXI));
case OASIS_EXI:
room = (struct room_data *) data;
for (i = 0; i < NUM_OF_DIRS; i++) {
if (room->dir_option[i]) {
if (room->dir_option[i]->general_description) {
free(room->dir_option[i]->general_description);
room->dir_option[i]->general_description = NULL;
}
if (room->dir_option[i]->keyword) {
free(room->dir_option[i]->keyword);
room->dir_option[i]->keyword = NULL;
}
free(room->dir_option[i]);
room->dir_option[i] = NULL;
}
}
return (TRUE);
case OASIS_MOB:
case OASIS_OBJ:
return (FALSE); /* For now... */
case OASIS_CFG:
config = (struct config_data *) data;
if (config->play.OK)
free(config->play.OK);
if (config->play.NOPERSON)
free(config->play.NOPERSON);
if (config->play.NOEFFECT)
free(config->play.NOEFFECT);
if (config->operation.DFLT_IP)
free(config->operation.DFLT_IP);
if (config->operation.DFLT_DIR)
free(config->operation.DFLT_DIR);
if (config->operation.LOGNAME)
free(config->operation.LOGNAME);
if (config->operation.MENU)
free(config->operation.MENU);
if (config->operation.WELC_MESSG)
free(config->operation.WELC_MESSG);
if (config->operation.START_MESSG)
free(config->operation.START_MESSG);
return (TRUE);
default:
mudlog(BRF, LVL_GOD, TRUE, "SYSERR: oasis_delete.c: free_strings: Invalid type handled (Type %d).", type);
return (FALSE);
}
}

4
src/oasis_delete.h Normal file
View file

@ -0,0 +1,4 @@
/*
* Function prototypes defined in oasis_delete.c.
*/
void remove_room_from_memory(room_rnum rnum);

472
src/oasis_list.c Normal file
View file

@ -0,0 +1,472 @@
/******************************************************************************/
/** OasisOLC - InGame OLC Listings v2.0 **/
/** Original author: Levork **/
/** Copyright 1996 Harvey Gilpin **/
/** Copyright 1997-2001 George Greer (greerga@circlemud.org) **/
/** Copyright 2002 Kip Potter [Mythran] (kip_potter@hotmail.com) **/
/******************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "genolc.h"
#include "oasis.h"
#include "improved-edit.h"
#include "shop.h"
#include "screen.h"
#include "constants.h"
#include "dg_scripts.h"
/******************************************************************************/
/** Ingame Commands **/
/******************************************************************************/
ACMD(do_oasis_list)
{
zone_rnum rzone = NOWHERE;
room_rnum vmin = NOWHERE;
room_rnum vmax = NOWHERE;
char smin[MAX_INPUT_LENGTH];
char smax[MAX_INPUT_LENGTH];
two_arguments(argument, smin, smax);
if (!*smin || *smin == '.') {
rzone = world[IN_ROOM(ch)].zone;
} else if (!*smax) {
rzone = real_zone(atoi(smin));
if (rzone == NOWHERE) {
send_to_char(ch, "Sorry, there's no zone with that number\r\n");
return;
}
} else {
/** Listing by min vnum / max vnum. Retrieve the numeric values. **/
vmin = atoi(smin);
vmax = atoi(smax);
if (vmin > vmax) {
send_to_char(ch, "List from %d to %d - Aren't we funny today!\r\n", vmin, vmax);
return;
}
}
switch (subcmd) {
case SCMD_OASIS_MLIST: list_mobiles(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_OLIST: list_objects(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_SLIST: list_shops(ch, rzone, vmin, vmax); break;
case SCMD_OASIS_ZLIST: list_zones(ch, rzone, vmin, vmax); break;
default:
send_to_char(ch, "You can't list that!\r\n");
mudlog(BRF, LVL_IMMORT, TRUE,
"SYSERR: do_oasis_list: Unknown list option: %d", subcmd);
}
}
ACMD(do_oasis_links)
{
zone_rnum zrnum;
zone_vnum zvnum;
room_rnum nr, to_room;
room_vnum first, last;
int j;
char arg[MAX_INPUT_LENGTH];
skip_spaces(&argument);
one_argument(argument, arg);
if (!arg || !*arg) {
send_to_char(ch,
"Syntax: links <zone_vnum> ('.' for zone you are standing in)\r\n");
return;
}
if (!strcmp(arg, ".")) {
zrnum = world[IN_ROOM(ch)].zone;
zvnum = zone_table[zrnum].number;
} else {
zvnum = atoi(arg);
zrnum = real_zone(zvnum);
}
if (zrnum == NOWHERE || zvnum == NOWHERE) {
send_to_char(ch, "No zone was found with that number.\n\r");
return;
}
last = zone_table[zrnum].top;
first = zone_table[zrnum].bot;
send_to_char(ch, "Zone %d is linked to the following zones:\r\n", zvnum);
for (nr = 0; nr <= top_of_world && (GET_ROOM_VNUM(nr) <= last); nr++) {
if (GET_ROOM_VNUM(nr) >= first) {
for (j = 0; j < NUM_OF_DIRS; j++) {
if (world[nr].dir_option[j]) {
to_room = world[nr].dir_option[j]->to_room;
if (to_room != NOWHERE && (zrnum != world[to_room].zone))
send_to_char(ch, "%3d %-30s%s at %5d (%-5s) ---> %5d\r\n",
zone_table[world[to_room].zone].number,
zone_table[world[to_room].zone].name, QNRM,
GET_ROOM_VNUM(nr), dirs[j], world[to_room].number);
}
}
}
}
}
/******************************************************************************/
/** Helper Functions **/
/******************************************************************************/
/*
* List all rooms in a zone.
*/
void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax)
{
room_rnum i;
room_vnum bottom, top;
int j, counter = 0;
/*
* Expect a minimum / maximum number if the rnum for the zone is NOWHERE.
*/
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
top = zone_table[rnum].top;
} else {
bottom = vmin;
top = vmax;
}
send_to_char (ch,
"Index VNum Room Name Exits\r\n"
"----- ------- ---------------------------------------- -----\r\n");
for (i = 0; i <= top_of_world; i++) {
/** Check to see if this room is one of the ones needed to be listed. **/
if ((world[i].number >= bottom) && (world[i].number <= top)) {
counter++;
send_to_char(ch, "%4d) [%s%-5d%s] %s%-*s%s %s",
counter, QGRN, world[i].number, QNRM,
QCYN, count_color_chars(world[i].name)+44, world[i].name, QNRM,
world[i].proto_script ? "[TRIG] " : ""
);
for (j = 0; j < NUM_OF_DIRS; j++) {
if (W_EXIT(i, j) == NULL)
continue;
if (W_EXIT(i, j)->to_room == NOWHERE)
continue;
if (world[W_EXIT(i, j)->to_room].zone != world[i].zone)
send_to_char(ch, "(%s%d%s)", QYEL, world[W_EXIT(i, j)->to_room].number, QNRM);
}
send_to_char(ch, "\r\n");
}
}
if (counter == 0)
send_to_char(ch, "No rooms found for zone #%d\r\n", zone_table[rnum].number);
}
/*
* List all mobiles in a zone.
*/
void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mob_vnum vmax)
{
mob_rnum i;
mob_vnum bottom, top;
int counter = 0;
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
top = zone_table[rnum].top;
} else {
bottom = vmin;
top = vmax;
}
send_to_char(ch,
"Index VNum Mobile Name Level\r\n"
"----- ------- --------------------------------------------- -----\r\n");
for (i = 0; i <= top_of_mobt; i++) {
if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top) {
counter++;
send_to_char(ch, "%s%4d%s) [%s%-5d%s] %s%-*s %s[%4d]%s%s\r\n",
QGRN, counter, QNRM, QGRN, mob_index[i].vnum, QNRM,
QCYN, count_color_chars(mob_proto[i].player.short_descr)+44, mob_proto[i].player.short_descr,
QYEL, mob_proto[i].player.level, QNRM,
mob_proto[i].proto_script ? " [TRIG]" : ""
);
}
}
if (counter == 0)
send_to_char(ch, "None found.\r\n");
}
/*
* List all objects in a zone.
*/
void list_objects(struct char_data *ch, zone_rnum rnum, room_vnum vmin, room_vnum vmax)
{
obj_rnum i;
obj_vnum bottom, top;
int counter = 0;
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
top = zone_table[rnum].top;
} else {
bottom = vmin;
top = vmax;
}
send_to_char(ch,
"Index VNum Object Name Object Type\r\n"
"----- ------- -------------------------------------------- ----------------\r\n");
for (i = 0; i <= top_of_objt; i++) {
if (obj_index[i].vnum >= bottom && obj_index[i].vnum <= top) {
counter++;
send_to_char(ch, "%s%4d%s) [%s%-5d%s] %s%-*s %s[%s]%s%s\r\n",
QGRN, counter, QNRM, QGRN, obj_index[i].vnum, QNRM,
QCYN, count_color_chars(obj_proto[i].short_description)+44, obj_proto[i].short_description, QYEL,
item_types[obj_proto[i].obj_flags.type_flag], QNRM,
obj_proto[i].proto_script ? " [TRIG]" : ""
);
}
}
if (counter == 0)
send_to_char(ch, "None found.\r\n");
}
/*
* List all shops in a zone.
*/
void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, shop_vnum vmax)
{
shop_rnum i;
shop_vnum bottom, top;
int j, counter = 0;
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
top = zone_table[rnum].top;
} else {
bottom = vmin;
top = vmax;
}
send_to_char (ch,
"Index VNum RNum Shop Room(s)\r\n"
"----- ------- ------- -----------------------------------------\r\n");
for (i = 0; i <= top_shop; i++) {
if (SHOP_NUM(i) >= bottom && SHOP_NUM(i) <= top) {
counter++;
/* the +1 is strange but fits the rest of the shop code */
send_to_char(ch, "%s%4d%s) [%s%-5d%s] [%s%-5d%s]",
QGRN, counter, QNRM, QGRN, SHOP_NUM(i), QNRM, QGRN, i + 1, QNRM);
/* Thanks to Ken Ray (kenr86@hotmail.com) for this display fix -- Welcor*/
for (j = 0; SHOP_ROOM(i, j) != NOWHERE; j++)
send_to_char(ch, "%s%s[%s%-5d%s]%s",
((j > 0) && (j % 6 == 0)) ? "\r\n " : " ",
QCYN, QYEL, SHOP_ROOM(i, j), QCYN, QNRM);
if (j == 0)
send_to_char(ch, "%sNone.%s", QCYN, QNRM);
send_to_char(ch, "\r\n");
}
}
if (counter == 0)
send_to_char(ch, "None found.\r\n");
}
/*
* 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)
{
int counter = 0;
zone_rnum i;
zone_vnum bottom, top;
if (rnum != NOWHERE) {
/* Only one parameter was supplied - just list that zone */
print_zone(ch, rnum);
return;
} else {
bottom = vmin;
top = vmax;
}
send_to_char(ch,
"VNum Zone Name Builder(s)\r\n"
"----- ------------------------------ --------------------------------------\r\n");
for (i = 0; i <= top_of_zone_table; i++) {
if (zone_table[i].number >= bottom && zone_table[i].number <= top) {
send_to_char(ch, "[%s%3d%s] %s%-*s %s%-1s%s\r\n",
QGRN, zone_table[i].number, QNRM, QCYN, count_color_chars(zone_table[i].name)+30, zone_table[i].name,
QYEL, zone_table[i].builders ? zone_table[i].builders : "None.", QNRM);
counter++;
}
}
if (!counter)
send_to_char(ch, " None found within those parameters.\r\n");
}
/*
* Prints all of the zone information for the selected zone.
*/
void print_zone(struct char_data *ch, zone_vnum vnum)
{
zone_rnum rnum;
int size_rooms, size_objects, size_mobiles, i;
room_vnum top, bottom;
int largest_table;
if ((rnum = real_zone(vnum)) == NOWHERE) {
send_to_char(ch, "Zone #%d does not exist in the database.\r\n", vnum);
return;
}
/****************************************************************************/
/** Locate the largest of the three, top_of_world, top_of_mobt, or **/
/** top_of_objt. **/
/****************************************************************************/
if (top_of_world >= top_of_objt && top_of_world >= top_of_mobt)
largest_table = top_of_world;
else if (top_of_objt >= top_of_mobt && top_of_objt >= top_of_world)
largest_table = top_of_objt;
else
largest_table = top_of_mobt;
/****************************************************************************/
/** Initialize some of the variables. **/
/****************************************************************************/
size_rooms = 0;
size_objects = 0;
size_mobiles = 0;
top = zone_table[rnum].top;
bottom = zone_table[rnum].bot;
for (i = 0; i <= largest_table; i++) {
if (i <= top_of_world)
if (world[i].zone == rnum)
size_rooms++;
if (i <= top_of_objt)
if (obj_index[i].vnum >= bottom && obj_index[i].vnum <= top)
size_objects++;
if (i <= top_of_mobt)
if (mob_index[i].vnum >= bottom && mob_index[i].vnum <= top)
size_mobiles++;
}
/****************************************************************************/
/** Display all of the zone information at once. **/
/****************************************************************************/
send_to_char(ch,
"%sVirtual Number = %s%d\r\n"
"%sName of zone = %s%s\r\n"
"%sBuilders = %s%s\r\n"
"%sLifespan = %s%d\r\n"
"%sAge = %s%d\r\n"
"%sBottom of Zone = %s%d\r\n"
"%sTop of Zone = %s%d\r\n"
"%sReset Mode = %s%s\r\n"
"%sSize\r\n"
"%s Rooms = %s%d\r\n"
"%s Objects = %s%d\r\n"
"%s Mobiles = %s%d%s\r\n",
QGRN, QCYN, zone_table[rnum].number,
QGRN, QCYN, zone_table[rnum].name,
QGRN, QCYN, zone_table[rnum].builders,
QGRN, QCYN, zone_table[rnum].lifespan,
QGRN, QCYN, zone_table[rnum].age,
QGRN, QCYN, zone_table[rnum].bot,
QGRN, QCYN, zone_table[rnum].top,
QGRN, QCYN, zone_table[rnum].reset_mode ? ((zone_table[rnum].reset_mode == 1) ?
"Reset when no players are in zone." : "Normal reset.") : "Never reset",
QGRN,
QGRN, QCYN, size_rooms,
QGRN, QCYN, size_objects,
QGRN, QCYN, size_mobiles, QNRM);
}
/* List code by Ronald Evers - dlanor@xs4all.nl */
void list_triggers(struct char_data *ch, zone_rnum rnum, trig_vnum vmin, trig_vnum vmax)
{
int i, bottom, top, counter = 0;
char trgtypes[256];
/** Expect a minimum / maximum number if the rnum for the zone is NOWHERE. **/
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
top = zone_table[rnum].top;
} else {
bottom = vmin;
top = vmax;
}
/** Store the header for the room listing. **/
send_to_char (ch,
"Index VNum Trigger Name Type\r\n"
"----- ------- -------------------------------------------------------\r\n");
/** Loop through the world and find each room. **/
for (i = 0; i < top_of_trigt; i++) {
/** Check to see if this room is one of the ones needed to be listed. **/
if ((trig_index[i]->vnum >= bottom) && (trig_index[i]->vnum <= top)) {
counter++;
send_to_char(ch, "%4d) [%s%5d%s] %s%-45.45s%s ",
counter, QGRN, trig_index[i]->vnum, QNRM, QCYN, trig_index[i]->proto->name, QNRM);
if (trig_index[i]->proto->attach_type == OBJ_TRIGGER) {
sprintbit(GET_TRIG_TYPE(trig_index[i]->proto), otrig_types, trgtypes, sizeof(trgtypes));
send_to_char(ch, "obj %s%s%s\r\n", QYEL, trgtypes, QNRM);
} else if (trig_index[i]->proto->attach_type==WLD_TRIGGER) {
sprintbit(GET_TRIG_TYPE(trig_index[i]->proto), wtrig_types, trgtypes, sizeof(trgtypes));
send_to_char(ch, "wld %s%s%s\r\n", QYEL, trgtypes, QNRM);
} else {
sprintbit(GET_TRIG_TYPE(trig_index[i]->proto), trig_types, trgtypes, sizeof(trgtypes));
send_to_char(ch, "mob %s%s%s\r\n", QYEL, trgtypes, QNRM);
}
}
}
if (counter == 0)
send_to_char(ch, "No triggers found for zone #%d\r\n", zone_table[rnum].number);
}

1465
src/objsave.c Normal file

File diff suppressed because it is too large Load diff

1323
src/oedit.c Normal file

File diff suppressed because it is too large Load diff

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