Moved old codebase to old-codebase/

This commit is contained in:
Gergely Polonkai (W00d5t0ck)
2012-03-07 16:24:50 +01:00
parent e2b367dd56
commit dc1a6d7a0a
377 changed files with 0 additions and 0 deletions

5
old-codebase/src/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
conf.h
.accepted
Makefile
*.o
tags

View File

@@ -0,0 +1,212 @@
# 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
default: .accepted
$(MAKE) ../bin/circle
.accepted:
./licheck
utils: .accepted
$(MAKE) ../bin/autowiz
$(MAKE) ../bin/delobjs
$(MAKE) ../bin/listrent
$(MAKE) ../bin/mudpasswd
$(MAKE) ../bin/play2to3
$(MAKE) ../bin/purgeplay
$(MAKE) ../bin/shopconv
$(MAKE) ../bin/showplay
$(MAKE) ../bin/sign
$(MAKE) ../bin/split
$(MAKE) ../bin/wld2html
all: .accepted
$(MAKE) ../bin/circle
$(MAKE) utils
circle:
$(MAKE) ../bin/circle
autowiz:
$(MAKE) ../bin/autowiz
delobjs:
$(MAKE) ../bin/delobjs
listrent:
$(MAKE) ../bin/listrent
mudpasswd:
$(MAKE) ../bin/mudpasswd
play2to3:
$(MAKE) ../bin/play2to3
purgeplay:
$(MAKE) ../bin/purgeplay
shopconv:
$(MAKE) ../bin/shopconv
showplay:
$(MAKE) ../bin/showplay
sign:
$(MAKE) ../bin/sign
split:
$(MAKE) ../bin/split
wld2html:
$(MAKE) ../bin/wld2html
../bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) -o ../bin/autowiz util/autowiz.c
../bin/delobjs: util/delobjs.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/delobjs util/delobjs.c
../bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/listrent util/listrent.c
../bin/mudpasswd: util/mudpasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/mudpasswd util/mudpasswd.c $(LIBS)
../bin/play2to3: util/play2to3.c
$(CC) $(CFLAGS) -o ../bin/play2to3 util/play2to3.c
../bin/purgeplay: util/purgeplay.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/purgeplay util/purgeplay.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/showplay: util/showplay.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/showplay util/showplay.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
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

View File

@@ -0,0 +1,155 @@
# 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.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.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

View File

@@ -0,0 +1,330 @@
#
# 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\
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+
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
|
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
| $@

View File

@@ -0,0 +1,329 @@
# 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\
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+
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
|
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
| $@

View File

@@ -0,0 +1,208 @@
# 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@ @SQLITE3_CFLAGS@ $(MYFLAGS) $(PROFILE)
LIBS = @LIBS@ @SQLITE3_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 class.o comm.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 \
bsd-snprintf.o races.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 class.c comm.c config.c constants.c db.c fight.c \
graph.c handler.c house.c interpreter.c limits.c magic.c mail.c \
mobact.c modify.c objsave.c olc.c random.c shop.c spec_assign.c\
spec_procs.c spell_parser.c spells.c utils.c weather.c \
bsd-snprintf.c races.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)
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 constants.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 constants.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
alias.o: alias.c conf.h sysdep.h structs.h utils.h interpreter.h db.h
$(CC) -c $(CFLAGS) alias.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 \
constants.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 interpreter.h
$(CC) -c $(CFLAGS) config.c
constants.o: constants.c conf.h sysdep.h structs.h interpreter.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 constants.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 constants.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 \
constants.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 constants.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
races.o: races.c conf.h sysdep.h structs.h interpreter.h utils.h
$(CC) -c $(CFLAGS) races.c
random.o: random.c utils.h
$(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 constants.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 constants.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 interpreter.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 db.h interpreter.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
bsd-snprintf.o: bsd-snprintf.c conf.h sysdep.h
$(CC) -c $(CFLAGS) bsd-snprintf.c

View File

@@ -0,0 +1,566 @@
# 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 \
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 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

View File

@@ -0,0 +1,158 @@
#
# 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
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
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

View File

@@ -0,0 +1,214 @@
# 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
default: .accepted
$(MAKE) ../bin/circle
.accepted:
@./licheck more
utils: .accepted
$(MAKE) ../bin/autowiz
$(MAKE) ../bin/delobjs
$(MAKE) ../bin/listrent
$(MAKE) ../bin/mudpasswd
$(MAKE) ../bin/play2to3
$(MAKE) ../bin/purgeplay
$(MAKE) ../bin/shopconv
$(MAKE) ../bin/showplay
$(MAKE) ../bin/sign
$(MAKE) ../bin/split
$(MAKE) ../bin/wld2html
all: .accepted
$(MAKE) ../bin/circle
$(MAKE) utils
circle:
$(MAKE) ../bin/circle
autowiz:
$(MAKE) ../bin/autowiz
delobjs:
$(MAKE) ../bin/delobjs
listrent:
$(MAKE) ../bin/listrent
mudpasswd:
$(MAKE) ../bin/mudpasswd
play2to3:
$(MAKE) ../bin/play2to3
purgeplay:
$(MAKE) ../bin/purgeplay
shopconv:
$(MAKE) ../bin/shopconv
showplay:
$(MAKE) ../bin/showplay
sign:
$(MAKE) ../bin/sign
split:
$(MAKE) ../bin/split
wld2html:
$(MAKE) ../bin/wld2html
../bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) -o ../bin/autowiz util/autowiz.c
../bin/delobjs: util/delobjs.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/delobjs util/delobjs.c
../bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/listrent util/listrent.c
../bin/mudpasswd: util/mudpasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/mudpasswd util/mudpasswd.c
../bin/play2to3: util/play2to3.c
$(CC) $(CFLAGS) -o ../bin/play2to3 util/play2to3.c
../bin/purgeplay: util/purgeplay.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) -o ../bin/purgeplay util/purgeplay.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/showplay: util/showplay.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) -o ../bin/showplay util/showplay.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
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

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"

205
old-codebase/src/Smakefile Normal file
View File

@@ -0,0 +1,205 @@
# 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
default:
$(MAKE) /bin/circle
utils:
$(MAKE) /bin/autowiz
$(MAKE) /bin/delobjs
$(MAKE) /bin/listrent
$(MAKE) /bin/mudpasswd
$(MAKE) /bin/play2to3
$(MAKE) /bin/purgeplay
$(MAKE) /bin/shopconv
$(MAKE) /bin/showplay
$(MAKE) /bin/sign
$(MAKE) /bin/split
$(MAKE) /bin/wld2html
all: .accepted
$(MAKE) /bin/circle
$(MAKE) utils
circle:
$(MAKE) /bin/circle
autowiz:
$(MAKE) /bin/autowiz
delobjs:
$(MAKE) /bin/delobjs
listrent:
$(MAKE) /bin/listrent
mudpasswd:
$(MAKE) /bin/mudpasswd
play2to3:
$(MAKE) /bin/play2to3
purgeplay:
$(MAKE) /bin/purgeplay
shopconv:
$(MAKE) /bin/shopconv
showplay:
$(MAKE) /bin/showplay
sign:
$(MAKE) /bin/sign
split:
$(MAKE) /bin/split
wld2html:
$(MAKE) /bin/wld2html
/bin/autowiz: util/autowiz.c conf.h sysdep.h structs.h utils.h db.h
$(CC) $(CFLAGS) /bin/autowiz util/autowiz.c LINK
/bin/delobjs: util/delobjs.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) /bin/delobjs util/delobjs.c LINK
/bin/listrent: util/listrent.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) /bin/listrent util/listrent.c LINK
/bin/mudpasswd: util/mudpasswd.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) /bin/mudpasswd util/mudpasswd.c LINK
/bin/play2to3: util/play2to3.c
$(CC) $(CFLAGS) /bin/play2to3 util/play2to3.c LINK
/bin/purgeplay: util/purgeplay.c conf.h sysdep.h structs.h utils.h
$(CC) $(CFLAGS) /bin/purgeplay util/purgeplay.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/showplay: util/showplay.c conf.h sysdep.h structs.h
$(CC) $(CFLAGS) /bin/showplay util/showplay.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
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

63
old-codebase/src/TODO Normal file
View File

@@ -0,0 +1,63 @@
* = done
? = done?
/ = in progress
- = not started
/ finish spells
/ string sharing, or at least keyword sharing
/ overhaul do_look and all related functions
- fix affect_total
- etext system
- large buf freeing
- more imm levs?????
- randomized gold?
- add new prompt system?
- newbie command
- fix process_output (see comment above it)
? verify correctness of process_input
* get_char_room_vis/get_char_vis and get_player_vis(0/1)
* outdoor light
* add page breaks to prac list
* sort prac/spell list
* add FAILURE to spells!!
* fix floating point in current prompt system
* add aliases
* fix light bug
* page background story
* purge bug?
* force room bug
* spell word abbrev
* god can unlock doors w/o key
* fix loadroom
* invis start bug
* infrared bug
* xnames bug
* skillset/skillshow
* new where & locate object
* string!!!!!!!!
* new guild code
* anti-class flags
* gen com comments
* ascii flags??
* act fix
* turn off rent option
* 0.person means 'PC'
* class.c
* debug houses
* combine qsay/quecho
* check on lock picking
* change snoop to use descriptor instead of character
* FIX the freaking buried magic number '11' in act.offensive.c
* fix up prompts
* change type of aff num to 16-bit or greater in playerfile
* make 'player_specials_saved'
* change stat to use spell names instead of numbers
* line-by-line zone parsing
* reply command
* rewrite help system to use internal
* make '! ras' work
* fix the utilities, most of which are broken at the moment
* all those mobs using player specials, you'll see them :)

517
old-codebase/src/act.comm.c Normal file
View File

@@ -0,0 +1,517 @@
/* ************************************************************************
* 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"
/* extern variables */
extern int level_can_shout;
extern int holler_move_cost;
/* 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);
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 + 12];
snprintf(buf, sizeof(buf), "$n says, '%s'", argument);
act(buf, FALSE, ch, 0, 0, TO_ROOM);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", OK);
else {
delete_doubledollar(argument);
send_to_char(ch, "You say, '%s'\r\n", 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'", argument);
if (AFF_FLAGGED(k, AFF_GROUP) && (k != ch))
act(buf, FALSE, ch, 0, k, TO_VICT | TO_SLEEP);
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);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", OK);
else
send_to_char(ch, "You tell the group, '%s'\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);
send_to_char(vict, "%s", CCNRM(vict, C_NRM));
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", 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))
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))
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 (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", NOPERSON);
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", 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", 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);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", 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 if (paper->action_description)
send_to_char(ch, "There's something written on it already.\r\n");
else {
/* we can write - hooray! */
send_to_char(ch, "Write your note. End with '@' on a new line.\r\n");
act("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM);
string_write(ch->desc, &paper->action_description, MAX_NOTE_LENGTH, 0, NULL);
}
}
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);
} 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);
if (PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", 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_DEAF,
PRF_NOGOSS,
PRF_NOAUCT,
PRF_NOGRATZ,
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}
};
/* 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)) {
send_to_char(ch, "The walls seem to absorb your words.\r\n");
return;
}
/* level_can_shout defined in config.c */
if (GET_LEVEL(ch) < level_can_shout) {
send_to_char(ch, "You must be at least level %d before you can %s.\r\n", 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) < holler_move_cost) {
send_to_char(ch, "You're too exhausted to holler.\r\n");
return;
} else
GET_MOVE(ch) -= 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", 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 &&
!PRF_FLAGGED(i->character, channels[subcmd]) &&
!PLR_FLAGGED(i->character, PLR_WRITING) &&
!ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF)) {
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);
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", 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));
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);
}
}

File diff suppressed because it is too large Load Diff

1483
old-codebase/src/act.item.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,744 @@
/* ************************************************************************
* 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"
/* external variables */
extern int tunnel_size;
/* 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);
/* 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;
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);
/* 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])) >= tunnel_size) {
if (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_GRGOD) {
send_to_char(ch, "You aren't godly enough to use that room!\r\n");
return (0);
}
/* Now we know we're allow 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);
if (!AFF_FLAGGED(ch, AFF_SNEAK))
{
char buf2[MAX_STRING_LENGTH];
snprintf(buf2, sizeof(buf2), "$n has arrived from %s%s.",
(((dir == UP) || (dir == DOWN)) ? "" : "the "),
(dir == UP ? "below": dir == DOWN ? "above" : dirs[rev_dir[dir]])
);
act(buf2, 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);
}
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) || 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 (isname(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 (isname(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;
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", 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", 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.",
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_RESTING;
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", 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", 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);
}
}
}

View File

@@ -0,0 +1,451 @@
/* ************************************************************************
* 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 variables */
extern int pk_allowed;
/* extern functions */
void raw_kill(struct char_data *ch);
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", 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);
else if (!pk_allowed && !IS_NPC(opponent)) /* prevent accidental pkill */
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 (!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);
}
}
}
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", 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", 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);
}

1187
old-codebase/src/act.other.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,345 @@
/* ************************************************************************
* 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 globals */
static int list_top = -1;
/* 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);
struct social_messg {
int act_nr;
int hide;
int min_victim_position; /* Position of victim */
/* No argument was supplied */
char *char_no_arg;
char *others_no_arg;
/* An argument was there, and a victim was found */
char *char_found; /* if NULL, read no further, ignore args */
char *others_found;
char *vict_found;
/* An argument was there, but no victim was found */
char *not_found;
/* The victim turned out to be the character */
char *char_auto;
char *others_auto;
} *soc_mess_list;
int find_action(int cmd)
{
int bot, top, mid;
bot = 0;
top = list_top;
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_action)
{
char buf[MAX_INPUT_LENGTH];
int act_nr;
struct social_messg *action;
struct char_data *vict;
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 (action->char_found && argument)
one_argument(argument, buf);
else
*buf = '\0';
if (!*buf) {
send_to_char(ch, "%s\r\n", action->char_no_arg);
act(action->others_no_arg, action->hide, ch, 0, 0, TO_ROOM);
return;
}
if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "%s\r\n", action->not_found);
else if (vict == ch) {
send_to_char(ch, "%s\r\n", action->char_auto);
act(action->others_auto, action->hide, ch, 0, 0, TO_ROOM);
} 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);
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");
}
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);
/* SYSERR_DESC:
* fread_action() will fail if it discovers an end of file marker
* before it is able to read in the expected string. This can be
* caused by a truncated socials file.
*/
exit(1);
}
if (*buf == '#')
return (NULL);
buf[strlen(buf) - 1] = '\0';
return (strdup(buf));
}
void free_social_messages(void)
{
int ac;
struct social_messg *soc;
for (ac = 0; ac <= list_top; ac++) {
soc = &soc_mess_list[ac];
if (soc->char_no_arg) free(soc->char_no_arg);
if (soc->others_no_arg) free(soc->others_no_arg);
if (soc->char_found) free(soc->char_found);
if (soc->others_found) free(soc->others_found);
if (soc->vict_found) free(soc->vict_found);
if (soc->not_found) free(soc->not_found);
if (soc->char_auto) free(soc->char_auto);
if (soc->others_auto) free(soc->others_auto);
}
free(soc_mess_list);
}
void boot_social_messages(void)
{
FILE *fl;
int nr, i, hide, min_pos, curr_soc = -1;
char next_soc[100];
struct social_messg temp;
/* open social file */
if (!(fl = fopen(SOCMESS_FILE, "r"))) {
log("SYSERR: can't open socials file '%s': %s", SOCMESS_FILE, strerror(errno));
/* SYSERR_DESC:
* This error, from boot_social_messages(), occurs when the server
* fails to open the file containing the social messages. The error
* at the end will indicate the reason why.
*/
exit(1);
}
/* count socials & allocate space */
for (nr = 0; *cmd_info[nr].command != '\n'; nr++)
if (cmd_info[nr].command_pointer == do_action)
list_top++;
CREATE(soc_mess_list, struct social_messg, list_top + 1);
/* now read 'em */
for (;;) {
fscanf(fl, " %s ", next_soc);
if (*next_soc == '$')
break;
if (fscanf(fl, " %d %d \n", &hide, &min_pos) != 2) {
log("SYSERR: format error in social file near social '%s'", next_soc);
/* SYSERR_DESC:
* From boot_social_messages(), this error is output when the
* server is expecting to find the remainder of the first line of the
* social ('hide' and 'minimum position'). These must follow the
* name of the social with a single space such as: 'accuse 0 5\n'.
* This error often occurs when one of the numbers is missing or the
* social name has a space in it (i.e., 'bend over').
*/
exit(1);
}
if (++curr_soc > list_top) {
log("SYSERR: Ran out of slots in social array. (%d > %d)", curr_soc, list_top);
/* SYSERR_DESC:
* The server creates enough space for all of the socials that it finds
* in the command structure (cmd_info[] in interpreter.c). These are
* designated with the 'do_action' command call. If there are more
* socials in the file than in the cmd_info structure, the
* boot_social_messages() function will fail with this error.
*/
break;
}
/* read the stuff */
soc_mess_list[curr_soc].act_nr = nr = find_command(next_soc);
soc_mess_list[curr_soc].hide = hide;
soc_mess_list[curr_soc].min_victim_position = min_pos;
#ifdef CIRCLE_ACORN
if (fgetc(fl) != '\n')
log("SYSERR: Acorn bug workaround failed.");
/* SYSERR_DESC:
* The only time that this error should ever arise is if you are running
* your CircleMUD on the Acorn platform. The error arises when the
* server cannot properly read a '\n' out of the file at the end of the
* first line of the social (that with 'hide' and 'min position'). This
* is in boot_social_messages().
*/
#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 (!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 social not found, re-use this slot. 'curr_soc' will be reincremented. */
if (nr < 0) {
log("SYSERR: Unknown social '%s' in social file.", next_soc);
/* SYSERR_DESC:
* This occurs when the find_command() function in interpreter.c cannot
* find the social of the name in the file in the cmd_info[] structure.
* This is returned to boot_social_messages(), and the function
* reassigns that slot to another social to avoid running out of memory.
* The solution is to add this social to the cmd_info[] array in
* interpreter.c or to remove the social from the file.
*/
memset(&soc_mess_list[curr_soc--], 0, sizeof(struct social_messg));
continue;
}
/* If the command we found isn't do_action, we didn't count it for the CREATE(). */
if (cmd_info[nr].command_pointer != do_action) {
log("SYSERR: Social '%s' already assigned to a command.", next_soc);
/* SYSERR_DESC:
* This error occurs when boot_social_messages() reads in a social and
* then discovers that it is not assigned 'do_action' as a command in
* the cmd_info[] array in interpreter.c
*/
memset(&soc_mess_list[curr_soc--], 0, sizeof(struct social_messg));
}
}
/* close file & set top */
fclose(fl);
list_top = curr_soc;
/* now, sort 'em */
for (curr_soc = 0; curr_soc < list_top; curr_soc++) {
min_pos = curr_soc;
for (i = curr_soc + 1; i <= list_top; i++)
if (soc_mess_list[i].act_nr < soc_mess_list[min_pos].act_nr)
min_pos = i;
if (curr_soc != min_pos) {
temp = soc_mess_list[curr_soc];
soc_mess_list[curr_soc] = soc_mess_list[min_pos];
soc_mess_list[min_pos] = temp;
}
}
}

File diff suppressed because it is too large Load Diff

140
old-codebase/src/alias.c Normal file
View File

@@ -0,0 +1,140 @@
/* ***********************************************************************
* 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': %s", GET_NAME(ch), fn, strerror(errno));
/* SYSERR_DESC:
* This error occurs when the server fails to open the relevant alias
* file for writing. The text at the end of the error should give a
* valid reason why.
*/
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: %s", xbuf, GET_NAME(ch), strerror(errno));
/* SYSERR_DESC:
* This error occurs when the server fails to open the relevant alias
* file for reading. The text at the end version should give a valid
* reason why.
*/
}
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));
/* SYSERR_DESC:
* When an alias file cannot be removed, this error will occur,
* and the reason why will be the tail end of the error.
*/
}

314
old-codebase/src/ban.c Normal file
View File

@@ -0,0 +1,314 @@
/* ************************************************************************
* 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;
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.
*/
for (dt = descriptor_list; dt; dt = dt->next)
if (dt->character && GET_NAME(dt->character) && !str_cmp(GET_NAME(dt->character), newname))
return (STATE(dt) == CON_PLAYING);
/* 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
old-codebase/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"
/* 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.mort", 0},
{3098, LVL_IMMORT, LVL_IMMORT, LVL_GRGOD, LIB_ETC "board.immort", 0},
{3097, LVL_IMMORT, LVL_FREEZE, LVL_IMPL, LIB_ETC "board.freeze", 0},
{3096, 0, 0, LVL_IMMORT, LIB_ETC "board.social", 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);
}
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 (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);
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. Terminate with a @ on a new line.\r\n\r\n");
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);
}
MSG_HEADING(board_type, num_of_msgs[board_type] - 1) = NULL;
MSG_SLOTNUM(board_type, num_of_msgs[board_type] - 1) = 0;
MSG_LEVEL(board_type, num_of_msgs[board_type] - 1) = 0;
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_SLOTNUM(board_type, i) == -1)
continue; /* don't try to free non-existant slots */
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
old-codebase/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 4 /* 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);

View File

@@ -0,0 +1,788 @@
/*
* 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.
**************************************************************/
#if 0
#include "includes.h"
RCSID("$Id: bsd-snprintf.c,v 1.1 2002/04/16 02:22:12 greerga Exp $");
#else
# include "conf.h"
# include "sysdep.h"
# define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif
#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 */

View File

@@ -0,0 +1,58 @@
/*
* 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
#if 0
#include "config.h"
#include <sys/types.h> /* For size_t */
#endif
#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 */

View File

@@ -0,0 +1,518 @@
$!
$! 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,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,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 = "DELOBJS,LISTRENT,MUDPASSWD,PLAY2TO3,PURGEPLAY," + -
"SHOPCONV,SHOWPLAY,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

930
old-codebase/src/castle.c Normal file
View File

@@ -0,0 +1,930 @@
/* ************************************************************************
* 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);
/* SYSERR_DESC:
* When the castle_mob_spec() function is given a mobnum that
* does not correspond to a mod loaded (when not in minimud mode),
* this error will result.
*/
} 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);
}

2227
old-codebase/src/class.c Normal file

File diff suppressed because it is too large Load Diff

2538
old-codebase/src/comm.c Normal file

File diff suppressed because it is too large Load Diff

45
old-codebase/src/comm.h Normal file
View File

@@ -0,0 +1,45 @@
/* ************************************************************************
* 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
/* 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 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_SLEEP 128 /* to char, even if sleeping */
/* 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);

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 */

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
old-codebase/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
old-codebase/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
old-codebase/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
old-codebase/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
old-codebase/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

309
old-codebase/src/config.c Normal file
View File

@@ -0,0 +1,309 @@
/* ************************************************************************
* 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 */
#define TRUE 1
#define YES 1
#define FALSE 0
#define NO 0
/*
* 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 */
/*
* 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 = 2;
/* 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;
/****************************************************************************/
/****************************************************************************/
/* 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 = NOWHERE; /* unused - room for expansion */
room_vnum donation_room_3 = NOWHERE; /* 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;
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 the land of 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;

View File

@@ -0,0 +1,793 @@
/* ************************************************************************
* 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.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. */
"\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",
"AUTOLOOT",
"AUTODRAIN",
"\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",
"Select race",
"Disconnecting",
"\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"
};
/* --- 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;

View File

@@ -0,0 +1,40 @@
extern const char *circlemud_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 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;

3031
old-codebase/src/db.c Normal file

File diff suppressed because it is too large Load Diff

257
old-codebase/src/db.h Normal file
View File

@@ -0,0 +1,257 @@
/* ************************************************************************
* 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
#if defined(CIRCLE_MACINTOSH)
#define LIB_WORLD ":world:"
#define LIB_TEXT ":text:"
#define LIB_TEXT_HELP ":text:help:"
#define LIB_MISC ":misc:"
#define LIB_ETC ":etc:"
#define LIB_PLRTEXT ":plrtext:"
#define LIB_PLROBJS ":plrobjs:"
#define LIB_PLRALIAS ":plralias:"
#define LIB_HOUSE ":house:"
#define 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_HELP "text/help/"
#define LIB_MISC "misc/"
#define LIB_ETC "etc/"
#define LIB_PLRTEXT "plrtext/"
#define LIB_PLROBJS "plrobjs/"
#define LIB_PLRALIAS "plralias/"
#define LIB_HOUSE "house/"
#define SLASH "/"
#else
#error "Unknown path components."
#endif
#define SUF_OBJS "objs"
#define SUF_TEXT "text"
#define SUF_ALIAS "alias"
#if defined(CIRCLE_AMIGA)
#define FASTBOOT_FILE "/.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "/.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "/pause" /* autorun: don't restart mud */
#elif defined(CIRCLE_MACINTOSH)
#define FASTBOOT_FILE "::.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "::.killscript" /* autorun: shut mud down */
#define PAUSE_FILE "::pause" /* autorun: don't restart mud */
#else
#define FASTBOOT_FILE "../.fastboot" /* autorun: boot without sleep */
#define KILLSCRIPT_FILE "../.killscript"/* autorun: shut mud down */
#define PAUSE_FILE "../pause" /* autorun: don't restart mud */
#endif
/* names of various files and directories */
#define INDEX_FILE "index" /* index of world files */
#define MINDEX_FILE "index.mini" /* ... and for mini-mud-mode */
#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 HLP_PREFIX LIB_TEXT"help"SLASH /* for HELP <keyword> */
#define CREDITS_FILE LIB_TEXT"credits" /* for the 'credits' command */
#define NEWS_FILE LIB_TEXT"news" /* for the 'news' command */
#define MOTD_FILE LIB_TEXT"motd" /* messages of the day / mortal */
#define IMOTD_FILE LIB_TEXT"imotd" /* messages of the day / immort */
#define GREETINGS_FILE LIB_TEXT"greetings" /* The opening screen. */
#define HELP_PAGE_FILE LIB_TEXT_HELP"screen" /* for HELP <CR> */
#define INFO_FILE LIB_TEXT"info" /* for INFO */
#define WIZLIST_FILE LIB_TEXT"wizlist" /* for WIZLIST */
#define IMMLIST_FILE LIB_TEXT"immlist" /* for IMMLIST */
#define BACKGROUND_FILE LIB_TEXT"background"/* for the background story */
#define POLICIES_FILE LIB_TEXT"policies" /* player policies/rules */
#define HANDBOOK_FILE LIB_TEXT"handbook" /* handbook for new immorts */
#define 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 XNAME_FILE LIB_MISC"xnames" /* invalid name substrings */
#define PLAYER_FILE LIB_ETC"players" /* the player database */
#define MAIL_FILE LIB_ETC"plrmail" /* 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 */
/* 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_player_index(void);
void free_help(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);
void char_to_store(struct char_data *ch, struct char_file_u *st);
void store_to_char(struct char_file_u *st, struct char_data *ch);
int load_char(const char *name, struct char_file_u *char_element);
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);
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);
#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 */
/*
* 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 *
*/
};
/* zone definition structure. for the 'zone-table' */
struct zone_data {
char *name; /* name of this zone */
int lifespan; /* how long between resets (minutes) */
int age; /* current age of this zone (minutes) */
room_vnum bot; /* starting room number for this zone */
room_vnum top; /* upper limit for rooms in this zone */
int 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;
};
struct player_index_element {
char *name;
long id;
};
struct help_index_element {
char *keyword;
char *entry;
int duplicate;
};
/* 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 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;
#endif
#ifndef __CONFIG_C__
extern char *OK;
extern char *NOPERSON;
extern char *NOEFFECT;
#endif

63
old-codebase/src/doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,63 @@
conf.h
.accepted
Makefile
act.comm.c.html
act.informative.c.html
act.item.c.html
act.movement.c.html
act.offensive.c.html
act.other.c.html
act.social.c.html
act.wizard.c.html
alias.c.html
ban.c.html
boards.c.html
boards.h.html
castle.c.html
circle.function
circle.html
circle.include
circle.typedef
circle.variable
class.c.html
comm.c.html
comm.h.html
conf.h.html
config.c.html
constants.c.html
constants.h.html
db.c.html
db.h.html
fight.c.html
graph.c.html
handler.c.html
handler.h.html
house.c.html
house.h.html
index.html
interpreter.c.html
interpreter.h.html
limits.c.html
magic.c.html
mail.c.html
mail.h.html
mobact.c.html
modify.c.html
objsave.c.html
olc.c.html
olc.h.html
random.c.html
screen.h.html
shop.c.html
shop.h.html
spec_assign.c.html
spec_procs.c.html
spell_parser.c.html
spells.c.html
spells.h.html
structs.h.html
sysdep.h.html
telnet.h.html
utils.c.html
utils.h.html
weather.c.html

1041
old-codebase/src/fight.c Normal file

File diff suppressed because it is too large Load Diff

249
old-codebase/src/graph.c Normal file
View File

@@ -0,0 +1,249 @@
/* ************************************************************************
* 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[];
extern int track_through_doors;
/* 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 (track_through_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);
}
}

1393
old-codebase/src/handler.c Normal file

File diff suppressed because it is too large Load Diff

112
old-codebase/src/handler.h Normal file
View File

@@ -0,0 +1,112 @@
/* ************************************************************************
* 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);
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);

616
old-codebase/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(last_pay));
} 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
old-codebase/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);

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,212 @@
/* ************************************************************************
* 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 (cmd_info[cmd].command)
#define CMD_IS(cmd_name) (!strcmp(cmd_name, cmd_info[cmd].command))
#define IS_MOVE(cmdnum) (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)
struct command_info {
const char *command;
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 const struct command_info 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_DEAF 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_AUTOLOOT 17
#define SCMD_AUTODRAIN 18
/* 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
/* 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

21
old-codebase/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.doc 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 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

478
old-codebase/src/limits.c Normal file
View File

@@ -0,0 +1,478 @@
/* ************************************************************************
* 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"
/* external variables */
extern int max_exp_gain;
extern int max_exp_loss;
extern int idle_rent_time;
extern int idle_max_level;
extern int idle_void;
extern int immort_level_ok;
extern int use_autowiz;
extern int min_wizlist_lev;
extern int free_rent;
/* 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 (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 &",
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",
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(max_exp_gain, gain); /* put a cap on the max gain per kill */
GET_EXP(ch) += gain;
while (GET_LEVEL(ch) < LVL_IMMORT - 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(-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) > 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 > 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 (free_rent)
Crash_rentsave(ch, 0);
else
Crash_idlesave(ch);
mudlog(CMP, LVL_GOD, TRUE, "%s force-rented and extracted (idle).", GET_NAME(ch));
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) < 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);
}
}
}
}

972
old-codebase/src/magic.c Normal file
View File

@@ -0,0 +1,972 @@
/* ************************************************************************
* 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"
/* external variables */
extern int mini_mud;
extern int pk_allowed;
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", 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", 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 (!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", 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", 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 (!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);
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", 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", 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);
}

634
old-codebase/src/mail.c Normal file
View File

@@ -0,0 +1,634 @@
/* ************************************************************************
* 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)
*************************************************************************/
#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;
/* external functions */
SPECIAL(postmaster);
/* local globals */
mail_index_type *mail_index = NULL; /* list of recs in the mail file */
position_list_type *free_list = NULL; /* list of free positions in file */
long file_end_pos = 0; /* length of file */
/* 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);
void push_free_list(long pos);
long pop_free_list(void);
void clear_free_list(void);
mail_index_type *find_char_in_index(long searchee);
void write_to_file(void *buf, int size, long filepos);
void read_from_file(void *buf, int size, long filepos);
void index_mail(long id_to_index, long pos);
int mail_recip_ok(const char *name);
/* -------------------------------------------------------------------------- */
int mail_recip_ok(const char *name)
{
struct char_file_u tmp_store;
struct char_data *victim;
int ret = FALSE;
CREATE(victim, struct char_data, 1);
clear_char(victim);
if (load_char(name, &tmp_store) >= 0) {
store_to_char(&tmp_store, victim);
char_to_room(victim, 0);
if (!PLR_FLAGGED(victim, PLR_DELETED))
ret = TRUE;
extract_char_final(victim);
} else
free(victim);
return ret;
}
/*
* void push_free_list(long #1)
* #1 - What byte offset into the file the block resides.
*
* Net effect is to store a list of free blocks in the mail file in a linked
* list. This is called when people receive their messages and at startup
* when the list is created.
*/
void push_free_list(long pos)
{
position_list_type *new_pos;
CREATE(new_pos, position_list_type, 1);
new_pos->position = pos;
new_pos->next = free_list;
free_list = new_pos;
}
/*
* long pop_free_list(none)
* Returns the offset of a free block in the mail file.
*
* Typically used whenever a person mails a message. The blocks are not
* guaranteed to be sequential or in any order at all.
*/
long pop_free_list(void)
{
position_list_type *old_pos;
long return_value;
/*
* If we don't have any free blocks, we append to the file.
*/
if ((old_pos = free_list) == NULL)
return (file_end_pos);
/* Save the offset of the free block. */
return_value = free_list->position;
/* Remove this block from the free list. */
free_list = old_pos->next;
/* Get rid of the memory the node took. */
free(old_pos);
/* Give back the free offset. */
return (return_value);
}
void clear_free_list(void)
{
while (free_list)
pop_free_list();
}
/*
* main_index_type *find_char_in_index(long #1)
* #1 - The idnum of the person to look for.
* Returns a pointer to the mail block found.
*
* Finds the first mail block for a specific person based on id number.
*/
mail_index_type *find_char_in_index(long searchee)
{
mail_index_type *tmp;
if (searchee < 0) {
log("SYSERR: Mail system -- non fatal error #1 (searchee == %ld).", searchee);
return (NULL);
}
for (tmp = mail_index; (tmp && tmp->recipient != searchee); tmp = tmp->next);
return (tmp);
}
/*
* void write_to_file(void * #1, int #2, long #3)
* #1 - A pointer to the data to write, usually the 'block' record.
* #2 - How much to write (because we'll write NUL terminated strings.)
* #3 - What offset (block position) in the file to write to.
*
* Writes a mail block back into the database at the given location.
*/
void write_to_file(void *buf, int size, long filepos)
{
FILE *mail_file;
if (filepos % BLOCK_SIZE) {
log("SYSERR: Mail system -- fatal error #2!!! (invalid file position %ld)", filepos);
no_mail = TRUE;
return;
}
if (!(mail_file = fopen(MAIL_FILE, "r+b"))) {
log("SYSERR: Unable to open mail file '%s'.", MAIL_FILE);
no_mail = TRUE;
return;
}
fseek(mail_file, filepos, SEEK_SET);
fwrite(buf, size, 1, mail_file);
/* find end of file */
fseek(mail_file, 0L, SEEK_END);
file_end_pos = ftell(mail_file);
fclose(mail_file);
return;
}
/*
* void read_from_file(void * #1, int #2, long #3)
* #1 - A pointer to where we should store the data read.
* #2 - How large the block we're reading is.
* #3 - What position in the file to read.
*
* This reads a block from the mail database file.
*/
void read_from_file(void *buf, int size, long filepos)
{
FILE *mail_file;
if (filepos % BLOCK_SIZE) {
log("SYSERR: Mail system -- fatal error #3!!! (invalid filepos read %ld)", filepos);
no_mail = TRUE;
return;
}
if (!(mail_file = fopen(MAIL_FILE, "r+b"))) {
log("SYSERR: Unable to open mail file '%s'.", MAIL_FILE);
no_mail = TRUE;
return;
}
fseek(mail_file, filepos, SEEK_SET);
fread(buf, size, 1, mail_file);
fclose(mail_file);
return;
}
void index_mail(long id_to_index, long pos)
{
mail_index_type *new_index;
position_list_type *new_position;
if (id_to_index < 0) {
log("SYSERR: Mail system -- non-fatal error #4. (id_to_index == %ld)", id_to_index);
return;
}
if (!(new_index = find_char_in_index(id_to_index))) {
/* name not already in index.. add it */
CREATE(new_index, mail_index_type, 1);
new_index->recipient = id_to_index;
new_index->list_start = NULL;
/* add to front of list */
new_index->next = mail_index;
mail_index = new_index;
}
/* now, add this position to front of position list */
CREATE(new_position, position_list_type, 1);
new_position->position = pos;
new_position->next = new_index->list_start;
new_index->list_start = new_position;
}
/*
* 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;
header_block_type next_block;
int total_messages = 0, block_num = 0;
if (!(mail_file = fopen(MAIL_FILE, "rb"))) {
log(" Mail file non-existant... creating new file.");
touch(MAIL_FILE);
return (1);
}
while (fread(&next_block, sizeof(header_block_type), 1, mail_file)) {
if (next_block.block_type == HEADER_BLOCK) {
index_mail(next_block.header_data.to, block_num * BLOCK_SIZE);
total_messages++;
} else if (next_block.block_type == DELETED_BLOCK)
push_free_list(block_num * BLOCK_SIZE);
block_num++;
}
file_end_pos = ftell(mail_file);
fclose(mail_file);
log(" %ld bytes read.", file_end_pos);
if (file_end_pos % BLOCK_SIZE) {
log("SYSERR: Error booting mail system -- Mail file corrupt!");
log("SYSERR: Mail disabled!");
return (0);
}
log(" Mail file read -- %d messages.", total_messages);
return (1);
} /* end of scan_file */
/*
* 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)
{
return (find_char_in_index(recipient) != NULL);
}
/*
* 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)
{
header_block_type header;
data_block_type data;
long last_address, target_address;
char *msg_txt = message_pointer;
int bytes_written, total_length = strlen(message_pointer);
if ((sizeof(header_block_type) != sizeof(data_block_type)) ||
(sizeof(header_block_type) != BLOCK_SIZE)) {
core_dump();
return;
}
if (from < 0 || to < 0 || !*message_pointer) {
log("SYSERR: Mail system -- non-fatal error #5. (from == %ld, to == %ld)", from, to);
return;
}
memset((char *) &header, 0, sizeof(header)); /* clear the record */
header.block_type = HEADER_BLOCK;
header.header_data.next_block = LAST_BLOCK;
header.header_data.from = from;
header.header_data.to = to;
header.header_data.mail_time = time(0);
strncpy(header.txt, msg_txt, HEADER_BLOCK_DATASIZE); /* strncpy: OK (h.txt:HEADER_BLOCK_DATASIZE+1) */
header.txt[HEADER_BLOCK_DATASIZE] = '\0';
target_address = pop_free_list(); /* find next free block */
index_mail(to, target_address); /* add it to mail index in memory */
write_to_file(&header, BLOCK_SIZE, target_address);
if (strlen(msg_txt) <= HEADER_BLOCK_DATASIZE)
return; /* that was the whole message */
bytes_written = HEADER_BLOCK_DATASIZE;
msg_txt += HEADER_BLOCK_DATASIZE; /* move pointer to next bit of text */
/*
* find the next block address, then rewrite the header to reflect where
* the next block is.
*/
last_address = target_address;
target_address = pop_free_list();
header.header_data.next_block = target_address;
write_to_file(&header, BLOCK_SIZE, last_address);
/* now write the current data block */
memset((char *) &data, 0, sizeof(data)); /* clear the record */
data.block_type = LAST_BLOCK;
strncpy(data.txt, msg_txt, DATA_BLOCK_DATASIZE); /* strncpy: OK (d.txt:DATA_BLOCK_DATASIZE+1) */
data.txt[DATA_BLOCK_DATASIZE] = '\0';
write_to_file(&data, BLOCK_SIZE, target_address);
bytes_written += strlen(data.txt);
msg_txt += strlen(data.txt);
/*
* if, after 1 header block and 1 data block there is STILL part of the
* message left to write to the file, keep writing the new data blocks and
* rewriting the old data blocks to reflect where the next block is. Yes,
* this is kind of a hack, but if the block size is big enough it won't
* matter anyway. Hopefully, MUD players won't pour their life stories out
* into the Mud Mail System anyway.
*
* Note that the block_type data field in data blocks is either a number >=0,
* meaning a link to the next block, or LAST_BLOCK flag (-2) meaning the
* last block in the current message. This works much like DOS' FAT.
*/
while (bytes_written < total_length) {
last_address = target_address;
target_address = pop_free_list();
/* rewrite the previous block to link it to the next */
data.block_type = target_address;
write_to_file(&data, BLOCK_SIZE, last_address);
/* now write the next block, assuming it's the last. */
data.block_type = LAST_BLOCK;
strncpy(data.txt, msg_txt, DATA_BLOCK_DATASIZE); /* strncpy: OK (d.txt:DATA_BLOCK_DATASIZE+1) */
data.txt[DATA_BLOCK_DATASIZE] = '\0';
write_to_file(&data, BLOCK_SIZE, target_address);
bytes_written += strlen(data.txt);
msg_txt += strlen(data.txt);
}
} /* store mail */
/*
* 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 and the mail index.
*/
char *read_delete(long recipient)
{
header_block_type header;
data_block_type data;
mail_index_type *mail_pointer, *prev_mail;
position_list_type *position_pointer;
long mail_address, following_block;
char *tmstr, buf[MAX_MAIL_SIZE + 256]; /* + header */
char *from, *to;
if (recipient < 0) {
log("SYSERR: Mail system -- non-fatal error #6. (recipient: %ld)", recipient);
return (NULL);
}
if (!(mail_pointer = find_char_in_index(recipient))) {
log("SYSERR: Mail system -- post office spec_proc error? Error #7. (invalid character in index)");
return (NULL);
}
if (!(position_pointer = mail_pointer->list_start)) {
log("SYSERR: Mail system -- non-fatal error #8. (invalid position pointer %p)", position_pointer);
return (NULL);
}
if (!(position_pointer->next)) { /* just 1 entry in list. */
mail_address = position_pointer->position;
free(position_pointer);
/* now free up the actual name entry */
if (mail_index == mail_pointer) { /* name is 1st in list */
mail_index = mail_pointer->next;
free(mail_pointer);
} else {
/* find entry before the one we're going to del */
for (prev_mail = mail_index;
prev_mail->next != mail_pointer;
prev_mail = prev_mail->next);
prev_mail->next = mail_pointer->next;
free(mail_pointer);
}
} else {
/* move to next-to-last record */
while (position_pointer->next->next)
position_pointer = position_pointer->next;
mail_address = position_pointer->next->position;
free(position_pointer->next);
position_pointer->next = NULL;
}
/* ok, now lets do some readin'! */
read_from_file(&header, BLOCK_SIZE, mail_address);
if (header.block_type != HEADER_BLOCK) {
log("SYSERR: Oh dear. (Header block %ld != %d)", header.block_type, HEADER_BLOCK);
no_mail = TRUE;
log("SYSERR: Mail system disabled! -- Error #9. (Invalid header block.)");
return (NULL);
}
tmstr = asctime(localtime(&header.header_data.mail_time));
*(tmstr + strlen(tmstr) - 1) = '\0';
from = get_name_by_id(header.header_data.from);
to = get_name_by_id(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",
header.txt
);
following_block = header.header_data.next_block;
/* mark the block as deleted */
header.block_type = DELETED_BLOCK;
write_to_file(&header, BLOCK_SIZE, mail_address);
push_free_list(mail_address);
while (following_block != LAST_BLOCK) {
read_from_file(&data, BLOCK_SIZE, following_block);
strcat(buf, data.txt); /* strcat: OK (data.txt:DATA_BLOCK_DATASIZE < buf:MAX_MAIL_SIZE) */
mail_address = following_block;
following_block = data.block_type;
data.block_type = DELETED_BLOCK;
write_to_file(&data, BLOCK_SIZE, mail_address);
push_free_list(mail_address);
}
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) {
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, use @ on a new line when done.'",
STAMP_PRICE);
act(buf, FALSE, mailman, 0, ch, TO_VICT);
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 = create_obj();
obj->item_number = NOTHING;
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 | ITEM_WEAR_HOLD;
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);
}
}
void free_mail_index(void)
{
while (mail_index) {
mail_index_type *tmp_index = mail_index;
mail_index = mail_index->next;
while (tmp_index->list_start) {
position_list_type *tmp_list;
tmp_list = tmp_index->list_start;
tmp_index->list_start = tmp_index->list_start->next;
free(tmp_list);
}
free(tmp_index);
}
}

108
old-codebase/src/mail.h Normal file
View File

@@ -0,0 +1,108 @@
/* ************************************************************************
* 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 2
/* # 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);
#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;

283
old-codebase/src/mobact.c Normal file
View File

@@ -0,0 +1,283 @@
/* ************************************************************************
* 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);
/* 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;
/* 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);
}

442
old-codebase/src/modify.c Normal file
View File

@@ -0,0 +1,442 @@
/* ************************************************************************
* 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"
void show_string(struct descriptor_data *d, char *input);
extern struct spell_info_type spell_info[];
extern const char *MENU;
extern const char *unused_spellname; /* spell_parser.c */
/* local functions */
void smash_tilde(char *str);
ACMD(do_skillset);
char *next_page(char *str);
int count_pages(char *str);
void paginate_string(char *str, struct descriptor_data *d);
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)
{
#if 0
/*
* Erase any ~'s inserted by people in the editor. This prevents anyone
* using online creation from causing parse errors in the world files.
* Derived from an idea by Sammy <samedi@dhc.net> (who happens to like
* his tildes thank you very much.), -gg 2/20/98
*/
while ((str = strchr(str, '~')) != NULL)
*str = ' ';
#endif
}
/*
* 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 (data)
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: string_write: I don't understand special data.");
d->str = writeto;
d->max_str = len;
d->mail_to = mailto;
}
/* Add user input to the 'current' string (as defined by d->str) */
void string_add(struct descriptor_data *d, char *str)
{
int terminator;
/* 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);
if ((terminator = (*str == '@')))
*str = '\0';
smash_tilde(str);
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) */
terminator = 1;
} 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");
terminator = 1;
} else {
RECREATE(*d->str, char, strlen(*d->str) + strlen(str) + 3); /* \r\n\0 */
strcat(*d->str, str); /* strcat: OK (size precalculated) */
}
}
if (terminator) {
if (STATE(d) == CON_PLAYING && (PLR_FLAGGED(d->character, PLR_MAILING))) {
store_mail(d->mail_to, GET_IDNUM(d->character), *d->str);
d->mail_to = 0;
free(*d->str);
free(d->str);
write_to_output(d, "Message sent!\r\n");
if (!IS_NPC(d->character))
REMOVE_BIT(PLR_FLAGS(d->character), PLR_MAILING | PLR_WRITING);
}
d->str = NULL;
if (d->mail_to >= BOARD_MAGIC) {
Board_save_board(d->mail_to - BOARD_MAGIC);
d->mail_to = 0;
}
if (STATE(d) == CON_EXDESC) {
write_to_output(d, "%s", MENU);
STATE(d) = CON_MENU;
}
if (STATE(d) == CON_PLAYING && d->character && !IS_NPC(d->character))
REMOVE_BIT(PLR_FLAGS(d->character), PLR_WRITING);
} else
strcat(*d->str, "\r\n"); /* strcat: OK (size checked) */
}
/* **********************************************************************
* 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", 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)
{
int col = 1, line = 1, spec_code = FALSE;
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 > PAGE_LENGTH)
return (str);
/* Check for the begining of an ANSI color code block. */
else if (*str == '\x1B' && !spec_code)
spec_code = TRUE;
/* Check for the end of an ANSI color code block. */
else if (*str == 'm' && spec_code)
spec_code = FALSE;
/* Check for everything else. */
else if (!spec_code) {
/* 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)
{
int pages;
for (pages = 1; (str = next_page(str)); 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->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;
d->showstr_count = count_pages(str);
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.
*/
if (d->showstr_page + 1 >= d->showstr_count) {
send_to_char(d->character, "%s", 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++;
}
}

1166
old-codebase/src/objsave.c Normal file

File diff suppressed because it is too large Load Diff

351
old-codebase/src/olc.c Normal file
View File

@@ -0,0 +1,351 @@
/* ************************************************************************
* File: olc.c Part of CircleMUD *
* Usage: online creation *
* *
* 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. *
************************************************************************ */
/*
* PLEASE, FOR THE LOVE OF GOD, DON'T TRY TO USE THIS YET!!!
* *** DO *** NOT *** SEND ME MAIL ASKING WHY IT DOESN'T WORK -- IT'S
* NOT DONE!!
*/
#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 "olc.h"
/* OLC command format:
*
* olc {"." | {<"room"|"mobile"|"object"> <number>}} <arguments>
* olc {"set"|"show"} <attribute> <arguments>
*/
#define OLC_USAGE "Usage: olc { . | set | show | obj | mob | room} [args]\r\n"
/* local globals */
struct char_data *olc_ch;
/* local functions */
void olc_interpreter(void *targ, int mode, char *arg);
void olc_set_show(struct char_data *ch, int olc_mode, char *arg);
void olc_string(char **string, size_t maxlen, char *arg);
int can_modify(struct char_data *ch, int vnum);
ACMD(do_olc);
void olc_bitvector(int *bv, const char **names, char *arg);
const char *olc_modes[] = {
"set", /* set OLC characteristics */
"show", /* show OLC characteristics */
".", /* repeat last modification command */
"room", /* modify a room */
"mobile", /* modify a mobile */
"object", /* modify an object */
"\n"
};
const char *olc_commands[] = {
"copy",
"name",
"description",
"aliases",
"\n", /* many more to be added */
};
/* The actual do_olc command for the interpreter. Determines the target
entity, checks permissions, and passes control to olc_interpreter */
ACMD(do_olc)
{
void *olc_targ = NULL;
char mode_arg[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
room_rnum rnum;
room_vnum vnum = NOWHERE;
int olc_mode;
/* WARNING! **DO NOT** under any circumstances remove the code below!!!! */
if (strcmp(GET_NAME(ch), "Ras")) {
send_to_char(ch, "OLC is not yet complete. Sorry.\r\n");
return;
}
/* WARNING! **DO NOT** under any circumstances remove the code above!!!! */
/* first, figure out the first (mode) argument */
half_chop(argument, mode_arg, argument);
if ((olc_mode = search_block(mode_arg, olc_modes, FALSE)) < 0) {
send_to_char(ch, "Invalid mode '%s'.\r\n%s", mode_arg, OLC_USAGE);
return;
}
switch (olc_mode) {
case OLC_SET:
case OLC_SHOW:
olc_set_show(ch, olc_mode, argument);
return;
case OLC_REPEAT:
if (!(olc_mode = GET_LAST_OLC_MODE(ch)) ||
((olc_targ = GET_LAST_OLC_TARG(ch)) == NULL)) {
send_to_char(ch, "No last OLC operation!\r\n");
return;
}
break;
case OLC_ROOM:
if (isdigit(*argument)) {
/* room specified. take the numeric argument off */
argument = one_argument(argument, arg);
if (!is_number(arg)) {
send_to_char(ch, "Invalid room vnum '%s'.\r\n", arg);
return;
}
vnum = atoi(arg);
if ((rnum = real_room(vnum)) == NOWHERE) {
send_to_char(ch, "No such room!\r\n");
return;
}
} else {
rnum = IN_ROOM(ch);
vnum = GET_ROOM_VNUM(IN_ROOM(ch));
send_to_char(ch, "(Using current room %d)\r\n", vnum);
}
/* if (!ROOM_FLAGGED(rnum, ROOM_OLC))
send_to_char(ch, "That room is not modifyable.\r\n");
else
*/
olc_targ = (void *) &(world[rnum]);
break;
case OLC_MOB:
argument = one_argument(argument, arg);
if (!is_number(arg)) {
send_to_char(ch, "Invalid mob vnum '%s'.\r\n", arg);
return;
}
vnum = atoi(arg);
if ((rnum = real_mobile(vnum)) == NOBODY)
send_to_char(ch, "No such mobile vnum.\r\n");
else
olc_targ = (void *) &(mob_proto[rnum]);
break;
case OLC_OBJ:
argument = one_argument(argument, arg);
if (!is_number(arg)) {
send_to_char(ch, "Invalid obj vnum '%s'\r\n", arg);
return;
}
vnum = atoi(arg);
if ((rnum = real_object(vnum)) == NOTHING)
send_to_char(ch, "No object with vnum %d.\r\n", vnum);
else
olc_targ = (void *) &(obj_proto[rnum]);
break;
default:
send_to_char(ch, "Usage: olc {.|set|show|obj|mob|room} [args]\r\n");
return;
}
if (olc_targ == NULL)
return;
if (!can_modify(ch, vnum)) {
send_to_char(ch, "You can't modify that.\r\n");
return;
}
GET_LAST_OLC_MODE(ch) = olc_mode;
GET_LAST_OLC_TARG(ch) = olc_targ;
olc_ch = ch;
olc_interpreter(olc_targ, olc_mode, argument);
/* freshen? */
}
/* OLC interpreter command; called by do_olc */
void olc_interpreter(void *targ, int mode, char *arg)
{
int error = 0, command;
char command_string[MAX_INPUT_LENGTH];
struct char_data *olc_mob = NULL;
struct room_data *olc_room = NULL;
struct obj_data *olc_obj = NULL;
half_chop(arg, command_string, arg);
if ((command = search_block(command_string, olc_commands, FALSE)) < 0) {
send_to_char(olc_ch, "Invalid OLC command '%s'.\r\n", command_string);
return;
}
switch (mode) {
case OLC_ROOM:
olc_room = (struct room_data *) targ;
break;
case OLC_MOB:
olc_mob = (struct char_data *) targ;
break;
case OLC_OBJ:
olc_obj = (struct obj_data *) targ;
break;
default:
log("SYSERR: Invalid OLC mode %d passed to interp.", mode);
return;
}
switch (command) {
case OLC_COPY:
switch (mode) {
case OLC_ROOM:
break;
case OLC_MOB:
break;
case OLC_OBJ:
break;
default:
error = 1;
break;
}
break;
case OLC_NAME:
switch (mode) {
case OLC_ROOM:
olc_string(&(olc_room->name), MAX_ROOM_NAME, arg);
break;
case OLC_MOB:
olc_string(&olc_mob->player.short_descr, MAX_MOB_NAME, arg);
break;
case OLC_OBJ:
olc_string(&olc_obj->short_description, MAX_OBJ_NAME, arg);
break;
default:
error = 1;
break;
}
break;
case OLC_DESC:
switch (mode) {
case OLC_ROOM:
olc_string(&olc_room->description, MAX_ROOM_DESC, arg);
break;
case OLC_MOB:
olc_string(&olc_mob->player.long_descr, MAX_MOB_DESC, arg);
break;
case OLC_OBJ:
olc_string(&olc_obj->description, MAX_OBJ_DESC, arg);
break;
default:
error = 1;
break;
}
break;
case OLC_ALIASES:
switch (mode) {
case OLC_ROOM:
break;
case OLC_MOB:
break;
case OLC_OBJ:
break;
default:
error = 1;
break;
}
}
}
/* can_modify: determine if a particular char can modify a vnum */
int can_modify(struct char_data *ch, int vnum)
{
return (1);
}
/* generic fn for modifying a string */
void olc_string(char **string, size_t maxlen, char *arg)
{
skip_spaces(&arg);
if (!*arg) {
send_to_char(olc_ch, "Enter new string (max of %d characters); use '@' on a new line when done.\r\n", (int) maxlen);
**string = '\0';
string_write(olc_ch->desc, string, maxlen, 0, NULL);
} else {
if (strlen(arg) > maxlen) {
send_to_char(olc_ch, "String too long (cannot be more than %d chars).\r\n", (int) maxlen);
} else {
if (*string != NULL)
free(*string);
*string = strdup(arg);
send_to_char(olc_ch, "%s", OK);
}
}
}
/* generic fn for modifying a bitvector */
void olc_bitvector(int *bv, const char **names, char *arg)
{
int newbv, flagnum, doremove = 0;
char *this_name;
char buf[MAX_STRING_LENGTH];
skip_spaces(&arg);
if (!*arg) {
send_to_char(olc_ch, "Flag list or flag modifiers required.\r\n");
return;
}
/* determine if this is 'absolute' or 'relative' mode */
if (*arg == '+' || *arg == '-')
newbv = *bv;
else
newbv = 0;
while (*arg) {
arg = one_argument(arg, buf); /* get next argument */
/* change to upper-case */
for (this_name = buf; *this_name; this_name++)
CAP(this_name);
/* determine if this is an add or a subtract */
if (*buf == '+' || *buf == '-') {
this_name = buf + 1;
if (*buf == '-')
doremove = TRUE;
else
doremove = FALSE;
} else {
this_name = buf;
doremove = FALSE;
}
/* figure out which one we're dealing with */
if ((flagnum = search_block(this_name, names, TRUE)) < 0)
send_to_char(olc_ch, "Unknown flag: %s\r\n", this_name);
else {
if (doremove)
REMOVE_BIT(newbv, (1 << flagnum));
else
SET_BIT(newbv, (1 << flagnum));
}
}
*bv = newbv;
sprintbit(newbv, names, buf, sizeof(buf));
send_to_char(olc_ch, "Flags now set to: %s\r\n", buf);
}
void olc_set_show(struct char_data *ch, int olc_mode, char *arg)
{
}

19
old-codebase/src/olc.h Normal file
View File

@@ -0,0 +1,19 @@
#define OLC_SET 0
#define OLC_SHOW 1
#define OLC_REPEAT 2
#define OLC_ROOM 3
#define OLC_MOB 4
#define OLC_OBJ 5
#define OLC_COPY 0
#define OLC_NAME 1
#define OLC_DESC 2
#define OLC_ALIASES 3
#define MAX_ROOM_NAME 75
#define MAX_MOB_NAME 50
#define MAX_OBJ_NAME 50
#define MAX_ROOM_DESC 1024
#define MAX_MOB_DESC 512
#define MAX_OBJ_DESC 512

View File

@@ -0,0 +1,105 @@
CREATE TABLE preferences (
id integer NOT NULL PRIMARY KEY,
internal_name varchar(20) NOT NULL UNIQUE,
description varchar(240) NOT NULL,
);
INSERT INTO preferences (id, internal_name, description) VALUES (1, 'BRIEF', 'Room descriptions won''t normally be shown');
INSERT INTO preferences (id, internal_name, description) VALUES (2, 'COMPACT', 'No extra CRLF pair before prompt');
INSERT INTO preferences (id, internal_name, description) VALUES (3, 'DEAF', 'Can''t hear shouts');
INSERT INTO preferences (id, internal_name, description) VALUES (4, 'NO_TELL', 'Can''t receive tells');
INSERT INTO preferences (id, internal_name, description) VALUES (5, 'D_HP', 'Display Hit Points in prompt');
INSERT INTO preferences (id, internal_name, description) VALUES (6, 'D_MANA', 'Display Mana Points in prompt');
INSERT INTO preferences (id, internal_name, description) VALUES (7, 'D_MOVE', 'Display Move Points in prompt');
INSERT INTO preferences (id, internal_name, description) VALUES (8, 'AUTOEX', 'Display exits in a room');
INSERT INTO preferences (id, internal_name, description) VALUES (9, 'NO_HASS', 'Aggressive mobs won''t attack');
INSERT INTO preferences (id, internal_name, description) VALUES (10, 'QUEST', 'Player is on a quest');
INSERT INTO preferences (id, internal_name, description) VALUES (11, 'SUMN', 'Can be summoned');
INSERT INTO preferences (id, internal_name, description) VALUES (12, 'NO_REP', 'No repetition of comm commands');
INSERT INTO preferences (id, internal_name, description) VALUES (13, 'LIGHT', 'Holy Light enabled');
INSERT INTO preferences (id, internal_name, description) VALUES (14, 'C1', 'Color (low bit)');
INSERT INTO preferences (id, internal_name, description) VALUES (15, 'C2', 'Color (high bit)');
INSERT INTO preferences (id, internal_name, description) VALUES (16, 'NO_WIZ', 'Can''t hear wizline');
INSERT INTO preferences (id, internal_name, description) VALUES (17, 'L1', 'Online system log (low bit)');
INSERT INTO preferences (id, internal_name, description) VALUES (18, 'L2', 'Online system log (high bit)');
INSERT INTO preferences (id, internal_name, description) VALUES (19, 'NO_AUC', 'Can''t hear auction channel');
INSERT INTO preferences (id, internal_name, description) VALUES (20, 'NO_GOS', 'Can''t hear gossip channel');
INSERT INTO preferences (id, internal_name, description) VALUES (21, 'NO_GTZ', 'Can''t hear grats channel');
INSERT INTO preferences (id, internal_name, description) VALUES (22, 'RMFLG', 'Can see room flags');
INSERT INTO preferences (id, internal_name, description) VALUES (23, 'DISPAUTO', 'Show prompt HP, MP, MV when < 30%');
INSERT INTO preferences (id, internal_name, description) VALUES (23, 'AUTOLOOT', 'Automatically loot corpses on kill');
INSERT INTO preferences (id, internal_name, description) VALUES (24, 'AUTODRAIN', 'Automatically drain corpses on kill');
CREATE TABLE affections (
id integer NOT NULL PRIMARY KEY,
spell_type integer NOT NULL UNIQUE,
duration integer,
modifier int2,
location int2,
bitvector unsigned big int
);
CREATE TABLE players (
id integer NOT NULL, -- Used to be idnum!
name varchar(20) UNIQUE NOT NULL PRIMARY KEY,
description varchar(240),
title varchar(80),
sex int2 NOT NULL,
class int2 NOT NULL,
race int2 NOT NULL,
level int2 NOT NULL DEFAULT 1,
hometown unsigned big int NOT NULL,
birth datetime NOT NULL,
played unsigned big int NOT NULL DEFAULT 0,
weight integer NOT NULL,
height integer NOT NULL,
pwd varchar(10) NOT NULL,
alignment integer NOT NULL,
long /*bitvector_t*/ act; /* act flag for NPC's; player flag for PC's */
long /*bitvector_t*/ affected_by; /* Bitvector for spells/skills affected by */
sh_int apply_saving_throw[5]; /* Saving throw (Bonuses) */
byte skills[201]; /* array of skills plus skill 0 */
bool talks[3]; /* PC s Tongues 0 for NPC */
wimp integer,
freeze_level int2,
invis_level int2,
load_room unsigned big int,
bad_pws integer NOT NULL DEFAULT 0,
drunk_level int2,
hunger_level int2,
thirst_level int2,
spells_to_learn integer,
strength int2,
strength_add int2,
intelligence int2,
wisdom int2,
dexterity int2,
constitution int2,
charisma int2,
cur_mana integer,
max_mana integer,
cur_hit integer,
max_hit integer,
cur_move integer,
max_move integer,
armour int2,
gold bigint,
bank bigint,
experience bigint,
hitroll int2,
damroll int2,
last_logon datetime,
last_host varchar(100)
);
CREATE TABLE player_preferences (
player_id integer NOT NULL REFERENCES players(id),
preference_id integer NOT NULL REFERENCES preferences(id)
);
CREATE TABLE player_affections (
player_id integer NOT NULL REFERENCES players(id),
affection_id integer NOT NULL REFERENCES affenctions(id)
);

69
old-codebase/src/races.c Normal file
View File

@@ -0,0 +1,69 @@
#include <string.h>
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "interpreter.h"
#include "utils.h"
const char *race_abbrevs[] = {
"Hao",
"Utn",
"Dua",
"\n"
};
const char *pc_race_types[] = {
"Haoon",
"Utnir",
"Duaron",
"\n"
};
const char *race_menu = "\r\n"
"Select race:\r\n"
"( 1) Haoon\r\n"
"( 2) Utnir\r\n"
"( 3) Duaron\r\n";
int
parse_race(char *arg)
{
if (strcmp(arg, "1") == 0)
{
return RACE_HAOON;
}
else if (strcmp(arg, "2") == 0)
{
return RACE_UTNIR;
}
else if (strcmp(arg, "3") == 0)
{
return RACE_DUARON;
}
return RACE_UNDEFINED;
}
long
find_race_bitvector(char arg)
{
arg = LOWER(arg);
switch (arg)
{
case '1':
return (1 << 0);
break;
case '2':
return (1 << 1);
break;
case '3':
return (1 << 2);
break;
default:
return 0;
break;
}
}

91
old-codebase/src/random.c Normal file
View File

@@ -0,0 +1,91 @@
/* ************************************************************************
* File: random.c Part of CircleMUD *
* Usage: pseudo-random number generator *
************************************************************************ */
/*
* I am bothered by the non-portablility of 'rand' and 'random' -- rand
* is ANSI C, but on some systems such as Suns, rand has seriously tragic
* spectral properties (the low bit alternates between 0 and 1!). random
* is better but isn't supported by all systems. So, in my quest for Ultimate
* CircleMUD Portability, I decided to include this code for a simple but
* relatively effective random number generator. It's not the best RNG code
* around, but I like it because it's very short and simple, and for our
* purposes it's "random enough".
* --Jeremy Elson 2/23/95
*
* Now that we're using GNU's autoconf, I've coded Circle to always use
* random(), and automatically link in this object file if random() isn't
* supported on the target system. -JE 2/3/96
*
* Well, despite autoconf we're back to using this random all the
* time. Oh well, there's no harm in changing my mind on this one
* from release to release... -JE 10/28/97
*/
/***************************************************************************/
/*
*
* This program is public domain and was written by William S. England
* (Oct 1988). It is based on an article by:
*
* Stephen K. Park and Keith W. Miller. RANDOM NUMBER GENERATORS:
* GOOD ONES ARE HARD TO FIND. Communications of the ACM,
* New York, NY.,October 1988 p.1192
The following is a portable c program for generating random numbers.
The modulus and multipilier have been extensively tested and should
not be changed except by someone who is a professional Lehmer generator
writer. THIS GENERATOR REPRESENTS THE MINIMUM STANDARD AGAINST WHICH
OTHER GENERATORS SHOULD BE JUDGED. ("Quote from the referenced article's
authors. WSE" )
*/
#define m (unsigned long)2147483647
#define q (unsigned long)127773
#define a (unsigned int)16807
#define r (unsigned int)2836
/*
** F(z) = (az)%m
** = az-m(az/m)
**
** F(z) = G(z)+mT(z)
** G(z) = a(z%q)- r(z/q)
** T(z) = (z/q) - (az/m)
**
** F(z) = a(z%q)- rz/q+ m((z/q) - a(z/m))
** = a(z%q)- rz/q+ m(z/q) - az
*/
static unsigned long seed;
/* local functions */
void circle_srandom(unsigned long initial_seed);
unsigned long circle_random(void);
void circle_srandom(unsigned long initial_seed)
{
seed = initial_seed;
}
unsigned long circle_random(void)
{
int lo, hi, test;
hi = seed/q;
lo = seed%q;
test = a*lo - r*hi;
if (test > 0)
seed = test;
else
seed = test+ m;
return (seed);
}

48
old-codebase/src/screen.h Normal file
View File

@@ -0,0 +1,48 @@
/* ************************************************************************
* File: screen.h Part of CircleMUD *
* Usage: header file with ANSI color codes for online color *
* *
* 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 KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#define KNUL ""
/* conditional color. pass it a pointer to a char_data and a color level. */
#define C_OFF 0
#define C_SPR 1
#define C_NRM 2
#define C_CMP 3
#define _clrlevel(ch) (!IS_NPC(ch) ? (PRF_FLAGGED((ch), PRF_COLOR_1) ? 1 : 0) + \
(PRF_FLAGGED((ch), PRF_COLOR_2) ? 2 : 0) : 0)
#define clr(ch,lvl) (_clrlevel(ch) >= (lvl))
#define CCNRM(ch,lvl) (clr((ch),(lvl))?KNRM:KNUL)
#define CCRED(ch,lvl) (clr((ch),(lvl))?KRED:KNUL)
#define CCGRN(ch,lvl) (clr((ch),(lvl))?KGRN:KNUL)
#define CCYEL(ch,lvl) (clr((ch),(lvl))?KYEL:KNUL)
#define CCBLU(ch,lvl) (clr((ch),(lvl))?KBLU:KNUL)
#define CCMAG(ch,lvl) (clr((ch),(lvl))?KMAG:KNUL)
#define CCCYN(ch,lvl) (clr((ch),(lvl))?KCYN:KNUL)
#define CCWHT(ch,lvl) (clr((ch),(lvl))?KWHT:KNUL)
#define COLOR_LEV(ch) (_clrlevel(ch))
#define QNRM CCNRM(ch,C_SPR)
#define QRED CCRED(ch,C_SPR)
#define QGRN CCGRN(ch,C_SPR)
#define QYEL CCYEL(ch,C_SPR)
#define QBLU CCBLU(ch,C_SPR)
#define QMAG CCMAG(ch,C_SPR)
#define QCYN CCCYN(ch,C_SPR)
#define QWHT CCWHT(ch,C_SPR)

1532
old-codebase/src/shop.c Normal file

File diff suppressed because it is too large Load Diff

146
old-codebase/src/shop.h Normal file
View File

@@ -0,0 +1,146 @@
/* ************************************************************************
* File: shop.h Part of CircleMUD *
* Usage: shop file definitions, structures, constants *
* *
* 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. *
************************************************************************ */
struct shop_buy_data {
int type;
char *keywords;
};
#define BUY_TYPE(i) ((i).type)
#define BUY_WORD(i) ((i).keywords)
struct shop_data {
room_vnum vnum; /* Virtual number of this shop */
obj_vnum *producing; /* Which item to produce (virtual) */
float profit_buy; /* Factor to multiply cost with */
float profit_sell; /* Factor to multiply cost with */
struct shop_buy_data *type; /* Which items to trade */
char *no_such_item1; /* Message if keeper hasn't got an item */
char *no_such_item2; /* Message if player hasn't got an item */
char *missing_cash1; /* Message if keeper hasn't got cash */
char *missing_cash2; /* Message if player hasn't got cash */
char *do_not_buy; /* If keeper dosn't buy such things */
char *message_buy; /* Message when player buys item */
char *message_sell; /* Message when player sells item */
int temper1; /* How does keeper react if no money */
bitvector_t bitvector; /* Can attack? Use bank? Cast here? */
mob_rnum keeper; /* The mobile who owns the shop (rnum) */
int with_who; /* Who does the shop trade with? */
room_vnum *in_room; /* Where is the shop? */
int open1, open2; /* When does the shop open? */
int close1, close2; /* When does the shop close? */
int bankAccount; /* Store all gold over 15000 (disabled) */
int lastsort; /* How many items are sorted in inven? */
SPECIAL (*func); /* Secondary spec_proc for shopkeeper */
};
#define MAX_TRADE 5 /* List maximums for compatibility */
#define MAX_PROD 5 /* with shops before v3.0 */
#define VERSION3_TAG "v3.0" /* The file has v3.0 shops in it! */
#define MAX_SHOP_OBJ 100 /* "Soft" maximum for list maximums */
/* Pretty general macros that could be used elsewhere */
#define IS_GOD(ch) (!IS_NPC(ch) && (GET_LEVEL(ch) >= LVL_GOD))
#define END_OF(buffer) ((buffer) + strlen((buffer)))
/* Possible states for objects trying to be sold */
#define OBJECT_DEAD 0
#define OBJECT_NOTOK 1
#define OBJECT_OK 2
#define OBJECT_NOVAL 3
/* Types of lists to read */
#define LIST_PRODUCE 0
#define LIST_TRADE 1
#define LIST_ROOM 2
/* Whom will we not trade with (bitvector for SHOP_TRADE_WITH()) */
#define TRADE_NOGOOD (1 << 0)
#define TRADE_NOEVIL (1 << 1)
#define TRADE_NONEUTRAL (1 << 2)
#define TRADE_NOMAGIC_USER (1 << 3)
#define TRADE_NOCLERIC (1 << 4)
#define TRADE_NOTHIEF (1 << 5)
#define TRADE_NOWARRIOR (1 << 6)
struct stack_data {
int data[100];
int len;
} ;
#define S_DATA(stack, index) ((stack)->data[(index)])
#define S_LEN(stack) ((stack)->len)
/* Which expression type we are now parsing */
#define OPER_OPEN_PAREN 0
#define OPER_CLOSE_PAREN 1
#define OPER_OR 2
#define OPER_AND 3
#define OPER_NOT 4
#define MAX_OPER 4
#define SHOP_NUM(i) (shop_index[(i)].vnum)
#define SHOP_KEEPER(i) (shop_index[(i)].keeper)
#define SHOP_OPEN1(i) (shop_index[(i)].open1)
#define SHOP_CLOSE1(i) (shop_index[(i)].close1)
#define SHOP_OPEN2(i) (shop_index[(i)].open2)
#define SHOP_CLOSE2(i) (shop_index[(i)].close2)
#define SHOP_ROOM(i, num) (shop_index[(i)].in_room[(num)])
#define SHOP_BUYTYPE(i, num) (BUY_TYPE(shop_index[(i)].type[(num)]))
#define SHOP_BUYWORD(i, num) (BUY_WORD(shop_index[(i)].type[(num)]))
#define SHOP_PRODUCT(i, num) (shop_index[(i)].producing[(num)])
#define SHOP_BANK(i) (shop_index[(i)].bankAccount)
#define SHOP_BROKE_TEMPER(i) (shop_index[(i)].temper1)
#define SHOP_BITVECTOR(i) (shop_index[(i)].bitvector)
#define SHOP_TRADE_WITH(i) (shop_index[(i)].with_who)
#define SHOP_SORT(i) (shop_index[(i)].lastsort)
#define SHOP_BUYPROFIT(i) (shop_index[(i)].profit_buy)
#define SHOP_SELLPROFIT(i) (shop_index[(i)].profit_sell)
#define SHOP_FUNC(i) (shop_index[(i)].func)
#define NOTRADE_GOOD(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOGOOD))
#define NOTRADE_EVIL(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOEVIL))
#define NOTRADE_NEUTRAL(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NONEUTRAL))
#define NOTRADE_MAGIC_USER(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOMAGIC_USER))
#define NOTRADE_CLERIC(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOCLERIC))
#define NOTRADE_THIEF(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOTHIEF))
#define NOTRADE_WARRIOR(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOWARRIOR))
#define WILL_START_FIGHT (1 << 0)
#define WILL_BANK_MONEY (1 << 1)
#define SHOP_KILL_CHARS(i) (IS_SET(SHOP_BITVECTOR(i), WILL_START_FIGHT))
#define SHOP_USES_BANK(i) (IS_SET(SHOP_BITVECTOR(i), WILL_BANK_MONEY))
#define MIN_OUTSIDE_BANK 5000
#define MAX_OUTSIDE_BANK 15000
#define MSG_NOT_OPEN_YET "Come back later!"
#define MSG_NOT_REOPEN_YET "Sorry, we have closed, but come back later."
#define MSG_CLOSED_FOR_DAY "Sorry, come back tomorrow."
#define MSG_NO_STEAL_HERE "$n is a bloody thief!"
#define MSG_NO_SEE_CHAR "I don't trade with someone I can't see!"
#define MSG_NO_SELL_ALIGN "Get out of here before I call the guards!"
#define MSG_NO_SELL_CLASS "We don't serve your kind here!"
#define MSG_NO_USED_WANDSTAFF "I don't buy used up wands or staves!"
#define MSG_CANT_KILL_KEEPER "Get out of here before I call the guards!"

View File

@@ -0,0 +1,307 @@
/* ************************************************************************
* File: spec_assign.c Part of CircleMUD *
* Usage: Functions to assign function pointers to objs/mobs/rooms *
* *
* 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 "db.h"
#include "interpreter.h"
#include "utils.h"
/* external globals */
extern int dts_are_dumps;
extern int mini_mud;
/* external functions */
SPECIAL(dump);
SPECIAL(pet_shops);
SPECIAL(postmaster);
SPECIAL(cityguard);
SPECIAL(receptionist);
SPECIAL(cryogenicist);
SPECIAL(guild_guard);
SPECIAL(guild);
SPECIAL(puff);
SPECIAL(fido);
SPECIAL(janitor);
SPECIAL(mayor);
SPECIAL(snake);
SPECIAL(thief);
SPECIAL(magic_user);
SPECIAL(bank);
SPECIAL(gen_board);
void assign_kings_castle(void);
/* local functions */
void assign_mobiles(void);
void assign_objects(void);
void assign_rooms(void);
void ASSIGNROOM(room_vnum room, SPECIAL(fname));
void ASSIGNMOB(mob_vnum mob, SPECIAL(fname));
void ASSIGNOBJ(obj_vnum obj, SPECIAL(fname));
/* functions to perform assignments */
void ASSIGNMOB(mob_vnum mob, SPECIAL(fname))
{
mob_rnum rnum;
if ((rnum = real_mobile(mob)) != NOBODY)
mob_index[rnum].func = fname;
else if (!mini_mud)
log("SYSERR: Attempt to assign spec to non-existant mob #%d", mob);
}
void ASSIGNOBJ(obj_vnum obj, SPECIAL(fname))
{
obj_rnum rnum;
if ((rnum = real_object(obj)) != NOTHING)
obj_index[rnum].func = fname;
else if (!mini_mud)
log("SYSERR: Attempt to assign spec to non-existant obj #%d", obj);
}
void ASSIGNROOM(room_vnum room, SPECIAL(fname))
{
room_rnum rnum;
if ((rnum = real_room(room)) != NOWHERE)
world[rnum].func = fname;
else if (!mini_mud)
log("SYSERR: Attempt to assign spec to non-existant room #%d", room);
}
/* ********************************************************************
* Assignments *
******************************************************************** */
/* assign special procedures to mobiles */
void assign_mobiles(void)
{
assign_kings_castle();
ASSIGNMOB(1, puff);
/* Immortal Zone */
ASSIGNMOB(1200, receptionist);
ASSIGNMOB(1201, postmaster);
ASSIGNMOB(1202, janitor);
/* Midgaard */
ASSIGNMOB(3005, receptionist);
ASSIGNMOB(3010, postmaster);
ASSIGNMOB(3020, guild);
ASSIGNMOB(3021, guild);
ASSIGNMOB(3022, guild);
ASSIGNMOB(3023, guild);
ASSIGNMOB(3024, guild_guard);
ASSIGNMOB(3025, guild_guard);
ASSIGNMOB(3026, guild_guard);
ASSIGNMOB(3027, guild_guard);
ASSIGNMOB(3059, cityguard);
ASSIGNMOB(3060, cityguard);
ASSIGNMOB(3061, janitor);
ASSIGNMOB(3062, fido);
ASSIGNMOB(3066, fido);
ASSIGNMOB(3067, cityguard);
ASSIGNMOB(3068, janitor);
ASSIGNMOB(3095, cryogenicist);
ASSIGNMOB(3105, mayor);
/* MORIA */
ASSIGNMOB(4000, snake);
ASSIGNMOB(4001, snake);
ASSIGNMOB(4053, snake);
ASSIGNMOB(4100, magic_user);
ASSIGNMOB(4102, snake);
ASSIGNMOB(4103, thief);
/* Redferne's */
ASSIGNMOB(7900, cityguard);
/* PYRAMID */
ASSIGNMOB(5300, snake);
ASSIGNMOB(5301, snake);
ASSIGNMOB(5304, thief);
ASSIGNMOB(5305, thief);
ASSIGNMOB(5309, magic_user); /* should breath fire */
ASSIGNMOB(5311, magic_user);
ASSIGNMOB(5313, magic_user); /* should be a cleric */
ASSIGNMOB(5314, magic_user); /* should be a cleric */
ASSIGNMOB(5315, magic_user); /* should be a cleric */
ASSIGNMOB(5316, magic_user); /* should be a cleric */
ASSIGNMOB(5317, magic_user);
/* High Tower Of Sorcery */
ASSIGNMOB(2501, magic_user); /* should likely be cleric */
ASSIGNMOB(2504, magic_user);
ASSIGNMOB(2507, magic_user);
ASSIGNMOB(2508, magic_user);
ASSIGNMOB(2510, magic_user);
ASSIGNMOB(2511, thief);
ASSIGNMOB(2514, magic_user);
ASSIGNMOB(2515, magic_user);
ASSIGNMOB(2516, magic_user);
ASSIGNMOB(2517, magic_user);
ASSIGNMOB(2518, magic_user);
ASSIGNMOB(2520, magic_user);
ASSIGNMOB(2521, magic_user);
ASSIGNMOB(2522, magic_user);
ASSIGNMOB(2523, magic_user);
ASSIGNMOB(2524, magic_user);
ASSIGNMOB(2525, magic_user);
ASSIGNMOB(2526, magic_user);
ASSIGNMOB(2527, magic_user);
ASSIGNMOB(2528, magic_user);
ASSIGNMOB(2529, magic_user);
ASSIGNMOB(2530, magic_user);
ASSIGNMOB(2531, magic_user);
ASSIGNMOB(2532, magic_user);
ASSIGNMOB(2533, magic_user);
ASSIGNMOB(2534, magic_user);
ASSIGNMOB(2536, magic_user);
ASSIGNMOB(2537, magic_user);
ASSIGNMOB(2538, magic_user);
ASSIGNMOB(2540, magic_user);
ASSIGNMOB(2541, magic_user);
ASSIGNMOB(2548, magic_user);
ASSIGNMOB(2549, magic_user);
ASSIGNMOB(2552, magic_user);
ASSIGNMOB(2553, magic_user);
ASSIGNMOB(2554, magic_user);
ASSIGNMOB(2556, magic_user);
ASSIGNMOB(2557, magic_user);
ASSIGNMOB(2559, magic_user);
ASSIGNMOB(2560, magic_user);
ASSIGNMOB(2562, magic_user);
ASSIGNMOB(2564, magic_user);
/* SEWERS */
ASSIGNMOB(7006, snake);
ASSIGNMOB(7009, magic_user);
ASSIGNMOB(7200, magic_user);
ASSIGNMOB(7201, magic_user);
ASSIGNMOB(7202, magic_user);
/* FOREST */
ASSIGNMOB(6112, magic_user);
ASSIGNMOB(6113, snake);
ASSIGNMOB(6114, magic_user);
ASSIGNMOB(6115, magic_user);
ASSIGNMOB(6116, magic_user); /* should be a cleric */
ASSIGNMOB(6117, magic_user);
/* ARACHNOS */
ASSIGNMOB(6302, magic_user);
ASSIGNMOB(6309, magic_user);
ASSIGNMOB(6312, magic_user);
ASSIGNMOB(6314, magic_user);
ASSIGNMOB(6315, magic_user);
/* Desert */
ASSIGNMOB(5004, magic_user);
ASSIGNMOB(5005, guild_guard); /* brass dragon */
ASSIGNMOB(5010, magic_user);
ASSIGNMOB(5014, magic_user);
/* Drow City */
ASSIGNMOB(5103, magic_user);
ASSIGNMOB(5104, magic_user);
ASSIGNMOB(5107, magic_user);
ASSIGNMOB(5108, magic_user);
/* Old Thalos */
ASSIGNMOB(5200, magic_user);
ASSIGNMOB(5201, magic_user);
ASSIGNMOB(5209, magic_user);
/* New Thalos */
/* 5481 - Cleric (or Mage... but he IS a high priest... *shrug*) */
ASSIGNMOB(5404, receptionist);
ASSIGNMOB(5421, magic_user);
ASSIGNMOB(5422, magic_user);
ASSIGNMOB(5423, magic_user);
ASSIGNMOB(5424, magic_user);
ASSIGNMOB(5425, magic_user);
ASSIGNMOB(5426, magic_user);
ASSIGNMOB(5427, magic_user);
ASSIGNMOB(5428, magic_user);
ASSIGNMOB(5434, cityguard);
ASSIGNMOB(5440, magic_user);
ASSIGNMOB(5455, magic_user);
ASSIGNMOB(5461, cityguard);
ASSIGNMOB(5462, cityguard);
ASSIGNMOB(5463, cityguard);
ASSIGNMOB(5482, cityguard);
/*
5400 - Guildmaster (Mage)
5401 - Guildmaster (Cleric)
5402 - Guildmaster (Warrior)
5403 - Guildmaster (Thief)
5456 - Guildguard (Mage)
5457 - Guildguard (Cleric)
5458 - Guildguard (Warrior)
5459 - Guildguard (Thief)
*/
/* ROME */
ASSIGNMOB(12009, magic_user);
ASSIGNMOB(12018, cityguard);
ASSIGNMOB(12020, magic_user);
ASSIGNMOB(12021, cityguard);
ASSIGNMOB(12025, magic_user);
ASSIGNMOB(12030, magic_user);
ASSIGNMOB(12031, magic_user);
ASSIGNMOB(12032, magic_user);
/* King Welmar's Castle (not covered in castle.c) */
ASSIGNMOB(15015, thief); /* Ergan... have a better idea? */
ASSIGNMOB(15032, magic_user); /* Pit Fiend, have something better? Use it */
/* DWARVEN KINGDOM */
ASSIGNMOB(6500, cityguard);
ASSIGNMOB(6502, magic_user);
ASSIGNMOB(6509, magic_user);
ASSIGNMOB(6516, magic_user);
}
/* assign special procedures to objects */
void assign_objects(void)
{
ASSIGNOBJ(3096, gen_board); /* social board */
ASSIGNOBJ(3097, gen_board); /* freeze board */
ASSIGNOBJ(3098, gen_board); /* immortal board */
ASSIGNOBJ(3099, gen_board); /* mortal board */
ASSIGNOBJ(3034, bank); /* atm */
ASSIGNOBJ(3036, bank); /* cashcard */
}
/* assign special procedures to rooms */
void assign_rooms(void)
{
room_rnum i;
ASSIGNROOM(3030, dump);
ASSIGNROOM(3031, pet_shops);
if (dts_are_dumps)
for (i = 0; i <= top_of_world; i++)
if (ROOM_FLAGGED(i, ROOM_DEATH))
world[i].func = dump;
}

View File

@@ -0,0 +1,755 @@
/* ************************************************************************
* File: spec_procs.c Part of CircleMUD *
* Usage: implementation of special procedures for mobiles/objects/rooms *
* *
* 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 "constants.h"
/* external vars */
extern struct time_info_data time_info;
extern struct spell_info_type spell_info[];
extern struct guild_info_type guild_info[];
/* extern functions */
ACMD(do_drop);
ACMD(do_gen_door);
ACMD(do_say);
ACMD(do_action);
/* local functions */
void sort_spells(void);
int compare_spells(const void *x, const void *y);
const char *how_good(int percent);
void list_skills(struct char_data *ch);
SPECIAL(guild);
SPECIAL(dump);
SPECIAL(mayor);
void npc_steal(struct char_data *ch, struct char_data *victim);
SPECIAL(snake);
SPECIAL(thief);
SPECIAL(magic_user);
SPECIAL(guild_guard);
SPECIAL(puff);
SPECIAL(fido);
SPECIAL(janitor);
SPECIAL(cityguard);
SPECIAL(pet_shops);
SPECIAL(bank);
/* ********************************************************************
* Special procedures for mobiles *
******************************************************************** */
int spell_sort_info[MAX_SKILLS + 1];
int compare_spells(const void *x, const void *y)
{
int a = *(const int *)x,
b = *(const int *)y;
return strcmp(spell_info[a].name, spell_info[b].name);
}
void sort_spells(void)
{
int a;
/* initialize array, avoiding reserved. */
for (a = 1; a <= MAX_SKILLS; a++)
spell_sort_info[a] = a;
qsort(&spell_sort_info[1], MAX_SKILLS, sizeof(int), compare_spells);
}
const char *how_good(int percent)
{
if (percent < 0)
return " error)";
if (percent == 0)
return " (not learned)";
if (percent <= 10)
return " (awful)";
if (percent <= 20)
return " (bad)";
if (percent <= 40)
return " (poor)";
if (percent <= 55)
return " (average)";
if (percent <= 70)
return " (fair)";
if (percent <= 80)
return " (good)";
if (percent <= 85)
return " (very good)";
return " (superb)";
}
const char *prac_types[] = {
"spell",
"skill"
};
#define LEARNED_LEVEL 0 /* % known which is considered "learned" */
#define MAX_PER_PRAC 1 /* max percent gain in skill per practice */
#define MIN_PER_PRAC 2 /* min percent gain in skill per practice */
#define PRAC_TYPE 3 /* should it say 'spell' or 'skill'? */
/* actual prac_params are in class.c */
extern int prac_params[4][NUM_CLASSES];
#define LEARNED(ch) (prac_params[LEARNED_LEVEL][(int)GET_CLASS(ch)])
#define MINGAIN(ch) (prac_params[MIN_PER_PRAC][(int)GET_CLASS(ch)])
#define MAXGAIN(ch) (prac_params[MAX_PER_PRAC][(int)GET_CLASS(ch)])
#define SPLSKL(ch) (prac_types[prac_params[PRAC_TYPE][(int)GET_CLASS(ch)]])
void list_skills(struct char_data *ch)
{
const char *overflow = "\r\n**OVERFLOW**\r\n";
int i, sortpos, nlen;
size_t len = 0;
char buf2[MAX_STRING_LENGTH];
if (!GET_PRACTICES(ch)) {
send_to_char(ch, "You have no practice sessions remaining.\r\n");
return;
}
len = snprintf(buf2, sizeof(buf2), "You have %d practice session%s remaining.\r\n"
"You know of the following %ss:\r\n", GET_PRACTICES(ch),
GET_PRACTICES(ch) == 1 ? "" : "s", SPLSKL(ch));
for (sortpos = 1; sortpos <= MAX_SKILLS; sortpos++) {
i = spell_sort_info[sortpos];
if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) {
nlen = snprintf(buf2 + len, sizeof(buf2) - len, "%-20s %s\r\n", spell_info[i].name, how_good(GET_SKILL(ch, i)));
if (len + nlen >= sizeof(buf2) || nlen < 0)
break;
len += nlen;
}
}
if (len >= sizeof(buf2))
strcpy(buf2 + sizeof(buf2) - strlen(overflow) - 1, overflow); /* strcpy: OK */
page_string(ch->desc, buf2, TRUE);
}
SPECIAL(guild)
{
int skill_num, percent;
if (IS_NPC(ch) || !CMD_IS("practice"))
return (FALSE);
skip_spaces(&argument);
if (!*argument) {
list_skills(ch);
return (TRUE);
}
if (GET_PRACTICES(ch) <= 0) {
send_to_char(ch, "You do not seem to be able to practice now.\r\n");
return (TRUE);
}
skill_num = find_skill_num(argument);
if (skill_num < 1 ||
GET_LEVEL(ch) < spell_info[skill_num].min_level[(int) GET_CLASS(ch)]) {
send_to_char(ch, "You do not know of that %s.\r\n", SPLSKL(ch));
return (TRUE);
}
if (GET_SKILL(ch, skill_num) >= LEARNED(ch)) {
send_to_char(ch, "You are already learned in that area.\r\n");
return (TRUE);
}
send_to_char(ch, "You practice for a while...\r\n");
GET_PRACTICES(ch)--;
percent = GET_SKILL(ch, skill_num);
percent += MIN(MAXGAIN(ch), MAX(MINGAIN(ch), int_app[GET_INT(ch)].learn));
SET_SKILL(ch, skill_num, MIN(LEARNED(ch), percent));
if (GET_SKILL(ch, skill_num) >= LEARNED(ch))
send_to_char(ch, "You are now learned in that area.\r\n");
return (TRUE);
}
SPECIAL(dump)
{
struct obj_data *k;
int value = 0;
for (k = world[IN_ROOM(ch)].contents; k; k = world[IN_ROOM(ch)].contents) {
act("$p vanishes in a puff of smoke!", FALSE, 0, k, 0, TO_ROOM);
extract_obj(k);
}
if (!CMD_IS("drop"))
return (FALSE);
do_drop(ch, argument, cmd, SCMD_DROP);
for (k = world[IN_ROOM(ch)].contents; k; k = world[IN_ROOM(ch)].contents) {
act("$p vanishes in a puff of smoke!", FALSE, 0, k, 0, TO_ROOM);
value += MAX(1, MIN(50, GET_OBJ_COST(k) / 10));
extract_obj(k);
}
if (value) {
send_to_char(ch, "You are awarded for outstanding performance.\r\n");
act("$n has been awarded for being a good citizen.", TRUE, ch, 0, 0, TO_ROOM);
if (GET_LEVEL(ch) < 3)
gain_exp(ch, value);
else
GET_GOLD(ch) += value;
}
return (TRUE);
}
SPECIAL(mayor)
{
char actbuf[MAX_INPUT_LENGTH];
const char open_path[] =
"W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S.";
const char close_path[] =
"W3a3003b33000c111d0d111CE333333CE22c222112212111a1S.";
static const char *path = NULL;
static int path_index;
static bool move = FALSE;
if (!move) {
if (time_info.hours == 6) {
move = TRUE;
path = open_path;
path_index = 0;
} else if (time_info.hours == 20) {
move = TRUE;
path = close_path;
path_index = 0;
}
}
if (cmd || !move || (GET_POS(ch) < POS_SLEEPING) ||
(GET_POS(ch) == POS_FIGHTING))
return (FALSE);
switch (path[path_index]) {
case '0':
case '1':
case '2':
case '3':
perform_move(ch, path[path_index] - '0', 1);
break;
case 'W':
GET_POS(ch) = POS_STANDING;
act("$n awakens and groans loudly.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'S':
GET_POS(ch) = POS_SLEEPING;
act("$n lies down and instantly falls asleep.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'a':
act("$n says 'Hello Honey!'", FALSE, ch, 0, 0, TO_ROOM);
act("$n smirks.", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'b':
act("$n says 'What a view! I must get something done about that dump!'",
FALSE, ch, 0, 0, TO_ROOM);
break;
case 'c':
act("$n says 'Vandals! Youngsters nowadays have no respect for anything!'",
FALSE, ch, 0, 0, TO_ROOM);
break;
case 'd':
act("$n says 'Good day, citizens!'", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'e':
act("$n says 'I hereby declare the bazaar open!'", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'E':
act("$n says 'I hereby declare Midgaard closed!'", FALSE, ch, 0, 0, TO_ROOM);
break;
case 'O':
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_UNLOCK); /* strcpy: OK */
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_OPEN); /* strcpy: OK */
break;
case 'C':
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_CLOSE); /* strcpy: OK */
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_LOCK); /* strcpy: OK */
break;
case '.':
move = FALSE;
break;
}
path_index++;
return (FALSE);
}
/* ********************************************************************
* General special procedures for mobiles *
******************************************************************** */
void npc_steal(struct char_data *ch, struct char_data *victim)
{
int gold;
if (IS_NPC(victim))
return;
if (GET_LEVEL(victim) >= LVL_IMMORT)
return;
if (!CAN_SEE(ch, victim))
return;
if (AWAKE(victim) && (rand_number(0, GET_LEVEL(ch)) == 0)) {
act("You discover that $n has $s hands in your wallet.", FALSE, ch, 0, victim, TO_VICT);
act("$n tries to steal gold from $N.", TRUE, ch, 0, victim, TO_NOTVICT);
} else {
/* Steal some gold coins */
gold = (GET_GOLD(victim) * rand_number(1, 10)) / 100;
if (gold > 0) {
GET_GOLD(ch) += gold;
GET_GOLD(victim) -= gold;
}
}
}
/*
* Quite lethal to low-level characters.
*/
SPECIAL(snake)
{
if (cmd || GET_POS(ch) != POS_FIGHTING || !FIGHTING(ch))
return (FALSE);
if (IN_ROOM(FIGHTING(ch)) != IN_ROOM(ch) || rand_number(0, GET_LEVEL(ch)) != 0)
return (FALSE);
act("$n bites $N!", 1, ch, 0, FIGHTING(ch), TO_NOTVICT);
act("$n bites you!", 1, ch, 0, FIGHTING(ch), TO_VICT);
call_magic(ch, FIGHTING(ch), 0, SPELL_POISON, GET_LEVEL(ch), CAST_SPELL);
return (TRUE);
}
SPECIAL(thief)
{
struct char_data *cons;
if (cmd || GET_POS(ch) != POS_STANDING)
return (FALSE);
for (cons = world[IN_ROOM(ch)].people; cons; cons = cons->next_in_room)
if (!IS_NPC(cons) && GET_LEVEL(cons) < LVL_IMMORT && !rand_number(0, 4)) {
npc_steal(ch, cons);
return (TRUE);
}
return (FALSE);
}
SPECIAL(magic_user)
{
struct char_data *vict;
if (cmd || GET_POS(ch) != POS_FIGHTING)
return (FALSE);
/* pseudo-randomly choose someone in the room who is fighting me */
for (vict = world[IN_ROOM(ch)].people; vict; vict = vict->next_in_room)
if (FIGHTING(vict) == ch && !rand_number(0, 4))
break;
/* if I didn't pick any of those, then just slam the guy I'm fighting */
if (vict == NULL && IN_ROOM(FIGHTING(ch)) == IN_ROOM(ch))
vict = FIGHTING(ch);
/* Hm...didn't pick anyone...I'll wait a round. */
if (vict == NULL)
return (TRUE);
if (GET_LEVEL(ch) > 13 && rand_number(0, 10) == 0)
cast_spell(ch, vict, NULL, SPELL_POISON);
if (GET_LEVEL(ch) > 7 && rand_number(0, 8) == 0)
cast_spell(ch, vict, NULL, SPELL_BLINDNESS);
if (GET_LEVEL(ch) > 12 && rand_number(0, 12) == 0) {
if (IS_EVIL(ch))
cast_spell(ch, vict, NULL, SPELL_ENERGY_DRAIN);
else if (IS_GOOD(ch))
cast_spell(ch, vict, NULL, SPELL_DISPEL_EVIL);
}
if (rand_number(0, 4))
return (TRUE);
switch (GET_LEVEL(ch)) {
case 4:
case 5:
cast_spell(ch, vict, NULL, SPELL_MAGIC_MISSILE);
break;
case 6:
case 7:
cast_spell(ch, vict, NULL, SPELL_CHILL_TOUCH);
break;
case 8:
case 9:
cast_spell(ch, vict, NULL, SPELL_BURNING_HANDS);
break;
case 10:
case 11:
cast_spell(ch, vict, NULL, SPELL_SHOCKING_GRASP);
break;
case 12:
case 13:
cast_spell(ch, vict, NULL, SPELL_LIGHTNING_BOLT);
break;
case 14:
case 15:
case 16:
case 17:
cast_spell(ch, vict, NULL, SPELL_COLOR_SPRAY);
break;
default:
cast_spell(ch, vict, NULL, SPELL_FIREBALL);
break;
}
return (TRUE);
}
/* ********************************************************************
* Special procedures for mobiles *
******************************************************************** */
SPECIAL(guild_guard)
{
int i;
struct char_data *guard = (struct char_data *)me;
const char *buf = "The guard humiliates you, and blocks your way.\r\n";
const char *buf2 = "The guard humiliates $n, and blocks $s way.";
if (!IS_MOVE(cmd) || AFF_FLAGGED(guard, AFF_BLIND))
return (FALSE);
if (GET_LEVEL(ch) >= LVL_IMMORT)
return (FALSE);
for (i = 0; guild_info[i].guild_room != NOWHERE; i++) {
/* Wrong guild or not trying to enter. */
if (GET_ROOM_VNUM(IN_ROOM(ch)) != guild_info[i].guild_room || cmd != guild_info[i].direction)
continue;
/* Allow the people of the guild through. */
if (!IS_NPC(ch) && GET_CLASS(ch) == guild_info[i].pc_class)
continue;
send_to_char(ch, "%s", buf);
act(buf2, FALSE, ch, 0, 0, TO_ROOM);
return (TRUE);
}
return (FALSE);
}
SPECIAL(puff)
{
char actbuf[MAX_INPUT_LENGTH];
if (cmd)
return (FALSE);
switch (rand_number(0, 60)) {
case 0:
do_say(ch, strcpy(actbuf, "My god! It's full of stars!"), 0, 0); /* strcpy: OK */
return (TRUE);
case 1:
do_say(ch, strcpy(actbuf, "How'd all those fish get up here?"), 0, 0); /* strcpy: OK */
return (TRUE);
case 2:
do_say(ch, strcpy(actbuf, "I'm a very female dragon."), 0, 0); /* strcpy: OK */
return (TRUE);
case 3:
do_say(ch, strcpy(actbuf, "I've got a peaceful, easy feeling."), 0, 0); /* strcpy: OK */
return (TRUE);
default:
return (FALSE);
}
}
SPECIAL(fido)
{
struct obj_data *i, *temp, *next_obj;
if (cmd || !AWAKE(ch))
return (FALSE);
for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
if (!IS_CORPSE(i))
continue;
act("$n savagely devours a corpse.", FALSE, ch, 0, 0, TO_ROOM);
for (temp = i->contains; temp; temp = next_obj) {
next_obj = temp->next_content;
obj_from_obj(temp);
obj_to_room(temp, IN_ROOM(ch));
}
extract_obj(i);
return (TRUE);
}
return (FALSE);
}
SPECIAL(janitor)
{
struct obj_data *i;
if (cmd || !AWAKE(ch))
return (FALSE);
for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
if (!CAN_WEAR(i, ITEM_WEAR_TAKE))
continue;
if (GET_OBJ_TYPE(i) != ITEM_DRINKCON && GET_OBJ_COST(i) >= 15)
continue;
act("$n picks up some trash.", FALSE, ch, 0, 0, TO_ROOM);
obj_from_room(i);
obj_to_char(i, ch);
return (TRUE);
}
return (FALSE);
}
SPECIAL(cityguard)
{
struct char_data *tch, *evil, *spittle;
int max_evil, min_cha;
if (cmd || !AWAKE(ch) || FIGHTING(ch))
return (FALSE);
max_evil = 1000;
min_cha = 6;
spittle = evil = NULL;
for (tch = world[IN_ROOM(ch)].people; tch; tch = tch->next_in_room) {
if (!CAN_SEE(ch, tch))
continue;
if (!IS_NPC(tch) && PLR_FLAGGED(tch, PLR_KILLER)) {
act("$n screams 'HEY!!! You're one of those PLAYER KILLERS!!!!!!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, tch, TYPE_UNDEFINED);
return (TRUE);
}
if (!IS_NPC(tch) && PLR_FLAGGED(tch, PLR_THIEF)) {
act("$n screams 'HEY!!! You're one of those PLAYER THIEVES!!!!!!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, tch, TYPE_UNDEFINED);
return (TRUE);
}
if (FIGHTING(tch) && GET_ALIGNMENT(tch) < max_evil && (IS_NPC(tch) || IS_NPC(FIGHTING(tch)))) {
max_evil = GET_ALIGNMENT(tch);
evil = tch;
}
if (GET_CHA(tch) < min_cha) {
spittle = tch;
min_cha = GET_CHA(tch);
}
}
if (evil && GET_ALIGNMENT(FIGHTING(evil)) >= 0) {
act("$n screams 'PROTECT THE INNOCENT! BANZAI! CHARGE! ARARARAGGGHH!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, evil, TYPE_UNDEFINED);
return (TRUE);
}
/* Reward the socially inept. */
if (spittle && !rand_number(0, 9)) {
static int spit_social;
if (!spit_social)
spit_social = find_command("spit");
if (spit_social > 0) {
char spitbuf[MAX_NAME_LENGTH + 1];
strncpy(spitbuf, GET_NAME(spittle), sizeof(spitbuf)); /* strncpy: OK */
spitbuf[sizeof(spitbuf) - 1] = '\0';
do_action(ch, spitbuf, spit_social, 0);
return (TRUE);
}
}
return (FALSE);
}
#define PET_PRICE(pet) (GET_LEVEL(pet) * 300)
SPECIAL(pet_shops)
{
char buf[MAX_STRING_LENGTH], pet_name[256];
room_rnum pet_room;
struct char_data *pet;
/* Gross. */
pet_room = IN_ROOM(ch) + 1;
if (CMD_IS("list")) {
send_to_char(ch, "Available pets are:\r\n");
for (pet = world[pet_room].people; pet; pet = pet->next_in_room) {
/* No, you can't have the Implementor as a pet if he's in there. */
if (!IS_NPC(pet))
continue;
send_to_char(ch, "%8d - %s\r\n", PET_PRICE(pet), GET_NAME(pet));
}
return (TRUE);
} else if (CMD_IS("buy")) {
two_arguments(argument, buf, pet_name);
if (!(pet = get_char_room(buf, NULL, pet_room)) || !IS_NPC(pet)) {
send_to_char(ch, "There is no such pet!\r\n");
return (TRUE);
}
if (GET_GOLD(ch) < PET_PRICE(pet)) {
send_to_char(ch, "You don't have enough gold!\r\n");
return (TRUE);
}
GET_GOLD(ch) -= PET_PRICE(pet);
pet = read_mobile(GET_MOB_RNUM(pet), REAL);
GET_EXP(pet) = 0;
SET_BIT(AFF_FLAGS(pet), AFF_CHARM);
if (*pet_name) {
snprintf(buf, sizeof(buf), "%s %s", pet->player.name, pet_name);
/* free(pet->player.name); don't free the prototype! */
pet->player.name = strdup(buf);
snprintf(buf, sizeof(buf), "%sA small sign on a chain around the neck says 'My name is %s'\r\n",
pet->player.description, pet_name);
/* free(pet->player.description); don't free the prototype! */
pet->player.description = strdup(buf);
}
char_to_room(pet, IN_ROOM(ch));
add_follower(pet, ch);
/* Be certain that pets can't get/carry/use/wield/wear items */
IS_CARRYING_W(pet) = 1000;
IS_CARRYING_N(pet) = 100;
send_to_char(ch, "May you enjoy your pet.\r\n");
act("$n buys $N as a pet.", FALSE, ch, 0, pet, TO_ROOM);
return (TRUE);
}
/* All commands except list and buy */
return (FALSE);
}
/* ********************************************************************
* Special procedures for objects *
******************************************************************** */
SPECIAL(bank)
{
int amount;
if (CMD_IS("balance")) {
if (GET_BANK_GOLD(ch) > 0)
send_to_char(ch, "Your current balance is %d coins.\r\n", GET_BANK_GOLD(ch));
else
send_to_char(ch, "You currently have no money deposited.\r\n");
return (TRUE);
} else if (CMD_IS("deposit")) {
if ((amount = atoi(argument)) <= 0) {
send_to_char(ch, "How much do you want to deposit?\r\n");
return (TRUE);
}
if (GET_GOLD(ch) < amount) {
send_to_char(ch, "You don't have that many coins!\r\n");
return (TRUE);
}
GET_GOLD(ch) -= amount;
GET_BANK_GOLD(ch) += amount;
send_to_char(ch, "You deposit %d coins.\r\n", amount);
act("$n makes a bank transaction.", TRUE, ch, 0, FALSE, TO_ROOM);
return (TRUE);
} else if (CMD_IS("withdraw")) {
if ((amount = atoi(argument)) <= 0) {
send_to_char(ch, "How much do you want to withdraw?\r\n");
return (TRUE);
}
if (GET_BANK_GOLD(ch) < amount) {
send_to_char(ch, "You don't have that many coins deposited!\r\n");
return (TRUE);
}
GET_GOLD(ch) += amount;
GET_BANK_GOLD(ch) -= amount;
send_to_char(ch, "You withdraw %d coins.\r\n", amount);
act("$n makes a bank transaction.", TRUE, ch, 0, FALSE, TO_ROOM);
return (TRUE);
} else
return (FALSE);
}

File diff suppressed because it is too large Load Diff

406
old-codebase/src/spells.c Normal file
View File

@@ -0,0 +1,406 @@
/* ************************************************************************
* File: spells.c Part of CircleMUD *
* Usage: Implementation of "manual spells". Circle 2.2 spell compat. *
* *
* 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 "constants.h"
#include "interpreter.h"
/* external variables */
extern room_rnum r_mortal_start_room;
extern int mini_mud;
extern int pk_allowed;
/* external functions */
void clearMemory(struct char_data *ch);
void weight_change_object(struct obj_data *obj, int weight);
int mag_savingthrow(struct char_data *ch, int type, int modifier);
void name_to_drinkcon(struct obj_data *obj, int type);
void name_from_drinkcon(struct obj_data *obj);
int compute_armor_class(struct char_data *ch);
/*
* Special spells appear below.
*/
ASPELL(spell_create_water)
{
int water;
if (ch == NULL || obj == NULL)
return;
/* level = MAX(MIN(level, LVL_IMPL), 1); - not used */
if (GET_OBJ_TYPE(obj) == ITEM_DRINKCON) {
if ((GET_OBJ_VAL(obj, 2) != LIQ_WATER) && (GET_OBJ_VAL(obj, 1) != 0)) {
name_from_drinkcon(obj);
GET_OBJ_VAL(obj, 2) = LIQ_SLIME;
name_to_drinkcon(obj, LIQ_SLIME);
} else {
water = MAX(GET_OBJ_VAL(obj, 0) - GET_OBJ_VAL(obj, 1), 0);
if (water > 0) {
if (GET_OBJ_VAL(obj, 1) >= 0)
name_from_drinkcon(obj);
GET_OBJ_VAL(obj, 2) = LIQ_WATER;
GET_OBJ_VAL(obj, 1) += water;
name_to_drinkcon(obj, LIQ_WATER);
weight_change_object(obj, water);
act("$p is filled.", FALSE, ch, obj, 0, TO_CHAR);
}
}
}
}
ASPELL(spell_recall)
{
if (victim == NULL || IS_NPC(victim))
return;
act("$n disappears.", TRUE, victim, 0, 0, TO_ROOM);
char_from_room(victim);
char_to_room(victim, r_mortal_start_room);
act("$n appears in the middle of the room.", TRUE, victim, 0, 0, TO_ROOM);
look_at_room(victim, 0);
}
ASPELL(spell_teleport)
{
room_rnum to_room;
if (victim == NULL || IS_NPC(victim))
return;
do {
to_room = rand_number(0, top_of_world);
} while (ROOM_FLAGGED(to_room, ROOM_PRIVATE | ROOM_DEATH | ROOM_GODROOM));
act("$n slowly fades out of existence and is gone.",
FALSE, victim, 0, 0, TO_ROOM);
char_from_room(victim);
char_to_room(victim, to_room);
act("$n slowly fades into existence.", FALSE, victim, 0, 0, TO_ROOM);
look_at_room(victim, 0);
}
#define SUMMON_FAIL "You failed.\r\n"
ASPELL(spell_summon)
{
if (ch == NULL || victim == NULL)
return;
if (GET_LEVEL(victim) > MIN(LVL_IMMORT - 1, level + 3)) {
send_to_char(ch, "%s", SUMMON_FAIL);
return;
}
if (!pk_allowed) {
if (MOB_FLAGGED(victim, MOB_AGGRESSIVE)) {
act("As the words escape your lips and $N travels\r\n"
"through time and space towards you, you realize that $E is\r\n"
"aggressive and might harm you, so you wisely send $M back.",
FALSE, ch, 0, victim, TO_CHAR);
return;
}
if (!IS_NPC(victim) && !PRF_FLAGGED(victim, PRF_SUMMONABLE) &&
!PLR_FLAGGED(victim, PLR_KILLER)) {
send_to_char(victim, "%s just tried to summon you to: %s.\r\n"
"%s failed because you have summon protection on.\r\n"
"Type NOSUMMON to allow other players to summon you.\r\n",
GET_NAME(ch), world[IN_ROOM(ch)].name,
(ch->player.sex == SEX_MALE) ? "He" : "She");
send_to_char(ch, "You failed because %s has summon protection on.\r\n", GET_NAME(victim));
mudlog(BRF, LVL_IMMORT, TRUE, "%s failed summoning %s to %s.", GET_NAME(ch), GET_NAME(victim), world[IN_ROOM(ch)].name);
return;
}
}
if (MOB_FLAGGED(victim, MOB_NOSUMMON) ||
(IS_NPC(victim) && mag_savingthrow(victim, SAVING_SPELL, 0))) {
send_to_char(ch, "%s", SUMMON_FAIL);
return;
}
act("$n disappears suddenly.", TRUE, victim, 0, 0, TO_ROOM);
char_from_room(victim);
char_to_room(victim, IN_ROOM(ch));
act("$n arrives suddenly.", TRUE, victim, 0, 0, TO_ROOM);
act("$n has summoned you!", FALSE, ch, 0, victim, TO_VICT);
look_at_room(victim, 0);
}
ASPELL(spell_locate_object)
{
struct obj_data *i;
char name[MAX_INPUT_LENGTH];
int j;
/*
* FIXME: This is broken. The spell parser routines took the argument
* the player gave to the spell and located an object with that keyword.
* Since we're passed the object and not the keyword we can only guess
* at what the player originally meant to search for. -gg
*/
strlcpy(name, fname(obj->name), sizeof(name));
j = level / 2;
for (i = object_list; i && (j > 0); i = i->next) {
if (!isname(name, i->name))
continue;
send_to_char(ch, "%c%s", UPPER(*i->short_description), i->short_description+1);
if (i->carried_by)
send_to_char(ch, " is being carried by %s.\r\n", PERS(i->carried_by, ch));
else if (IN_ROOM(i) != NOWHERE)
send_to_char(ch, " is in %s.\r\n", world[IN_ROOM(i)].name);
else if (i->in_obj)
send_to_char(ch, " is in %s.\r\n", i->in_obj->short_description);
else if (i->worn_by)
send_to_char(ch, " is being worn by %s.\r\n", PERS(i->worn_by, ch));
else
send_to_char(ch, "'s location is uncertain.\r\n");
j--;
}
if (j == level / 2)
send_to_char(ch, "You sense nothing.\r\n");
}
ASPELL(spell_charm)
{
struct affected_type af;
if (victim == NULL || ch == NULL)
return;
if (victim == ch)
send_to_char(ch, "You like yourself even better!\r\n");
else if (!IS_NPC(victim) && !PRF_FLAGGED(victim, PRF_SUMMONABLE))
send_to_char(ch, "You fail because SUMMON protection is on!\r\n");
else if (AFF_FLAGGED(victim, AFF_SANCTUARY))
send_to_char(ch, "Your victim is protected by sanctuary!\r\n");
else if (MOB_FLAGGED(victim, MOB_NOCHARM))
send_to_char(ch, "Your victim resists!\r\n");
else if (AFF_FLAGGED(ch, AFF_CHARM))
send_to_char(ch, "You can't have any followers of your own!\r\n");
else if (AFF_FLAGGED(victim, AFF_CHARM) || level < GET_LEVEL(victim))
send_to_char(ch, "You fail.\r\n");
/* player charming another player - no legal reason for this */
else if (!pk_allowed && !IS_NPC(victim))
send_to_char(ch, "You fail - shouldn't be doing it anyway.\r\n");
else if (circle_follow(victim, ch))
send_to_char(ch, "Sorry, following in circles can not be allowed.\r\n");
else if (mag_savingthrow(victim, SAVING_PARA, 0))
send_to_char(ch, "Your victim resists!\r\n");
else {
if (victim->master)
stop_follower(victim);
add_follower(victim, ch);
af.type = SPELL_CHARM;
af.duration = 24 * 2;
if (GET_CHA(ch))
af.duration *= GET_CHA(ch);
if (GET_INT(victim))
af.duration /= GET_INT(victim);
af.modifier = 0;
af.location = 0;
af.bitvector = AFF_CHARM;
affect_to_char(victim, &af);
act("Isn't $n just such a nice fellow?", FALSE, ch, 0, victim, TO_VICT);
if (IS_NPC(victim))
REMOVE_BIT(MOB_FLAGS(victim), MOB_SPEC);
}
}
ASPELL(spell_identify)
{
int i, found;
size_t len;
if (obj) {
char bitbuf[MAX_STRING_LENGTH];
sprinttype(GET_OBJ_TYPE(obj), item_types, bitbuf, sizeof(bitbuf));
send_to_char(ch, "You feel informed:\r\nObject '%s', Item type: %s\r\n", obj->short_description, bitbuf);
if (GET_OBJ_AFFECT(obj)) {
sprintbit(GET_OBJ_AFFECT(obj), affected_bits, bitbuf, sizeof(bitbuf));
send_to_char(ch, "Item will give you following abilities: %s\r\n", bitbuf);
}
sprintbit(GET_OBJ_EXTRA(obj), extra_bits, bitbuf, sizeof(bitbuf));
send_to_char(ch, "Item is: %s\r\n", bitbuf);
send_to_char(ch, "Weight: %d, Value: %d, Rent: %d\r\n", GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj));
switch (GET_OBJ_TYPE(obj)) {
case ITEM_SCROLL:
case ITEM_POTION:
len = i = 0;
if (GET_OBJ_VAL(obj, 1) >= 1) {
i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 1)));
if (i >= 0)
len += i;
}
if (GET_OBJ_VAL(obj, 2) >= 1 && len < sizeof(bitbuf)) {
i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 2)));
if (i >= 0)
len += i;
}
if (GET_OBJ_VAL(obj, 3) >= 1 && len < sizeof(bitbuf)) {
i = snprintf(bitbuf + len, sizeof(bitbuf) - len, " %s", skill_name(GET_OBJ_VAL(obj, 3)));
if (i >= 0)
len += i;
}
send_to_char(ch, "This %s casts: %s\r\n", item_types[(int) GET_OBJ_TYPE(obj)], bitbuf);
break;
case ITEM_WAND:
case ITEM_STAFF:
send_to_char(ch, "This %s casts: %s\r\nIt has %d maximum charge%s and %d remaining.\r\n",
item_types[(int) GET_OBJ_TYPE(obj)], skill_name(GET_OBJ_VAL(obj, 3)),
GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 1) == 1 ? "" : "s", GET_OBJ_VAL(obj, 2));
break;
case ITEM_WEAPON:
send_to_char(ch, "Damage Dice is '%dD%d' for an average per-round damage of %.1f.\r\n",
GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 2), ((GET_OBJ_VAL(obj, 2) + 1) / 2.0) * GET_OBJ_VAL(obj, 1));
break;
case ITEM_ARMOR:
send_to_char(ch, "AC-apply is %d\r\n", GET_OBJ_VAL(obj, 0));
break;
}
found = FALSE;
for (i = 0; i < MAX_OBJ_AFFECT; i++) {
if ((obj->affected[i].location != APPLY_NONE) &&
(obj->affected[i].modifier != 0)) {
if (!found) {
send_to_char(ch, "Can affect you as :\r\n");
found = TRUE;
}
sprinttype(obj->affected[i].location, apply_types, bitbuf, sizeof(bitbuf));
send_to_char(ch, " Affects: %s By %d\r\n", bitbuf, obj->affected[i].modifier);
}
}
} else if (victim) { /* victim */
send_to_char(ch, "Name: %s\r\n", GET_NAME(victim));
if (!IS_NPC(victim))
send_to_char(ch, "%s is %d years, %d months, %d days and %d hours old.\r\n",
GET_NAME(victim), age(victim)->year, age(victim)->month,
age(victim)->day, age(victim)->hours);
send_to_char(ch, "Height %d cm, Weight %d pounds\r\n", GET_HEIGHT(victim), GET_WEIGHT(victim));
send_to_char(ch, "Level: %d, Hits: %d, Mana: %d\r\n", GET_LEVEL(victim), GET_HIT(victim), GET_MANA(victim));
send_to_char(ch, "AC: %d, Hitroll: %d, Damroll: %d\r\n", compute_armor_class(victim), GET_HITROLL(victim), GET_DAMROLL(victim));
send_to_char(ch, "Str: %d/%d, Int: %d, Wis: %d, Dex: %d, Con: %d, Cha: %d\r\n",
GET_STR(victim), GET_ADD(victim), GET_INT(victim),
GET_WIS(victim), GET_DEX(victim), GET_CON(victim), GET_CHA(victim));
}
}
/*
* Cannot use this spell on an equipped object or it will mess up the
* wielding character's hit/dam totals.
*/
ASPELL(spell_enchant_weapon)
{
int i;
if (ch == NULL || obj == NULL)
return;
/* Either already enchanted or not a weapon. */
if (GET_OBJ_TYPE(obj) != ITEM_WEAPON || OBJ_FLAGGED(obj, ITEM_MAGIC))
return;
/* Make sure no other affections. */
for (i = 0; i < MAX_OBJ_AFFECT; i++)
if (obj->affected[i].location != APPLY_NONE)
return;
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_MAGIC);
obj->affected[0].location = APPLY_HITROLL;
obj->affected[0].modifier = 1 + (level >= 18);
obj->affected[1].location = APPLY_DAMROLL;
obj->affected[1].modifier = 1 + (level >= 20);
if (IS_GOOD(ch)) {
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_EVIL);
act("$p glows blue.", FALSE, ch, obj, 0, TO_CHAR);
} else if (IS_EVIL(ch)) {
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_ANTI_GOOD);
act("$p glows red.", FALSE, ch, obj, 0, TO_CHAR);
} else
act("$p glows yellow.", FALSE, ch, obj, 0, TO_CHAR);
}
ASPELL(spell_detect_poison)
{
if (victim) {
if (victim == ch) {
if (AFF_FLAGGED(victim, AFF_POISON))
send_to_char(ch, "You can sense poison in your blood.\r\n");
else
send_to_char(ch, "You feel healthy.\r\n");
} else {
if (AFF_FLAGGED(victim, AFF_POISON))
act("You sense that $E is poisoned.", FALSE, ch, 0, victim, TO_CHAR);
else
act("You sense that $E is healthy.", FALSE, ch, 0, victim, TO_CHAR);
}
}
if (obj) {
switch (GET_OBJ_TYPE(obj)) {
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
case ITEM_FOOD:
if (GET_OBJ_VAL(obj, 3))
act("You sense that $p has been contaminated.",FALSE,ch,obj,0,TO_CHAR);
else
act("You sense that $p is safe for consumption.", FALSE, ch, obj, 0,
TO_CHAR);
break;
default:
send_to_char(ch, "You sense that it should not be consumed.\r\n");
}
}
}

272
old-codebase/src/spells.h Normal file
View File

@@ -0,0 +1,272 @@
/* ************************************************************************
* File: spells.h Part of CircleMUD *
* Usage: header file: constants and fn prototypes for spell 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. *
************************************************************************ */
#define DEFAULT_STAFF_LVL 12
#define DEFAULT_WAND_LVL 12
#define CAST_UNDEFINED (-1)
#define CAST_SPELL 0
#define CAST_POTION 1
#define CAST_WAND 2
#define CAST_STAFF 3
#define CAST_SCROLL 4
#define MAG_DAMAGE (1 << 0)
#define MAG_AFFECTS (1 << 1)
#define MAG_UNAFFECTS (1 << 2)
#define MAG_POINTS (1 << 3)
#define MAG_ALTER_OBJS (1 << 4)
#define MAG_GROUPS (1 << 5)
#define MAG_MASSES (1 << 6)
#define MAG_AREAS (1 << 7)
#define MAG_SUMMONS (1 << 8)
#define MAG_CREATIONS (1 << 9)
#define MAG_MANUAL (1 << 10)
#define TYPE_UNDEFINED (-1)
#define SPELL_RESERVED_DBC 0 /* SKILL NUMBER ZERO -- RESERVED */
/* PLAYER SPELLS -- Numbered from 1 to MAX_SPELLS */
#define SPELL_ARMOR 1 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_TELEPORT 2 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_BLESS 3 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_BLINDNESS 4 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_BURNING_HANDS 5 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CALL_LIGHTNING 6 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CHARM 7 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CHILL_TOUCH 8 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CLONE 9 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_COLOR_SPRAY 10 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CONTROL_WEATHER 11 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CREATE_FOOD 12 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CREATE_WATER 13 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CURE_BLIND 14 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CURE_CRITIC 15 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CURE_LIGHT 16 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_CURSE 17 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DETECT_ALIGN 18 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DETECT_INVIS 19 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DETECT_MAGIC 20 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DETECT_POISON 21 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DISPEL_EVIL 22 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_EARTHQUAKE 23 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_ENCHANT_WEAPON 24 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_ENERGY_DRAIN 25 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_FIREBALL 26 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_HARM 27 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_HEAL 28 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_INVISIBLE 29 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_LIGHTNING_BOLT 30 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_LOCATE_OBJECT 31 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_MAGIC_MISSILE 32 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_POISON 33 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_PROT_FROM_EVIL 34 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_REMOVE_CURSE 35 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_SANCTUARY 36 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_SHOCKING_GRASP 37 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_SLEEP 38 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_STRENGTH 39 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_SUMMON 40 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_VENTRILOQUATE 41 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_WORD_OF_RECALL 42 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_REMOVE_POISON 43 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_SENSE_LIFE 44 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_ANIMATE_DEAD 45 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_DISPEL_GOOD 46 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_GROUP_ARMOR 47 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_GROUP_HEAL 48 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_GROUP_RECALL 49 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_INFRAVISION 50 /* Reserved Skill[] DO NOT CHANGE */
#define SPELL_WATERWALK 51 /* Reserved Skill[] DO NOT CHANGE */
/* Insert new spells here, up to MAX_SPELLS */
#define MAX_SPELLS 130
/* PLAYER SKILLS - Numbered from MAX_SPELLS+1 to MAX_SKILLS */
#define SKILL_BACKSTAB 131 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_BASH 132 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_HIDE 133 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_KICK 134 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_PICK_LOCK 135 /* Reserved Skill[] DO NOT CHANGE */
/* Undefined 136 */
#define SKILL_RESCUE 137 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_SNEAK 138 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_STEAL 139 /* Reserved Skill[] DO NOT CHANGE */
#define SKILL_TRACK 140 /* Reserved Skill[] DO NOT CHANGE */
/* New skills may be added here up to MAX_SKILLS (200) */
/*
* NON-PLAYER AND OBJECT SPELLS AND SKILLS
* The practice levels for the spells and skills below are _not_ recorded
* in the playerfile; therefore, the intended use is for spells and skills
* associated with objects (such as SPELL_IDENTIFY used with scrolls of
* identify) or non-players (such as NPC-only spells).
*/
#define SPELL_IDENTIFY 201
#define SPELL_FIRE_BREATH 202
#define SPELL_GAS_BREATH 203
#define SPELL_FROST_BREATH 204
#define SPELL_ACID_BREATH 205
#define SPELL_LIGHTNING_BREATH 206
#define TOP_SPELL_DEFINE 299
/* NEW NPC/OBJECT SPELLS can be inserted here up to 299 */
/* WEAPON ATTACK TYPES */
#define TYPE_HIT 300
#define TYPE_STING 301
#define TYPE_WHIP 302
#define TYPE_SLASH 303
#define TYPE_BITE 304
#define TYPE_BLUDGEON 305
#define TYPE_CRUSH 306
#define TYPE_POUND 307
#define TYPE_CLAW 308
#define TYPE_MAUL 309
#define TYPE_THRASH 310
#define TYPE_PIERCE 311
#define TYPE_BLAST 312
#define TYPE_PUNCH 313
#define TYPE_STAB 314
/* new attack types can be added here - up to TYPE_SUFFERING */
#define TYPE_SUFFERING 399
#define SAVING_PARA 0
#define SAVING_ROD 1
#define SAVING_PETRI 2
#define SAVING_BREATH 3
#define SAVING_SPELL 4
#define TAR_IGNORE (1 << 0)
#define TAR_CHAR_ROOM (1 << 1)
#define TAR_CHAR_WORLD (1 << 2)
#define TAR_FIGHT_SELF (1 << 3)
#define TAR_FIGHT_VICT (1 << 4)
#define TAR_SELF_ONLY (1 << 5) /* Only a check, use with i.e. TAR_CHAR_ROOM */
#define TAR_NOT_SELF (1 << 6) /* Only a check, use with i.e. TAR_CHAR_ROOM */
#define TAR_OBJ_INV (1 << 7)
#define TAR_OBJ_ROOM (1 << 8)
#define TAR_OBJ_WORLD (1 << 9)
#define TAR_OBJ_EQUIP (1 << 10)
struct spell_info_type {
byte min_position; /* Position for caster */
int mana_min; /* Min amount of mana used by a spell (highest lev) */
int mana_max; /* Max amount of mana used by a spell (lowest lev) */
int mana_change; /* Change in mana used by spell from lev to lev */
int min_level[NUM_CLASSES];
int routines;
byte violent;
int targets; /* See below for use with TAR_XXX */
const char *name; /* Input size not limited. Originates from string constants. */
const char *wear_off_msg; /* Input size not limited. Originates from string constants. */
};
/* Possible Targets:
bit 0 : IGNORE TARGET
bit 1 : PC/NPC in room
bit 2 : PC/NPC in world
bit 3 : Object held
bit 4 : Object in inventory
bit 5 : Object in room
bit 6 : Object in world
bit 7 : If fighting, and no argument, select tar_char as self
bit 8 : If fighting, and no argument, select tar_char as victim (fighting)
bit 9 : If no argument, select self, if argument check that it IS self.
*/
#define SPELL_TYPE_SPELL 0
#define SPELL_TYPE_POTION 1
#define SPELL_TYPE_WAND 2
#define SPELL_TYPE_STAFF 3
#define SPELL_TYPE_SCROLL 4
/* Attacktypes with grammar */
struct attack_hit_type {
const char *singular;
const char *plural;
};
#define ASPELL(spellname) \
void spellname(int level, struct char_data *ch, \
struct char_data *victim, struct obj_data *obj)
#define MANUAL_SPELL(spellname) spellname(level, caster, cvict, ovict);
ASPELL(spell_create_water);
ASPELL(spell_recall);
ASPELL(spell_teleport);
ASPELL(spell_summon);
ASPELL(spell_locate_object);
ASPELL(spell_charm);
ASPELL(spell_information);
ASPELL(spell_identify);
ASPELL(spell_enchant_weapon);
ASPELL(spell_detect_poison);
/* basic magic calling functions */
int find_skill_num(char *name);
int mag_damage(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype);
void mag_affects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype);
void mag_groups(int level, struct char_data *ch, int spellnum, int savetype);
void mag_masses(int level, struct char_data *ch, int spellnum, int savetype);
void mag_areas(int level, struct char_data *ch, int spellnum, int savetype);
void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int savetype);
void mag_points(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int savetype);
void mag_unaffects(int level, struct char_data *ch, struct char_data *victim,
int spellnum, int type);
void mag_alter_objs(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int type);
void mag_creations(int level, struct char_data *ch, int spellnum);
int call_magic(struct char_data *caster, struct char_data *cvict,
struct obj_data *ovict, int spellnum, int level, int casttype);
void mag_objectmagic(struct char_data *ch, struct obj_data *obj,
char *argument);
int cast_spell(struct char_data *ch, struct char_data *tch,
struct obj_data *tobj, int spellnum);
/* other prototypes */
void spell_level(int spell, int chclass, int level);
void init_spell_levels(void);
const char *skill_name(int num);

1121
old-codebase/src/structs.h Normal file

File diff suppressed because it is too large Load Diff

694
old-codebase/src/sysdep.h Normal file
View File

@@ -0,0 +1,694 @@
/* ************************************************************************
* File: sysdep.h Part of CircleMUD *
* Usage: machine-specific defs based on values in conf.h (from configure)*
* *
* 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. *
************************************************************************ */
/* Configurables: */
/*
* CircleMUD uses the crypt(3) function to encrypt player passwords in the
* playerfile so that they are never stored in plaintext form. However,
* due to U.S. export restrictions on machine-readable cryptographic
* software, the crypt() function is not available on some operating
* systems such as FreeBSD. By default, the 'configure' script will
* determine if you have crypt() available and enable or disable password
* encryption appropriately. #define NOCRYPT (by uncommenting the line
* below) if you'd like to explicitly disable password encryption (i.e.,
* if you have moved your MUD from an OS that does not support encryption
* to one that does.)
*
* See running.doc for details.
*/
/* #define NOCRYPT */
/**************************************************************************/
/*
* If you are porting CircleMUD to a new (untested) platform and you find
* that POSIX-standard non-blocking I/O does *not* work, you can define
* the constant below to have Circle work around the problem. Not having
* non-blocking I/O can cause the MUD to freeze if someone types part of
* a command while the MUD waits for the remainder of the command.
*
* NOTE: **DO** **NOT** use this constant unless you are SURE you understand
* exactly what non-blocking I/O is, and you are SURE that your operating
* system does NOT have it! (The only UNIX system I've ever seen that has
* broken POSIX non-blocking I/O is AIX 3.2.) If your MUD is freezing but
* you're not sure why, do NOT use this constant. Use this constant ONLY
* if you're sure that your MUD is freezing because of a non-blocking I/O
* problem.
*
* See running.doc for details.
*/
/* #define POSIX_NONBLOCK_BROKEN */
/**************************************************************************/
/*
* The Circle code prototypes library functions to avoid compiler warnings.
* (Operating system header files *should* do this, but sometimes don't.)
* However, Circle's prototypes cause the compilation to fail under some
* combinations of operating systems and compilers.
*
* If your compiler reports "conflicting types" for functions, you need to
* define this constant to turn off library function prototyping. Note,
* **DO** **NOT** blindly turn on this constant unless you're sure the
* problem is type conflicts between my header files and the header files
* of your operating system. The error message will look something like
* this:
*
* In file included from comm.c:14:
* sysdep.h:207: conflicting types for `random'
* /usr/local/lib/gcc-lib/alpha-dec-osf3.2/2.7.2/include/stdlib.h:253:
* previous declaration of `random'
*
* See running.doc for details.
*/
/* #define NO_LIBRARY_PROTOTYPES */
/**************************************************************************/
/*
* If using the GNU C library, version 2+, then you can have it trace
* memory allocations to check for leaks, uninitialized uses, and bogus
* free() calls. To see if your version supports it, run:
*
* info libc 'Allocation Debugging' 'Tracing malloc'
*
* Example usage (Bourne shell):
*
* MALLOC_TRACE=/tmp/circle-trace bin/circle
*
* After it finishes:
*
* mtrace bin/circle /tmp/circle-trace
*
* (Stock CircleMUD produces a file approximately 1.5 megabytes in size
* just running in Syntax Check mode.)
*
* NOTE: The GNU C library version 2.1.3 leaks a tiny bit of memory
* by itself. You will see something similar to:
*
* - 0000000000 Free 36910 was never alloc'd /lib/libcrypt.so.1:(fcrypt+0x883)[0x4001b9ef]
*
* Memory not freed:
* -----------------
* Address Size Caller
* 0x080ca830 0xf at /lib/libc.so.6:(__strdup+0x29)[0x400a6a09]
* 0x080ca848 0xc at /lib/libc.so.6:(adjtime+0x25c)[0x400d127c]
* 0x080ca858 0xc at /lib/libc.so.6:(adjtime+0x25c)[0x400d127c]
* 0x080ca868 0xc at /lib/libc.so.6:(adjtime+0x25c)[0x400d127c]
*
* But with GNU C library version 2.2.4:
*
* No memory leaks.
*
* Read the entire "Allocation Debugging" section of the GNU C library
* documentation before setting this to '1'.
*/
#define CIRCLE_GNU_LIBC_MEMORY_TRACK 0 /* 0 = off, 1 = on */
/************************************************************************/
/*** Do not change anything below this line *****************************/
/************************************************************************/
/*
* Set up various machine-specific things based on the values determined
* from configure and conf.h.
*/
/* Standard C headers *************************************************/
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
#include <stdlib.h>
#else /* No standard headers. */
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
extern char *malloc(), *calloc(), *realloc();
extern void free ();
extern void abort (), exit ();
#endif /* Standard headers. */
/* POSIX compliance *************************************************/
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef CIRCLE_WINDOWS
# include <sys\types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Now, we #define POSIX if we have a POSIX system. */
#ifdef HAVE_UNISTD_H
/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
#if defined (_POSIX_VERSION) && !defined (ultrix)
#define POSIX
#endif
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
#if (defined (butterfly) || defined (__arm) || \
(defined (__mips) && defined (_SYSTYPE_SVR3)) || \
(defined (sequent) && defined (i386)))
#undef POSIX
#endif
#endif /* HAVE_UNISTD_H */
#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
#define POSIX
#endif
#if defined(_AIX)
#define POSIX_NONBLOCK_BROKEN
#endif
/* Header files *******************************************************/
/* Header files common to all source files */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_NET_ERRNO_H
#include <net/errno.h>
#endif
/* Macintosh */
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_ASSERT_H
#include <assert.h>
#else
#define assert(arg)
#endif
/* Header files only used in comm.c and some of the utils */
#if defined(__COMM_C__) || defined(CIRCLE_UTIL)
#ifndef HAVE_STRUCT_IN_ADDR
struct in_addr {
unsigned long int s_addr; /* for inet_addr, etc. */
}
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_SIGNAL_H
# ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 2
# include <signal.h>
# undef _POSIX_C_SOURCE
# else
# include <signal.h> /* GNU libc 6 already defines _POSIX_C_SOURCE. */
# endif
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#endif /* __COMM_C__ && CIRCLE_UNIX */
/* Header files that are only used in act.other.c */
#ifdef __ACT_OTHER_C__
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#endif /* __ACT_OTHER_C__ */
/* Basic system dependencies *******************************************/
#if CIRCLE_GNU_LIBC_MEMORY_TRACK && !defined(HAVE_MCHECK_H)
#error "Cannot use GNU C library memory tracking without <mcheck.h>"
#endif
/* strcasecmp -> stricmp -> str_cmp */
#if defined(HAVE_STRCASECMP)
# define str_cmp strcasecmp
#elif defined(HAVE_STRICMP)
# define str_cmp stricmp
#endif
/* strncasecmp -> strnicmp -> strn_cmp */
#if defined(HAVE_STRNCASECMP)
# define strn_cmp strncasecmp
#elif defined(HAVE_STRNICMP)
# define strn_cmp strnicmp
#endif
#if !defined(__GNUC__)
# define __attribute__(x) /* nothing */
#endif
#if defined(__MWERKS__)
# define isascii(c) (((c) & ~0x7f) == 0) /* So easy to have, but ... */
#endif
/* Socket/header miscellany. */
#if defined(CIRCLE_WINDOWS) /* Definitions for Win32 */
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# define PATH_MAX MAX_PATH
# if !defined(__BORLANDC__) && !defined(LCC_WIN32) /* MSVC */
# define chdir _chdir
# pragma warning(disable:4761) /* Integral size mismatch. */
# pragma warning(disable:4244) /* Possible loss of data. */
# endif
# if defined(__BORLANDC__) /* Silence warnings we don't care about. */
# pragma warn -par /* to turn off >parameter< 'ident' is never used. */
# pragma warn -pia /* to turn off possibly incorrect assignment. 'if (!(x=a))' */
# pragma warn -sig /* to turn off conversion may lose significant digits. */
# endif
# ifndef _WINSOCK2API_ /* Winsock1 and Winsock 2 conflict. */
# include <winsock.h>
# endif
# ifndef FD_SETSIZE /* MSVC 6 is reported to have 64. */
# define FD_SETSIZE 1024
# endif
#elif defined(CIRCLE_VMS)
/*
* Necessary Definitions For DEC C With DEC C Sockets Under OpenVMS.
*/
# if defined(DECC)
# include <stdio.h>
# include <time.h>
# include <stropts.h>
# include <unixio.h>
# endif
#elif !defined(CIRCLE_MACINTOSH) && !defined(CIRCLE_UNIX) && !defined(CIRCLE_ACORN)
# error "You forgot to include conf.h or do not have a valid system define."
#endif
/* SOCKET -- must be after the winsock.h #include. */
#ifdef CIRCLE_WINDOWS
# define CLOSE_SOCKET(sock) closesocket(sock)
typedef SOCKET socket_t;
#else
# define CLOSE_SOCKET(sock) close(sock)
typedef int socket_t;
#endif
#if defined(__cplusplus) /* C++ */
#define cpp_extern extern
#else /* C */
#define cpp_extern /* Nothing */
#endif
/* Guess if we have the getrlimit()/setrlimit() functions */
#if defined(RLIMIT_NOFILE) || defined (RLIMIT_OFILE)
#define HAS_RLIMIT
#if !defined (RLIMIT_NOFILE)
# define RLIMIT_NOFILE RLIMIT_OFILE
#endif
#endif
/* Make sure we have STDERR_FILENO */
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
/* Make sure we have STDOUT_FILENO too. */
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
# include "bsd-snprintf.h"
#endif
/* Function prototypes ************************************************/
/*
* For reasons that perplex me, the header files of many OS's do not contain
* function prototypes for the standard C library functions. This produces
* annoying warning messages (sometimes, a huge number of them) on such OS's
* when compiling with gcc's -Wall.
*
* Some versions of CircleMUD prior to 3.0 patchlevel 9 attempted to
* include prototypes taken from OS man pages for a large number of
* OS's in the header files. I now think such an approach is a bad
* idea: maintaining that list is very difficult and time-consuming,
* and when new revisions of OS's are released with new header files,
* Circle can break if the prototypes contained in Circle's .h files
* differs from the new OS header files; for example, Circle 3.0
* patchlevel 8 failed with compiler errors under Solaris 2.5 and
* Linux 1.3.xx whereas under previous revisions of those OS's it had
* been fine.
*
* Thus, to silence the compiler warnings but still maintain some level of
* portability (albiet at the expense of worse error checking in the code),
* my solution is to define a "typeless" function prototype for all problem
* functions that have not already been prototyped by the OS. --JE
*
* 20 Mar 96: My quest is not yet over. These definitions still cause
* clashes with some compilers. Therefore, we only use these prototypes
* if we're using gcc (which makes sense, since they're only here for gcc's
* -Wall option in the first place), and configure tells gcc to use
* -fno-strict-prototypes, so that these definitions don't clash with
* previous prototypes.
*
* 4 June 96: The quest continues. OSF/1 still doesn't like these
* prototypes, even with gcc and -fno-strict-prototypes. I've created
* the constant NO_LIBRARY_PROTOTYPES to allow people to turn off the
* prototyping.
*
* 27 Oct 97: This is driving me crazy but I think I've finally come
* up with the solution that will work. I've changed the configure
* script to detect which prototypes exist already; this header file
* only prototypes functions that aren't already prototyped by the
* system headers. A clash should be impossible. This should give us
* our strong type-checking back. This should be the last word on
* this issue!
*/
#ifndef NO_LIBRARY_PROTOTYPES
#ifdef NEED_ATOI_PROTO
int atoi(const char *str);
#endif
#ifdef NEED_ATOL_PROTO
long atol(const char *str);
#endif
/*
* bzero is deprecated - use memset() instead. Not directly used in Circle
* but the prototype needed for FD_xxx macros on some machines.
*/
#ifdef NEED_BZERO_PROTO
void bzero(char *b, int length);
#endif
#ifdef NEED_CRYPT_PROTO
char *crypt(const char *key, const char *salt);
#endif
#ifdef NEED_FCLOSE_PROTO
int fclose(FILE *stream);
#endif
#ifdef NEED_FDOPEN_PROTO
FILE *fdopen(int fd, const char *mode);
#endif
#ifdef NEED_FFLUSH_PROTO
int fflush(FILE *stream);
#endif
#ifdef NEED_FPRINTF_PROTO
int fprintf(FILE *strm, const char *format, /* args */ ... );
#endif
#ifdef NEED_FREAD_PROTO
size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
#endif
#ifdef NEED_FSCANF_PROTO
int fscanf(FILE *strm, const char *format, ...);
#endif
#ifdef NEED_FSEEK_PROTO
int fseek(FILE *stream, long offset, int ptrname);
#endif
#ifdef NEED_FWRITE_PROTO
size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream);
#endif
#ifdef NEED_GETPID_PROTO
pid_t getpid(void);
#endif
#ifdef NEED_PERROR_PROTO
void perror(const char *s);
#endif
#ifdef NEED_QSORT_PROTO
void qsort(void *base, size_t nel, size_t width,
int (*compar) (const void *, const void *));
#endif
#ifdef NEED_REWIND_PROTO
void rewind(FILE *stream);
#endif
#ifdef NEED_SPRINTF_PROTO
int sprintf(char *s, const char *format, /* args */ ... );
#endif
#ifdef NEED_SSCANF_PROTO
int sscanf(const char *s, const char *format, ...);
#endif
#ifdef NEED_STRDUP_PROTO
char *strdup(const char *txt);
#endif
#ifdef NEED_STRERROR_PROTO
char *strerror(int errnum);
#endif
#ifdef NEED_STRLCPY_PROTO
size_t strlcpy(char *dest, const char *src, size_t copylen);
#endif
#ifdef NEED_SYSTEM_PROTO
int system(const char *string);
#endif
#ifdef NEED_TIME_PROTO
time_t time(time_t *tloc);
#endif
#ifdef NEED_UNLINK_PROTO
int unlink(const char *path);
#endif
#ifdef NEED_REMOVE_PROTO
int remove(const char *path);
#endif
/* Function prototypes that are only used in comm.c and some of the utils */
#if defined(__COMM_C__) || defined(CIRCLE_UTIL)
#ifdef NEED_ACCEPT_PROTO
int accept(socket_t s, struct sockaddr *addr, int *addrlen);
#endif
#ifdef NEED_BIND_PROTO
int bind(socket_t s, const struct sockaddr *name, int namelen);
#endif
#ifdef NEED_CHDIR_PROTO
int chdir(const char *path);
#endif
#ifdef NEED_CLOSE_PROTO
int close(int fildes);
#endif
#ifdef NEED_FCNTL_PROTO
int fcntl(int fildes, int cmd, /* arg */ ...);
#endif
#ifdef NEED_FPUTC_PROTO
int fputc(char c, FILE *stream);
#endif
#ifdef NEED_FPUTS_PROTO
int fputs(const char *s, FILE *stream);
#endif
#ifdef NEED_GETPEERNAME_PROTO
int getpeername(socket_t s, struct sockaddr *name, int *namelen);
#endif
#if defined(HAS_RLIMIT) && defined(NEED_GETRLIMIT_PROTO)
int getrlimit(int resource, struct rlimit *rlp);
#endif
#ifdef NEED_GETSOCKNAME_PROTO
int getsockname(socket_t s, struct sockaddr *name, int *namelen);
#endif
#ifdef NEED_GETTIMEOFDAY_PROTO
int gettimeofday(struct timeval *tp, void * );
#endif
#ifdef NEED_HTONL_PROTO
ulong htonl(u_long hostlong);
#endif
#ifdef NEED_HTONS_PROTO
u_short htons(u_short hostshort);
#endif
#if defined(HAVE_INET_ADDR) && defined(NEED_INET_ADDR_PROTO)
unsigned long int inet_addr(const char *cp);
#endif
#if defined(HAVE_INET_ATON) && defined(NEED_INET_ATON_PROTO)
int inet_aton(const char *cp, struct in_addr *inp);
#endif
#ifdef NEED_INET_NTOA_PROTO
char *inet_ntoa(const struct in_addr in);
#endif
#ifdef NEED_LISTEN_PROTO
int listen(socket_t s, int backlog);
#endif
#ifdef NEED_NTOHL_PROTO
u_long ntohl(u_long netlong);
#endif
#ifdef NEED_PRINTF_PROTO
int printf(char *format, ...);
#endif
#ifdef NEED_READ_PROTO
ssize_t read(int fildes, void *buf, size_t nbyte);
#endif
#ifdef NEED_SELECT_PROTO
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
#endif
#ifdef NEED_SETITIMER_PROTO
int setitimer(int which, const struct itimerval *value,
struct itimerval *ovalue);
#endif
#if defined(HAS_RLIMIT) && defined(NEED_SETRLIMIT_PROTO)
int setrlimit(int resource, const struct rlimit *rlp);
#endif
#ifdef NEED_SETSOCKOPT_PROTO
int setsockopt(socket_t s, int level, int optname, const char *optval,
int optlen);
#endif
#ifdef NEED_SOCKET_PROTO
int socket(int domain, int type, int protocol);
#endif
#ifdef NEED_WRITE_PROTO
ssize_t write(int fildes, const void *buf, size_t nbyte);
#endif
#endif /* __COMM_C__ */
#endif /* NO_LIBRARY_PROTOTYPES */

319
old-codebase/src/telnet.h Normal file
View File

@@ -0,0 +1,319 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)telnet.h 8.2 (Berkeley) 12/15/93
*/
#ifndef _ARPA_TELNET_H
#define _ARPA_TELNET_H
/*
* Definitions for the TELNET protocol.
*/
#define IAC 255 /* interpret as command: */
#define DONT 254 /* you are not to use option */
#define DO 253 /* please, you use option */
#define WONT 252 /* I won't use option */
#define WILL 251 /* I will use option */
#define SB 250 /* interpret as subnegotiation */
#define GA 249 /* you may reverse the line */
#define EL 248 /* erase the current line */
#define EC 247 /* erase the current character */
#define AYT 246 /* are you there */
#define AO 245 /* abort output--but let prog finish */
#define IP 244 /* interrupt process--permanently */
#define BREAK 243 /* break */
#define DM 242 /* data mark--for connect. cleaning */
#define NOP 241 /* nop */
#define SE 240 /* end sub negotiation */
#define EOR 239 /* end of record (transparent mode) */
#define ABORT 238 /* Abort process */
#define SUSP 237 /* Suspend process */
#define xEOF 236 /* End of file: EOF is already used... */
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
};
#else
extern char *telcmds[];
#endif
#define TELCMD_FIRST xEOF
#define TELCMD_LAST IAC
#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
(unsigned int)(x) >= TELCMD_FIRST)
#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
/* telnet options */
#define TELOPT_BINARY 0 /* 8-bit data path */
#define TELOPT_ECHO 1 /* echo */
#define TELOPT_RCP 2 /* prepare to reconnect */
#define TELOPT_SGA 3 /* suppress go ahead */
#define TELOPT_NAMS 4 /* approximate message size */
#define TELOPT_STATUS 5 /* give status */
#define TELOPT_TM 6 /* timing mark */
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
#define TELOPT_NAOL 8 /* negotiate about output line width */
#define TELOPT_NAOP 9 /* negotiate about output page size */
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
#define TELOPT_XASCII 17 /* extended ascic character set */
#define TELOPT_LOGOUT 18 /* force logout */
#define TELOPT_BM 19 /* byte macro */
#define TELOPT_DET 20 /* data entry terminal */
#define TELOPT_SUPDUP 21 /* supdup protocol */
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
#define TELOPT_SNDLOC 23 /* send location */
#define TELOPT_TTYPE 24 /* terminal type */
#define TELOPT_EOR 25 /* end or record */
#define TELOPT_TUID 26 /* TACACS user identification */
#define TELOPT_OUTMRK 27 /* output marking */
#define TELOPT_TTYLOC 28 /* terminal location number */
#define TELOPT_3270REGIME 29 /* 3270 regime */
#define TELOPT_X3PAD 30 /* X.3 PAD */
#define TELOPT_NAWS 31 /* window size */
#define TELOPT_TSPEED 32 /* terminal speed */
#define TELOPT_LFLOW 33 /* remote flow control */
#define TELOPT_LINEMODE 34 /* Linemode option */
#define TELOPT_XDISPLOC 35 /* X Display Location */
#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
#define TELOPT_AUTHENTICATION 37/* Authenticate */
#define TELOPT_ENCRYPT 38 /* Encryption option */
#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
#define TELOPT_EXOPL 255 /* extended-options-list */
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
"TACACS UID", "OUTPUT MARKING", "TTYLOC",
"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
"ENCRYPT", "NEW-ENVIRON",
0,
};
#define TELOPT_FIRST TELOPT_BINARY
#define TELOPT_LAST TELOPT_NEW_ENVIRON
#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
#endif
/* sub-option qualifiers */
#define TELQUAL_IS 0 /* option is... */
#define TELQUAL_SEND 1 /* send option */
#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
#define LFLOW_OFF 0 /* Disable remote flow control */
#define LFLOW_ON 1 /* Enable remote flow control */
#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
/*
* LINEMODE suboptions
*/
#define LM_MODE 1
#define LM_FORWARDMASK 2
#define LM_SLC 3
#define MODE_EDIT 0x01
#define MODE_TRAPSIG 0x02
#define MODE_ACK 0x04
#define MODE_SOFT_TAB 0x08
#define MODE_LIT_ECHO 0x10
#define MODE_MASK 0x1f
/* Not part of protocol, but needed to simplify things... */
#define MODE_FLOW 0x0100
#define MODE_ECHO 0x0200
#define MODE_INBIN 0x0400
#define MODE_OUTBIN 0x0800
#define MODE_FORCE 0x1000
#define SLC_SYNCH 1
#define SLC_BRK 2
#define SLC_IP 3
#define SLC_AO 4
#define SLC_AYT 5
#define SLC_EOR 6
#define SLC_ABORT 7
#define SLC_EOF 8
#define SLC_SUSP 9
#define SLC_EC 10
#define SLC_EL 11
#define SLC_EW 12
#define SLC_RP 13
#define SLC_LNEXT 14
#define SLC_XON 15
#define SLC_XOFF 16
#define SLC_FORW1 17
#define SLC_FORW2 18
#define NSLC 18
/*
* For backwards compatability, we define SLC_NAMES to be the
* list of names if SLC_NAMES is not defined.
*/
#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
#ifdef SLC_NAMES
char *slc_names[] = {
SLC_NAMELIST
};
#else
extern char *slc_names[];
#define SLC_NAMES SLC_NAMELIST
#endif
#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
#define SLC_NAME(x) slc_names[x]
#define SLC_NOSUPPORT 0
#define SLC_CANTCHANGE 1
#define SLC_VARIABLE 2
#define SLC_DEFAULT 3
#define SLC_LEVELBITS 0x03
#define SLC_FUNC 0
#define SLC_FLAGS 1
#define SLC_VALUE 2
#define SLC_ACK 0x80
#define SLC_FLUSHIN 0x40
#define SLC_FLUSHOUT 0x20
#define OLD_ENV_VAR 1
#define OLD_ENV_VALUE 0
#define NEW_ENV_VAR 0
#define NEW_ENV_VALUE 1
#define ENV_ESC 2
#define ENV_USERVAR 3
/*
* AUTHENTICATION suboptions
*/
/*
* Who is authenticating who ...
*/
#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
#define AUTH_WHO_SERVER 1 /* Server authenticating client */
#define AUTH_WHO_MASK 1
/*
* amount of authentication done
*/
#define AUTH_HOW_ONE_WAY 0
#define AUTH_HOW_MUTUAL 2
#define AUTH_HOW_MASK 2
#define AUTHTYPE_NULL 0
#define AUTHTYPE_KERBEROS_V4 1
#define AUTHTYPE_KERBEROS_V5 2
#define AUTHTYPE_SPX 3
#define AUTHTYPE_MINK 4
#define AUTHTYPE_CNT 5
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
char *authtype_names[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
};
#else
extern char *authtype_names[];
#endif
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
#define AUTHTYPE_NAME(x) authtype_names[x]
/*
* ENCRYPTion suboptions
*/
#define ENCRYPT_IS 0 /* I pick encryption type ... */
#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
#define ENCRYPT_REPLY 2 /* Initial setup response */
#define ENCRYPT_START 3 /* Am starting to send encrypted */
#define ENCRYPT_END 4 /* Am ending encrypted */
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
#define ENCRYPT_REQEND 6 /* Request you send encrypting */
#define ENCRYPT_ENC_KEYID 7
#define ENCRYPT_DEC_KEYID 8
#define ENCRYPT_CNT 9
#define ENCTYPE_ANY 0
#define ENCTYPE_DES_CFB64 1
#define ENCTYPE_DES_OFB64 2
#define ENCTYPE_CNT 3
#ifdef ENCRYPT_NAMES
char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0,
};
char *enctype_names[] = {
"ANY", "DES_CFB64", "DES_OFB64", 0,
};
#else
extern char *encrypt_names[];
extern char *enctype_names[];
#endif
#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
#define ENCRYPT_NAME(x) encrypt_names[x]
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
#endif /* _ARPA_TELNET_H */

1
old-codebase/src/util/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
Makefile

View File

@@ -0,0 +1,93 @@
# CircleMUD Makefile.in - Makefile template used by 'configure'
# for the 'util' directory
# C compiler to use
CC = @CC@
# Any special flags you want to pass to the compiler
MYFLAGS = @MYFLAGS@ -DCIRCLE_UTIL
#flags for profiling (see hacker.doc for more information)
PROFILE =
##############################################################################
# Do Not Modify Anything Below This Line (unless you know what you're doing) #
##############################################################################
# binary destination directory
BINDIR = ../../bin
# location of Circle include files
INCDIR = ..
CFLAGS = @CFLAGS@ @SQLITE3_CFLAGS@ $(MYFLAGS) $(PROFILE) -I$(INCDIR)
LIBS = @LIBS@ @SQLITE3_LIBS@
default: all
all: $(BINDIR)/autowiz $(BINDIR)/delobjs $(BINDIR)/listrent \
$(BINDIR)/mudpasswd $(BINDIR)/play2to3 $(BINDIR)/purgeplay \
$(BINDIR)/shopconv $(BINDIR)/showplay $(BINDIR)/sign $(BINDIR)/split \
$(BINDIR)/wld2html
autowiz: $(BINDIR)/autowiz
delobjs: $(BINDIR)/delobjs
listrent: $(BINDIR)/listrent
mudpasswd: $(BINDIR)/mudpasswd
play2to3: $(BINDIR)/play2to3
purgeplay: $(BINDIR)/purgeplay
shopconv: $(BINDIR)/shopconv
showplay: $(BINDIR)/showplay
sign: $(BINDIR)/sign
split: $(BINDIR)/split
wld2html: $(BINDIR)/wld2html
$(BINDIR)/autowiz: autowiz.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h $(INCDIR)/utils.h $(INCDIR)/db.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/autowiz autowiz.c
$(BINDIR)/delobjs: delobjs.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h $(INCDIR)/utils.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/delobjs delobjs.c
$(BINDIR)/listrent: listrent.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/listrent listrent.c
$(BINDIR)/mudpasswd: mudpasswd.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h $(INCDIR)/utils.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/mudpasswd mudpasswd.c @CRYPTLIB@
$(BINDIR)/play2to3: play2to3.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/play2to3 play2to3.c
$(BINDIR)/purgeplay: purgeplay.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h $(INCDIR)/utils.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/purgeplay purgeplay.c
$(BINDIR)/shopconv: shopconv.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h $(INCDIR)/db.h $(INCDIR)/utils.h $(INCDIR)/shop.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/shopconv shopconv.c
$(BINDIR)/showplay: showplay.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h \
$(INCDIR)/structs.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/showplay showplay.c
$(BINDIR)/sign: sign.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/sign sign.c @NETLIB@
$(BINDIR)/split: split.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/split split.c
$(BINDIR)/wld2html: wld2html.c $(INCDIR)/conf.h $(INCDIR)/sysdep.h
$(CC) $(CFLAGS) $(LIBS) -o $(BINDIR)/wld2html wld2html.c

View File

@@ -0,0 +1,257 @@
/* ************************************************************************
* file: autowiz.c Part of CircleMUD *
* Usage: self-updating wizlists *
* Written by Jeremy Elson *
* All Rights Reserved *
* Copyright (C) 1993 The Trustees of The Johns Hopkins University *
************************************************************************* */
/*
WARNING: THIS CODE IS A HACK. WE CAN NOT AND WILL NOT BE RESPONSIBLE
FOR ANY NASUEA, DIZZINESS, VOMITING, OR SHORTNESS OF BREATH RESULTING
FROM READING THIS CODE. PREGNANT WOMEN AND INDIVIDUALS WITH BACK
INJURIES, HEART CONDITIONS, OR ARE UNDER THE CARE OF A PHYSICIAN SHOULD
NOT READ THIS CODE.
-- The Management
*/
#include "conf.h"
#include "sysdep.h"
#include <signal.h>
#include "structs.h"
#include "utils.h"
#include "db.h"
#define IMM_LMARG " "
#define IMM_NSIZE 16
#define LINE_LEN 64
#define MIN_LEVEL LVL_IMMORT
/* max level that should be in columns instead of centered */
#define COL_LEVEL LVL_IMMORT
struct name_rec {
char name[25];
struct name_rec *next;
};
struct control_rec {
int level;
char *level_name;
};
struct level_rec {
struct control_rec *params;
struct level_rec *next;
struct name_rec *names;
};
struct control_rec level_params[] =
{
{LVL_IMMORT, "Immortals"},
{LVL_GOD, "Gods"},
{LVL_GRGOD, "Greater Gods"},
{LVL_IMPL, "Implementors"},
{0, ""}
};
struct level_rec *levels = 0;
void initialize(void)
{
struct level_rec *tmp;
int i = 0;
while (level_params[i].level > 0) {
tmp = (struct level_rec *) malloc(sizeof(struct level_rec));
tmp->names = 0;
tmp->params = &(level_params[i++]);
tmp->next = levels;
levels = tmp;
}
}
void read_file(void)
{
void add_name(byte level, char *name);
struct char_file_u player;
FILE *fl;
if (!(fl = fopen(PLAYER_FILE, "rb"))) {
perror("Error opening playerfile");
exit(1);
}
while (!feof(fl)) {
fread(&player, sizeof(struct char_file_u), 1, fl);
if (!feof(fl) && player.level >= MIN_LEVEL &&
!(IS_SET(player.char_specials_saved.act, PLR_FROZEN)) &&
!(IS_SET(player.char_specials_saved.act, PLR_NOWIZLIST)) &&
!(IS_SET(player.char_specials_saved.act, PLR_DELETED)))
add_name(player.level, player.name);
}
fclose(fl);
}
void add_name(byte level, char *name)
{
struct name_rec *tmp;
struct level_rec *curr_level;
char *ptr;
if (!*name)
return;
for (ptr = name; *ptr; ptr++)
if (!isalpha(*ptr))
return;
tmp = (struct name_rec *) malloc(sizeof(struct name_rec));
strcpy(tmp->name, name);
tmp->next = 0;
curr_level = levels;
while (curr_level->params->level > level)
curr_level = curr_level->next;
tmp->next = curr_level->names;
curr_level->names = tmp;
}
void sort_names(void)
{
struct level_rec *curr_level;
struct name_rec *a, *b;
char temp[100];
for (curr_level = levels; curr_level; curr_level = curr_level->next) {
for (a = curr_level->names; a && a->next; a = a->next) {
for (b = a->next; b; b = b->next) {
if (strcmp(a->name, b->name) > 0) {
strcpy(temp, a->name);
strcpy(a->name, b->name);
strcpy(b->name, temp);
}
}
}
}
}
void write_wizlist(FILE * out, int minlev, int maxlev)
{
char buf[100];
struct level_rec *curr_level;
struct name_rec *curr_name;
int i, j;
fprintf(out,
"*************************************************************************\n"
"* The following people have reached immortality on CircleMUD. They are *\n"
"* to be treated with respect and awe. Occasional prayers to them are *\n"
"* advisable. Annoying them is not recommended. Stealing from them is *\n"
"* punishable by immediate death. *\n"
"*************************************************************************\n\n");
for (curr_level = levels; curr_level; curr_level = curr_level->next) {
if (curr_level->params->level < minlev ||
curr_level->params->level > maxlev)
continue;
i = 39 - (strlen(curr_level->params->level_name) >> 1);
for (j = 1; j <= i; j++)
fputc(' ', out);
fprintf(out, "%s\n", curr_level->params->level_name);
for (j = 1; j <= i; j++)
fputc(' ', out);
for (j = 1; j <= strlen(curr_level->params->level_name); j++)
fputc('~', out);
fprintf(out, "\n");
strcpy(buf, "");
curr_name = curr_level->names;
while (curr_name) {
strcat(buf, curr_name->name);
if (strlen(buf) > LINE_LEN) {
if (curr_level->params->level <= COL_LEVEL)
fprintf(out, IMM_LMARG);
else {
i = 40 - (strlen(buf) >> 1);
for (j = 1; j <= i; j++)
fputc(' ', out);
}
fprintf(out, "%s\n", buf);
strcpy(buf, "");
} else {
if (curr_level->params->level <= COL_LEVEL) {
for (j = 1; j <= (IMM_NSIZE - strlen(curr_name->name)); j++)
strcat(buf, " ");
}
if (curr_level->params->level > COL_LEVEL)
strcat(buf, " ");
}
curr_name = curr_name->next;
}
if (*buf) {
if (curr_level->params->level <= COL_LEVEL)
fprintf(out, "%s%s\n", IMM_LMARG, buf);
else {
i = 40 - (strlen(buf) >> 1);
for (j = 1; j <= i; j++)
fputc(' ', out);
fprintf(out, "%s\n", buf);
}
}
fprintf(out, "\n");
}
}
int main(int argc, char **argv)
{
int wizlevel, immlevel, pid = 0;
FILE *fl;
if (argc != 5 && argc != 6) {
printf("Format: %s wizlev wizlistfile immlev immlistfile [pid to signal]\n",
argv[0]);
exit(0);
}
wizlevel = atoi(argv[1]);
immlevel = atoi(argv[3]);
#ifdef CIRCLE_UNIX /* Perhaps #ifndef CIRCLE_WINDOWS but ... */
if (argc == 6)
pid = atoi(argv[5]);
#endif
initialize();
read_file();
sort_names();
fl = fopen(argv[2], "w");
write_wizlist(fl, wizlevel, LVL_IMPL);
fclose(fl);
fl = fopen(argv[4], "w");
write_wizlist(fl, immlevel, wizlevel - 1);
fclose(fl);
#ifdef CIRCLE_UNIX /* ... I don't have the platforms to test. */
if (pid)
kill(pid, SIGUSR1);
#endif
return (0);
}

View File

@@ -0,0 +1,93 @@
/* ************************************************************************
* file: delobjs.c Part of CircleMud *
* Usage: deleting object files for players who are not in the playerfile *
* Written by Jeremy Elson 4/2/93 *
* All Rights Reserved *
* Copyright (C) 1993 The Trustees of The Johns Hopkins University *
************************************************************************* */
/*
I recommend you use the script in the lib/plrobjs directory instead of
invoking this program directly; however, you can use this program thusly:
usage: switch into an obj directory; type: delobjs <plrfile> <obj wildcard>
*/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
struct name_element {
char name[20];
struct name_element *next;
};
struct name_element *name_list = 0;
void do_purge(int argc, char **argv)
{
int x;
struct name_element *tmp;
char name[1024];
int found;
for (x = 2; x < argc; x++) {
found = 0;
strcpy(name, argv[x]);
*(strchr(name, '.')) = '\0';
for (tmp = name_list; !found && tmp; tmp = tmp->next)
if (!strcmp(tmp->name, name))
found = 1;
if (!found) {
remove(argv[x]);
printf("Deleting %s\n", argv[x]);
}
}
}
int main(int argc, char **argv)
{
char *ptr;
struct char_file_u player;
int okay;
struct name_element *tmp;
FILE *fl;
if (argc < 3) {
printf("Usage: %s <playerfile-name> <file1> <file2> ... <filen>\n",
argv[0]);
exit(1);
}
if (!(fl = fopen(argv[1], "rb"))) {
perror("Unable to open playerfile for reading");
exit(1);
}
while (1) {
fread(&player, sizeof(player), 1, fl);
if (feof(fl)) {
fclose(fl);
do_purge(argc, argv);
exit(0);
}
okay = 1;
for (ptr = player.name; *ptr; ptr++)
*ptr = LOWER(*ptr);
if (player.char_specials_saved.act & PLR_DELETED)
okay = 0;
if (okay) {
tmp = (struct name_element *) malloc(sizeof(struct name_element));
tmp->next = name_list;
strcpy(tmp->name, player.name);
name_list = tmp;
}
}
}

View File

@@ -0,0 +1,71 @@
/* ************************************************************************
* file: listrent.c Part of CircleMUD *
* Usage: list player rent files *
* Written by Jeremy Elson *
* All Rights Reserved *
* Copyright (C) 1993 The Trustees of The Johns Hopkins University *
************************************************************************* */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
void Crash_listrent(char *fname);
int main(int argc, char **argv)
{
int x;
for (x = 1; x < argc; x++)
Crash_listrent(argv[x]);
return (0);
}
void Crash_listrent(char *fname)
{
FILE *fl;
char buf[MAX_STRING_LENGTH];
struct obj_file_elem object;
struct rent_info rent;
if (!(fl = fopen(fname, "rb"))) {
sprintf(buf, "%s has no rent file.\r\n", fname);
printf("%s", buf);
return;
}
sprintf(buf, "%s\r\n", fname);
if (!feof(fl))
fread(&rent, sizeof(struct rent_info), 1, fl);
switch (rent.rentcode) {
case RENT_RENTED:
strcat(buf, "Rent\r\n");
break;
case RENT_CRASH:
strcat(buf, "Crash\r\n");
break;
case RENT_CRYO:
strcat(buf, "Cryo\r\n");
break;
case RENT_TIMEDOUT:
case RENT_FORCED:
strcat(buf, "TimedOut\r\n");
break;
default:
strcat(buf, "Undef\r\n");
break;
}
while (!feof(fl)) {
fread(&object, sizeof(struct obj_file_elem), 1, fl);
if (ferror(fl)) {
fclose(fl);
return;
}
if (!feof(fl))
sprintf(buf, "%s[%5d] %s\n", buf, object.item_number, fname);
}
printf("%s", buf);
fclose(fl);
}

View File

@@ -0,0 +1,84 @@
/* ************************************************************************
* file: mudpasswd.c Part of CircleMud *
* Usage: changing passwords of chars in a Diku playerifle *
* Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
* All Rights Reserved *
************************************************************************* */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
int str_eq(char *s, char *t)
{
for (;;) {
if (*s == 0 && *t == 0)
return (TRUE);
if (LOWER(*s) != LOWER(*t))
return (FALSE);
s++;
t++;
}
}
void pword(char *filename, char *name, char *password)
{
FILE *fl;
struct char_file_u buf;
int found = FALSE;
long size;
if (!(fl = fopen(filename, "r+"))) {
perror(filename);
exit(1);
}
fseek(fl, 0L, SEEK_END);
size = ftell(fl);
rewind(fl);
if (size % sizeof(struct char_file_u)) {
fprintf(stderr, "\aWARNING: File size does not match structure, recompile mudpasswd.\n");
fclose(fl);
exit(1);
}
for (;;) {
fread(&buf, sizeof(buf), 1, fl);
if (feof(fl))
break;
if (str_eq(name, buf.name)) {
found = TRUE;
strncpy(buf.pwd, CRYPT(password, buf.name), MAX_PWD_LENGTH);
if (fseek(fl, -1L * sizeof(buf), SEEK_CUR) != 0)
perror("fseek");
if (fwrite(&buf, sizeof(buf), 1, fl) != 1)
perror("fwrite");
if (fseek(fl, 0L, SEEK_CUR) != 0)
perror("fseek");
}
}
if (found) {
printf("%s password is now %s\n", name, password);
} else {
printf("%s not found\n", name);
}
fclose(fl);
}
int main(int argc, char **argv)
{
if (argc != 4)
fprintf(stderr, "Usage: %s playerfile character-name new-password\n", argv[0]);
else
pword(argv[1], argv[2], argv[3]);
return (0);
}

View File

@@ -0,0 +1,379 @@
/*
play2to3.c - CircleMUD v2.2-to-v3.0 player file converter
June 12th, 1995
This is a quick&dirty hack to convert a player file from CircleMUD v2.2
to CircleMUD v3.0. As far as I know it works and it should be portable,
but I have only compiled and tested it under Linux 1.1.59.
Edward Almasy
almasy@axis.com
*/
#include "conf.h"
#include "sysdep.h"
typedef signed char sbyte;
typedef unsigned char ubyte;
typedef signed short int sh_int;
typedef unsigned short int ush_int;
typedef char bool;
typedef char byte;
typedef sh_int room_num;
#define THREE_MAX_NAME_LENGTH 20
#define THREE_MAX_PWD_LENGTH 10
#define THREE_MAX_TITLE_LENGTH 80
#define THREE_HOST_LENGTH 30
#define THREE_EXDSCR_LENGTH 240
#define THREE_MAX_TONGUE 3
#define THREE_MAX_SKILLS 200
#define THREE_MAX_AFFECT 32
struct THREE_char_ability_data {
sbyte str;
sbyte str_add; /* 000 - 100 if strength 18 */
sbyte intel;
sbyte wis;
sbyte dex;
sbyte con;
sbyte cha;
};
struct THREE_char_point_data {
sh_int mana;
sh_int max_mana; /* Max mana for PC/NPC */
sh_int hit;
sh_int max_hit; /* Max hit for PC/NPC */
sh_int move;
sh_int max_move; /* Max move for PC/NPC */
sh_int armor; /* Internal -100..100, external -10..10 AC */
int gold; /* Money carried */
int bank_gold; /* Gold the char has in a bank account */
int exp; /* The experience of the player */
sbyte hitroll; /* Any bonus or penalty to the hit roll */
sbyte damroll; /* Any bonus or penalty to the damage roll */
};
struct THREE_char_special_data_saved {
int alignment; /* +-1000 for alignments */
long idnum; /* player's idnum; -1 for mobiles */
long act; /* act flag for NPC's; player flag for PC's */
long affected_by; /* Bitvector for spells/skills affected by */
sh_int apply_saving_throw[5]; /* Saving throw (Bonuses) */
};
struct THREE_player_special_data_saved {
byte skills[THREE_MAX_SKILLS + 1]; /* array of skills plus skill 0 */
byte spells_to_learn; /* How many can you learn yet this level */
bool talks[THREE_MAX_TONGUE]; /* PC s Tongues 0 for NPC */
int wimp_level; /* Below this # of hit points, flee! */
byte freeze_level; /* Level of god who froze char, if any */
sh_int invis_level; /* level of invisibility */
room_num load_room; /* Which room to place char in */
long pref; /* preference flags for PC's. */
ubyte bad_pws; /* number of bad password attemps */
sbyte conditions[3]; /* Drunk, full, thirsty */
ubyte spare0;
ubyte spare1;
ubyte spare2;
ubyte spare3;
ubyte spare4;
ubyte spare5;
int spare6;
int spare7;
int spare8;
int spare9;
int spare10;
int spare11;
int spare12;
int spare13;
int spare14;
int spare15;
int spare16;
long spare17;
long spare18;
long spare19;
long spare20;
long spare21;
};
/* An affect structure. Used in char_file_u *DO*NOT*CHANGE* */
struct THREE_affected_type {
sh_int type; /* The type of spell that caused this */
sh_int duration; /* For how long its effects will last */
sbyte modifier; /* This is added to apropriate ability */
byte location; /* Tells which ability to change(APPLY_XXX) */
long bitvector; /* Tells which bits to set (AFF_XXX) */
struct THREE_affected_type *next;
};
struct THREE_char_file_u {
char name[THREE_MAX_NAME_LENGTH + 1];
char description[THREE_EXDSCR_LENGTH];
char title[THREE_MAX_TITLE_LENGTH + 1];
byte sex;
byte class;
byte level;
sh_int hometown;
time_t birth; /* Time of birth of character */
int played; /* Number of secs played in total */
ubyte weight;
ubyte height;
char pwd[THREE_MAX_PWD_LENGTH + 1]; /* character's password */
struct THREE_char_special_data_saved char_specials_saved;
struct THREE_player_special_data_saved player_specials_saved;
struct THREE_char_ability_data abilities;
struct THREE_char_point_data points;
struct THREE_affected_type affected[THREE_MAX_AFFECT];
time_t last_logon; /* Time (in secs) of last logon */
char host[THREE_HOST_LENGTH + 1]; /* host of last logon */
};
#define TWO_MAX_PWD_LENGTH 10
#define TWO_HOST_LEN 30
#define TWO_MAX_TOUNGE 3
#define TWO_MAX_SKILLS 128
#define TWO_MAX_AFFECT 32
struct TWO_char_ability_data {
sbyte str;
sbyte str_add; /* 000 - 100 if strength 18 */
sbyte intel;
sbyte wis;
sbyte dex;
sbyte con;
};
struct TWO_char_point_data {
sh_int mana;
sh_int max_mana; /* Max move for PC/NPC */
sh_int hit;
sh_int max_hit; /* Max hit for PC/NPC */
sh_int move;
sh_int max_move; /* Max move for PC/NPC */
sh_int armor; /* Internal -100..100, external -10..10 AC */
int gold; /* Money carried */
int bank_gold; /* Gold the char has in a bank account */
int exp; /* The experience of the player */
sbyte hitroll; /* Any bonus or penalty to the hit roll */
sbyte damroll; /* Any bonus or penalty to the damage roll */
};
struct TWO_char_special2_data {
long idnum; /* player's idnum */
sh_int load_room; /* Which room to place char in */
byte spells_to_learn; /* How many can you learn yet this level */
int alignment; /* +-1000 for alignments */
long act; /* act flag for NPC's; player flag for PC's */
long pref; /* preference flags for PC's. */
int wimp_level; /* Below this # of hit points, flee! */
byte freeze_level; /* Level of god who froze char, if any */
ubyte bad_pws; /* number of bad password attemps */
sh_int apply_saving_throw[5]; /* Saving throw (Bonuses) */
sbyte conditions[3]; /* Drunk full etc. */
ubyte spare0;
ubyte spare1;
ubyte spare2;
ubyte spare3;
ubyte spare4;
ubyte spare5;
ubyte spare6;
ubyte spare7;
ubyte spare8;
ubyte spare9;
ubyte spare10;
ubyte spare11;
long spare12;
long spare13;
long spare14;
long spare15;
long spare16;
long spare17;
long spare18;
long spare19;
long spare20;
long spare21;
};
/* Used in CHAR_FILE_U *DO*NOT*CHANGE* */
struct TWO_affected_type {
sbyte type; /* The type of spell that caused this */
sh_int duration; /* For how long its effects will last */
sbyte modifier; /* This is added to apropriate ability */
byte location; /* Tells which ability to change(APPLY_XXX) */
long bitvector; /* Tells which bits to set (AFF_XXX) */
struct TWO_affected_type *next;
};
struct TWO_char_file_u {
byte sex;
byte class;
byte level;
time_t birth; /* Time of birth of character */
int played; /* Number of secs played in total */
ubyte weight;
ubyte height;
char title[80];
sh_int hometown;
char description[240];
bool talks[TWO_MAX_TOUNGE];
struct TWO_char_ability_data abilities;
struct TWO_char_point_data points;
byte skills[TWO_MAX_SKILLS];
struct TWO_affected_type affected[TWO_MAX_AFFECT];
struct TWO_char_special2_data specials2;
time_t last_logon; /* Time (in secs) of last logon */
char host[TWO_HOST_LEN + 1]; /* host of last logon */
char name[20];
char pwd[TWO_MAX_PWD_LENGTH + 1];
};
int main(int argc, char *argv[])
{
struct TWO_char_file_u stTwo;
struct THREE_char_file_u stThree;
FILE *ptTwoHndl;
FILE *ptThreeHndl;
int iIndex;
char *apcClassAbbrev[] =
{"Mu", "Cl", "Th", "Wa"};
int aiSkillMappings[] =
{138, 133, 139, 131, 135, 134, 132, 137};
if (argc < 3) {
printf("usage: play2to3 [old 2.2 player file] [new 3.0 player file]\n");
exit(1);
}
ptTwoHndl = fopen(argv[1], "rb");
if (ptTwoHndl == NULL) {
printf("unable to open source file \"%s\"\n", argv[1]);
exit(1);
}
ptThreeHndl = fopen(argv[2], "wb");
if (ptThreeHndl == NULL) {
printf("unable to open destination file \"%s\"\n", argv[2]);
exit(1);
}
while (!feof(ptTwoHndl)) {
fread(&stTwo, sizeof(struct TWO_char_file_u), 1, ptTwoHndl);
strcpy(stThree.name, stTwo.name);
strcpy(stThree.description, stTwo.description);
strcpy(stThree.title, stTwo.title);
stThree.sex = stTwo.sex;
stThree.class = stTwo.class - 1;
stThree.level = stTwo.level;
stThree.hometown = stTwo.hometown;
stThree.birth = stTwo.birth;
stThree.played = stTwo.played;
stThree.weight = stTwo.weight;
stThree.height = stTwo.height;
strcpy(stThree.pwd, stTwo.pwd);
stThree.char_specials_saved.alignment = stTwo.specials2.alignment;
stThree.char_specials_saved.idnum = stTwo.specials2.idnum;
stThree.char_specials_saved.act = stTwo.specials2.act;
stThree.char_specials_saved.affected_by = 0; /* ??? */
for (iIndex = 0; iIndex < 5; iIndex++)
stThree.char_specials_saved.apply_saving_throw[iIndex] =
stTwo.specials2.apply_saving_throw[iIndex];
for (iIndex = 0; iIndex < THREE_MAX_SKILLS; iIndex++)
stThree.player_specials_saved.skills[iIndex] = 0;
for (iIndex = 0; iIndex < 53; iIndex++)
if (iIndex > 44) {
stThree.player_specials_saved.skills[
aiSkillMappings[iIndex - 45]] = stTwo.skills[iIndex];
} else
stThree.player_specials_saved.skills[iIndex] =
stTwo.skills[iIndex];
stThree.player_specials_saved.spells_to_learn =
stTwo.specials2.spells_to_learn;
for (iIndex = 0; iIndex < THREE_MAX_TONGUE; iIndex++)
stThree.player_specials_saved.talks[iIndex] = stTwo.talks[iIndex];
stThree.player_specials_saved.wimp_level = stTwo.specials2.wimp_level;
stThree.player_specials_saved.freeze_level =
stTwo.specials2.freeze_level;
stThree.player_specials_saved.invis_level = 0;
stThree.player_specials_saved.load_room = stTwo.specials2.load_room;
stThree.player_specials_saved.pref = stTwo.specials2.pref;
stThree.player_specials_saved.bad_pws = stTwo.specials2.bad_pws;
for (iIndex = 0; iIndex < 3; iIndex++)
stThree.player_specials_saved.conditions[iIndex] =
stTwo.specials2.conditions[iIndex];
stThree.player_specials_saved.spare0 = 0;
stThree.player_specials_saved.spare1 = 0;
stThree.player_specials_saved.spare2 = 0;
stThree.player_specials_saved.spare3 = 0;
stThree.player_specials_saved.spare4 = 0;
stThree.player_specials_saved.spare5 = 0;
stThree.player_specials_saved.spare6 = 0;
stThree.player_specials_saved.spare7 = 0;
stThree.player_specials_saved.spare8 = 0;
stThree.player_specials_saved.spare9 = 0;
stThree.player_specials_saved.spare10 = 0;
stThree.player_specials_saved.spare11 = 0;
stThree.player_specials_saved.spare12 = 0;
stThree.player_specials_saved.spare13 = 0;
stThree.player_specials_saved.spare14 = 0;
stThree.player_specials_saved.spare15 = 0;
stThree.player_specials_saved.spare16 = 0;
stThree.player_specials_saved.spare17 = 0;
stThree.player_specials_saved.spare18 = 0;
stThree.player_specials_saved.spare19 = 0;
stThree.player_specials_saved.spare20 = 0;
stThree.player_specials_saved.spare21 = 0;
stThree.abilities.str = stTwo.abilities.str;
stThree.abilities.str_add = stTwo.abilities.str_add;
stThree.abilities.intel = stTwo.abilities.intel;
stThree.abilities.wis = stTwo.abilities.wis;
stThree.abilities.dex = stTwo.abilities.dex;
stThree.abilities.con = stTwo.abilities.con;
stThree.abilities.cha = 12;
stThree.points.mana = stTwo.points.mana;
stThree.points.max_mana = stTwo.points.max_mana;
stThree.points.hit = stTwo.points.hit;
stThree.points.max_hit = stTwo.points.max_hit;
stThree.points.move = stTwo.points.move;
stThree.points.max_move = stTwo.points.max_move;
stThree.points.armor = stTwo.points.armor;
stThree.points.gold = stTwo.points.gold;
stThree.points.bank_gold = stTwo.points.bank_gold;
stThree.points.exp = stTwo.points.exp;
stThree.points.hitroll = stTwo.points.hitroll;
stThree.points.damroll = stTwo.points.damroll;
for (iIndex = 0; iIndex < TWO_MAX_AFFECT; iIndex++) {
stThree.affected[iIndex].type = stTwo.affected[iIndex].type;
stThree.affected[iIndex].duration = stTwo.affected[iIndex].duration;
stThree.affected[iIndex].modifier = stTwo.affected[iIndex].modifier;
stThree.affected[iIndex].location = stTwo.affected[iIndex].location;
stThree.affected[iIndex].bitvector = stTwo.affected[iIndex].bitvector;
stThree.affected[iIndex].next = NULL;
}
stThree.last_logon = stTwo.last_logon;
strcpy(stThree.host, stTwo.host);
printf("[%2d %s] %s %s\n",
stThree.level, apcClassAbbrev[(int)stThree.class],
stThree.name, stThree.title);
fwrite(&stThree, sizeof(struct THREE_char_file_u), 1, ptThreeHndl);
}
fclose(ptThreeHndl);
fclose(ptTwoHndl);
return (0);
}

View File

@@ -0,0 +1,120 @@
/* ************************************************************************
* file: purgeplay.c Part of CircleMUD *
* Usage: purge useless chars from playerfile *
* All Rights Reserved *
* Copyright (C) 1992, 1993 The Trustees of The Johns Hopkins University *
************************************************************************* */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
void purge(char *filename)
{
FILE *fl;
FILE *outfile;
struct char_file_u player;
int okay, num = 0;
long timeout, size;
char *ptr, reason[80];
if (!(fl = fopen(filename, "r+"))) {
printf("Can't open %s.", filename);
exit(1);
}
fseek(fl, 0L, SEEK_END);
size = ftell(fl);
rewind(fl);
if (size % sizeof(struct char_file_u)) {
fprintf(stderr, "\aWARNING: File size does not match structure, recompile purgeplay.\n");
fclose(fl);
exit(1);
}
outfile = fopen("players.new", "w");
printf("Deleting: \n");
for (;;) {
fread(&player, sizeof(struct char_file_u), 1, fl);
if (feof(fl)) {
fclose(fl);
fclose(outfile);
printf("Done.\n");
exit(0);
}
okay = 1;
*reason = '\0';
for (ptr = player.name; *ptr; ptr++)
if (!isalpha(*ptr) || *ptr == ' ') {
okay = 0;
strcpy(reason, "Invalid name");
}
if (player.level == 0) {
okay = 0;
strcpy(reason, "Never entered game");
}
if (player.level < 0 || player.level > LVL_IMPL) {
okay = 0;
strcpy(reason, "Invalid level");
}
/* now, check for timeouts. They only apply if the char is not
cryo-rented. Lev 32-34 do not time out. */
timeout = 1000;
if (okay && player.level <= LVL_IMMORT) {
if (!(player.char_specials_saved.act & PLR_CRYO)) {
if (player.level == 1) timeout = 4; /* Lev 1 : 4 days */
else if (player.level <= 4) timeout = 7; /* Lev 2-4 : 7 days */
else if (player.level <= 10) timeout = 30; /* Lev 5-10: 30 days */
else if (player.level <= LVL_IMMORT - 1)
timeout = 60; /* Lev 11-30: 60 days */
else if (player.level <= LVL_IMMORT)
timeout = 90; /* Lev 31: 90 days */
} else
timeout = 90;
timeout *= SECS_PER_REAL_DAY;
if ((time(0) - player.last_logon) > timeout) {
okay = 0;
sprintf(reason, "Level %2d idle for %3ld days", player.level,
((time(0) - player.last_logon) / SECS_PER_REAL_DAY));
}
}
if (player.char_specials_saved.act & PLR_DELETED) {
okay = 0;
sprintf(reason, "Deleted flag set");
}
/* Don't delete for *any* of the above reasons if they have NODELETE */
if (!okay && (player.char_specials_saved.act & PLR_NODELETE)) {
okay = 2;
strcat(reason, "; NOT deleted.");
}
if (okay)
fwrite(&player, sizeof(struct char_file_u), 1, outfile);
else
printf("%4d. %-20s %s\n", ++num, player.name, reason);
if (okay == 2)
fprintf(stderr, "%-20s %s\n", player.name, reason);
}
}
int main(int argc, char *argv[])
{
if (argc != 2)
printf("Usage: %s playerfile-name\n", argv[0]);
else
purge(argv[1]);
return (0);
}

View File

@@ -0,0 +1,3 @@
scheck (the syntax checker) no longer exists as an independent utility.
If you want to check the syntax of the world files, just use the -c
switch on the main server.

View File

@@ -0,0 +1,190 @@
/* code to convert 2.20 shop files to 3.0 shop files - written by Jeff Fink */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "db.h"
#include "utils.h"
#include "shop.h"
void basic_mud_log(const char *x, ...)
{
puts(x);
}
char *fread_string(FILE * fl, const char *error)
{
char buf[MAX_STRING_LENGTH], tmp[512], *rslt, *point;
int flag;
*buf = '\0';
do {
if (!fgets(tmp, sizeof(tmp), fl)) {
printf("fread_string: format error at or near %s\n", error);
exit(1);
}
if (strlen(tmp) + strlen(buf) > MAX_STRING_LENGTH) {
printf("SYSERR: fread_string: string too large (shopconv.c)");
exit(1);
} else
strcat(buf, tmp);
for (point = buf + strlen(buf) - 2; point >= buf && isspace(*point);
point--);
if ((flag = (*point == '~'))) {
if (*(buf + strlen(buf) - 3) == '\n')
*(buf + strlen(buf) - 2) = '\0';
else
*(buf + strlen(buf) - 2) = '\0';
}
} while (!flag);
/* do the allocate boogie */
if (strlen(buf) > 0) {
CREATE(rslt, char, strlen(buf) + 1);
strcpy(rslt, buf);
} else
rslt = NULL;
return (rslt);
}
void do_list(FILE * shop_f, FILE * newshop_f, int max)
{
int count, temp;
char buf[MAX_STRING_LENGTH];
for (count = 0; count < max; count++) {
fscanf(shop_f, "%d", &temp);
fgets(buf, MAX_STRING_LENGTH - 1, shop_f);
if (temp > 0)
fprintf(newshop_f, "%d%s", temp, buf);
}
fprintf(newshop_f, "-1\n");
}
void do_float(FILE * shop_f, FILE * newshop_f)
{
float f;
char str[20];
fscanf(shop_f, "%f \n", &f);
sprintf(str, "%f", f);
while ((str[strlen(str) - 1] == '0') && (str[strlen(str) - 2] != '.'))
str[strlen(str) - 1] = 0;
fprintf(newshop_f, "%s \n", str);
}
void do_int(FILE * shop_f, FILE * newshop_f)
{
int i;
fscanf(shop_f, "%d \n", &i);
fprintf(newshop_f, "%d \n", i);
}
void do_string(FILE * shop_f, FILE * newshop_f, char *msg)
{
char *ptr;
ptr = fread_string(shop_f, msg);
fprintf(newshop_f, "%s~\n", ptr);
free(ptr);
}
int boot_the_shops(FILE * shop_f, FILE * newshop_f, char *filename)
{
char *buf, buf2[150];
int temp, count;
sprintf(buf2, "beginning of shop file %s", filename);
fprintf(newshop_f, "CircleMUD %s Shop File~\n", VERSION3_TAG);
for (;;) {
buf = fread_string(shop_f, buf2);
if (*buf == '#') { /* New shop */
sscanf(buf, "#%d\n", &temp);
sprintf(buf2, "shop #%d in shop file %s", temp, filename);
fprintf(newshop_f, "#%d~\n", temp);
free(buf); /* Plug memory leak! */
printf(" #%d\n", temp);
do_list(shop_f, newshop_f, MAX_PROD); /* Produced Items */
do_float(shop_f, newshop_f); /* Ratios */
do_float(shop_f, newshop_f);
do_list(shop_f, newshop_f, MAX_TRADE); /* Bought Items */
for (count = 0; count < 7; count++) /* Keeper msgs */
do_string(shop_f, newshop_f, buf2);
for (count = 0; count < 5; count++) /* Misc */
do_int(shop_f, newshop_f);
fprintf(newshop_f, "-1\n");
for (count = 0; count < 4; count++) /* Open/Close */
do_int(shop_f, newshop_f);
} else {
if (*buf == '$') { /* EOF */
free(buf); /* Plug memory leak! */
fprintf(newshop_f, "$~\n");
break;
} else if (strstr(buf, VERSION3_TAG)) {
printf("%s: New format detected, conversion aborted!\n", filename);
free(buf); /* Plug memory leak! */
return (1);
}
}
}
return (0);
}
int main(int argc, char *argv[])
{
FILE *sfp, *nsfp;
char fn[256], part[256];
int result, index;
if (argc < 2) {
printf("Usage: shopconv <file1> [file2] [file3] ...\n");
exit(1);
}
for (index = 1; index < argc; index++) {
sprintf(fn, "%s", argv[index]);
sprintf(part, "mv %s %s.tmp", fn, fn);
system(part);
sprintf(part, "%s.tmp", fn);
sfp = fopen(part, "r");
if (sfp == NULL) {
strcat(fn, " could not be opened");
perror(fn);
} else {
if ((nsfp = fopen(fn, "w")) == NULL) {
printf("Error writing to %s.\n", fn);
continue;
}
printf("%s:\n", fn);
result = boot_the_shops(sfp, nsfp, fn);
fclose(nsfp);
fclose(sfp);
if (result) {
sprintf(part, "mv %s.tmp %s", fn, fn);
system(part);
} else {
sprintf(part, "mv %s.tmp %s.bak", fn, fn);
system(part);
printf("Done!\n");
}
}
}
return (0);
}

View File

@@ -0,0 +1,91 @@
/* ************************************************************************
* file: showplay.c Part of CircleMud *
* Usage: list a diku playerfile *
* Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
* All Rights Reserved *
************************************************************************* */
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
void show(char *filename)
{
char sexname;
char classname[10];
FILE *fl;
struct char_file_u player;
int num = 0;
long size;
if (!(fl = fopen(filename, "r+"))) {
perror("error opening playerfile");
exit(1);
}
fseek(fl, 0L, SEEK_END);
size = ftell(fl);
rewind(fl);
if (size % sizeof(struct char_file_u)) {
fprintf(stderr, "\aWARNING: File size does not match structure, recompile showplay.\n");
fclose(fl);
exit(1);
}
for (;;) {
fread(&player, sizeof(struct char_file_u), 1, fl);
if (feof(fl)) {
fclose(fl);
exit(0);
}
switch (player.chclass) {
case CLASS_THIEF:
strcpy(classname, "Th");
break;
case CLASS_WARRIOR:
strcpy(classname, "Wa");
break;
case CLASS_MAGIC_USER:
strcpy(classname, "Mu");
break;
case CLASS_CLERIC:
strcpy(classname, "Cl");
break;
default:
strcpy(classname, "--");
break;
}
switch (player.sex) {
case SEX_FEMALE:
sexname = 'F';
break;
case SEX_MALE:
sexname = 'M';
break;
case SEX_NEUTRAL:
sexname = 'N';
break;
default:
sexname = '-';
break;
}
printf("%5d. ID: %5ld (%c) [%2d %s] %-16s %9dg %9db\n", ++num,
player.char_specials_saved.idnum, sexname, player.level,
classname, player.name, player.points.gold,
player.points.bank_gold);
}
}
int main(int argc, char **argv)
{
if (argc != 2)
printf("Usage: %s playerfile-name\n", argv[0]);
else
show(argv[1]);
return (0);
}

View File

@@ -0,0 +1,159 @@
/*
* sign.c: a program to present text on a TCP port
*
* Author: Jeremy Elson (jelson@circlemud.org)
* Usage: sign <port> <filename> or
* sign <port> -
*
* '-' indicates file should be read from stdin.
*
* This program is in the public domain. It may be copied, redistributed,
* reused, modified, etc., but a notice of my authorship must be maintained.
*
* This program comes with no warranty of any kind, expressed or implied.
*/
#define MAX_FILESIZE 8192
#define LINEBUF_SIZE 128
#include "conf.h"
#include "sysdep.h"
/*
* init_socket sets up the mother descriptor - creates the socket, sets
* its options up, binds it, and listens.
*/
int init_socket(int port)
{
int s, opt;
struct sockaddr_in sa;
/*
* Should the first argument to socket() be AF_INET or PF_INET? I don't
* know, take your pick. PF_INET seems to be more widely adopted, and
* Comer (_Internetworking with TCP/IP_) even makes a point to say that
* people erroneously use AF_INET with socket() when they should be using
* PF_INET. However, the man pages of some systems indicate that AF_INET
* is correct; some such as ConvexOS even say that you can use either one.
* All implementations I've seen define AF_INET and PF_INET to be the same
* number anyway, so ths point is (hopefully) moot.
*/
if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
perror("Create socket");
exit(1);
}
#if defined(SO_REUSEADDR)
opt = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &opt, sizeof(opt)) < 0) {
perror("setsockopt REUSEADDR");
exit(1);
}
#endif
#if defined(SO_LINGER)
{
struct linger ld;
ld.l_onoff = 0;
ld.l_linger = 0;
if (setsockopt(s, SOL_SOCKET, SO_LINGER, (char *) &ld, sizeof(ld)) < 0) {
perror("setsockopt LINGER");
exit(1);
}
}
#endif
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
perror("bind");
close(s);
exit(1);
}
listen(s, 5);
return (s);
}
char *get_text(char *fname)
{
static char t[MAX_FILESIZE];
char tmp[LINEBUF_SIZE + 2];
FILE *fl = NULL;
*t = '\0';
if (!strcmp(fname, "-")) {
fl = stdin;
if (isatty(STDIN_FILENO))
fprintf(stderr, "Enter sign text; terminate with Ctrl-D.\n");
} else {
if (!(fl = fopen(fname, "r"))) {
perror(fname);
exit(1);
}
}
while (fgets(tmp, LINEBUF_SIZE, fl)) {
if (strlen(tmp) + strlen(t) < MAX_FILESIZE - 1)
strcat(t, strcat(tmp, "\r"));
else {
fprintf(stderr, "String too long. Truncated.\n");
break;
}
}
return (t);
}
/* clean up our zombie kids to avoid defunct processes */
RETSIGTYPE reap(int sig)
{
while (waitpid(-1, NULL, WNOHANG) > 0);
signal(SIGCHLD, reap);
}
int main(int argc, char *argv[])
{
char *txt;
int desc, remaining, bytes_written, len, s, port, child;
if (argc != 3 || (port = atoi(argv[1])) < 1024) {
fprintf(stderr, "usage: %s <portnum> <\"-\" | filename>\n", argv[0]);
exit(1);
}
s = init_socket(port);
len = strlen(txt = get_text(argv[2]));
if ((child = fork()) > 0) {
fprintf(stderr, "Sign started on port %d (pid %d).\n", port, child);
exit(0);
}
signal(SIGCHLD, reap);
for (;;) {
if ((desc = accept(s, (struct sockaddr *) NULL, 0)) < 0)
continue;
if (fork() == 0) {
remaining = len;
do {
if ((bytes_written = write(desc, txt, remaining)) < 0)
exit(0);
else {
txt += bytes_written;
remaining -= bytes_written;
}
} while (remaining > 0);
exit(0);
}
close(desc);
}
}

View File

@@ -0,0 +1,57 @@
/* ************************************************************************
* file: split.c Part of CircleMud *
* Usage: split one large file into multiple smaller ones, with index *
* Written by Jeremy Elson *
* All Rights Reserved *
* Copyright (C) 1993 The Trustees of The Johns Hopkins University *
************************************************************************* */
/*
* This utility is meant to split a large file into multiple smaller ones,
* mainly to help break huge world files (ala Diku) into zone-sized files
* that are easier to manage.
*
* At each point in the original file where you want a break, insert a line
* containng "=filename" at the break point.
*/
#define INDEX_NAME "index"
#define BSZ 256
#define MAGIC_CHAR '='
#include "conf.h"
#include "sysdep.h"
int main(void)
{
char line[BSZ + 1];
FILE *index = 0, *outfile = 0;
if (!(index = fopen(INDEX_NAME, "w"))) {
perror("error opening index for write");
exit(1);
}
while (fgets(line, BSZ, stdin)) {
if (*line == MAGIC_CHAR) {
*(strchr(line, '\n')) = '\0';
if (outfile) {
/* fputs("$\n", outfile);*/
fclose(outfile);
}
if (!(outfile = fopen((line + 1), "a"))) {
perror("Error opening output file");
exit(0);
}
fputs(line + 1, index);
fputs("\n", index);
} else if (outfile)
fputs(line, outfile);
}
fputs("$\r\n", index);
fclose(index);
if (outfile)
fclose(outfile);
return (0);
}

View File

@@ -0,0 +1,513 @@
/* ************************************************************************
* File: wld2html.c *
* Usage: Convert a DikuMUD .wld file into a series of .html files *
* *
* This program is in the public domain. *
* Written (QUICKLY AND DIRTILY) by Jeremy Elson (jelson@circlemud.org) *
* Based on the Circle 3.0 syntax checker program (scheck.c) *
************************************************************************ */
#define log(msg) fprintf(stderr, "%s\n", msg)
#include "conf.h"
#include "sysdep.h"
#define NOWHERE -1 /* nil reference for room-database */
/* The cardinal directions: used as index to room_data.dir_option[] */
#define NORTH 0
#define EAST 1
#define SOUTH 2
#define WEST 3
#define UP 4
#define DOWN 5
#define NUM_OF_DIRS 6
#define CREATE(result, type, number) do {\
if (!((result) = (type *) calloc ((number), sizeof(type))))\
{ perror("malloc failure"); abort(); } } while(0)
/* Exit info: used in room_data.dir_option.exit_info */
#define EX_ISDOOR (1 << 0) /* Exit is a door */
#define EX_CLOSED (1 << 1) /* The door is closed */
#define EX_LOCKED (1 << 2) /* The door is locked */
#define EX_PICKPROOF (1 << 3) /* Lock can't be picked */
#define MAX_STRING_LENGTH 8192
typedef signed char sbyte;
typedef unsigned char ubyte;
typedef signed short int sh_int;
typedef unsigned short int ush_int;
typedef char bool;
typedef char byte;
typedef sh_int room_num;
typedef sh_int obj_num;
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char arg[MAX_STRING_LENGTH];
int get_line(FILE * fl, char *buf);
int real_room(int virtual, int reference);
/* room-related structures *********************************************** */
struct room_direction_data {
char *general_description; /* When look DIR. */
char *keyword; /* for open/close */
sh_int exit_info; /* Exit info */
obj_num key; /* Key's number (-1 for no key) */
room_num to_room; /* Where direction leads (NOWHERE) */
};
struct extra_descr_data {
char *keyword; /* Keyword in look/examine */
char *description; /* What to see */
struct extra_descr_data *next; /* Next in list */
};
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; /* */
/*
* 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 *
*/
};
struct zone_data {
char *name; /* name of this zone */
int lifespan; /* how long between resets (minutes) */
int age; /* current age of this zone (minutes) */
int top; /* upper limit for rooms in this zone */
int reset_mode; /* conditions for reset (see below) */
int 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. *
*/
};
/* ================== Memory Structure for room ======================= */
struct room_data {
room_num number; /* Rooms number (vnum) */
sh_int zone; /* Room zone (for resetting) */
int sector_type; /* sector type (move/hide) */
char *name; /* Rooms name 'You are ...' */
char *description; /* Shown when entered */
struct extra_descr_data *ex_description; /* for examine/look */
struct room_direction_data *dir_option[NUM_OF_DIRS]; /* Directions */
int room_flags; /* DEATH,DARK ... etc */
byte light; /* Number of lightsources in room */
};
/* ====================================================================== */
/**************************************************************************
* declarations of most of the 'global' variables *
************************************************************************ */
struct room_data *world = NULL; /* array of rooms */
int top_of_world = 0; /* ref to top element of world */
/* local functions */
char *fread_string(FILE * fl, char *error);
void setup_dir(FILE * fl, int room, int dir);
void index_boot(char *name);
void discrete_load(FILE * fl);
void parse_room(FILE * fl, int virtual_nr);
void parse_mobile(FILE * mob_f, int nr);
char *parse_object(FILE * obj_f, int nr);
void assign_rooms(void);
void renum_world(void);
void write_output(void);
char *dir_names[] =
{"North", "East", "South", "West", "Up", "Down"};
/*************************************************************************
* routines for booting the system *
*********************************************************************** */
/* body of the booting system */
int main(int argc, char **argv)
{
if (argc != 2) {
fprintf(stderr, "Usage: %s <world-file-name>\n", argv[0]);
exit(1);
}
index_boot(argv[1]);
log("Renumbering rooms.");
renum_world();
log("Writing output.");
write_output();
log("Done.");
return (0);
}
void write_output(void)
{
int i;
FILE *fl;
char buf[128];
register int door, found;
for (i = 0; i <= top_of_world; i++) {
sprintf(buf, "Writing %d.html", world[i].number);
log(buf);
sprintf(buf, "%d.html", world[i].number);
if (!(fl = fopen(buf, "w"))) {
perror("opening output file");
exit(1);
}
fprintf(fl, "<title> %s </title>\n", world[i].name);
fprintf(fl, "<h1> %s </h1>\n", world[i].name);
fprintf(fl, "<pre>\n");
fputs(world[i].description, fl);
fprintf(fl, "</pre>\n");
fprintf(fl, "<P> Exits: <P> \n");
found = 0;
for (door = 0; door < NUM_OF_DIRS; door++)
if (world[i].dir_option[door] &&
world[i].dir_option[door]->to_room != NOWHERE) {
found = 1;
fprintf(fl, "<a href = \"%d.html\"> %s to %s</a> <p>\n",
world[world[i].dir_option[door]->to_room].number,
dir_names[door],
world[world[i].dir_option[door]->to_room].name);
}
if (!found)
fprintf(fl, "None!");
fclose(fl);
}
}
/* function to count how many hash-mark delimited records exist in a file */
int count_hash_records(FILE * fl)
{
char buf[128];
int count = 0;
while (fgets(buf, 128, fl))
if (*buf == '#')
count++;
return (count);
}
void index_boot(char *name)
{
FILE *db_file;
int rec_count = 0;
if (!(db_file = fopen(name, "r"))) {
perror("error opening world file");
exit(1);
}
rec_count = count_hash_records(db_file);
CREATE(world, struct room_data, rec_count);
rewind(db_file);
discrete_load(db_file);
}
void discrete_load(FILE * fl)
{
int nr = -1, last = 0;
char line[256];
for (;;) {
if (!get_line(fl, line)) {
fprintf(stderr, "Format error after room #%d\n", nr);
exit(1);
}
if (*line == '$')
return;
if (*line == '#') {
last = nr;
if (sscanf(line, "#%d", &nr) != 1) {
fprintf(stderr, "Format error after room #%d\n", last);
exit(1);
}
if (nr >= 99999)
return;
else
parse_room(fl, nr);
} else {
fprintf(stderr, "Format error in world file near room #%d\n", nr);
fprintf(stderr, "Offending line: '%s'\n", line);
exit(1);
}
}
}
long asciiflag_conv(char *flag)
{
long flags = 0;
int is_number = 1;
register char *p;
for (p = flag; *p; p++) {
if (islower(*p))
flags |= 1 << (*p - 'a');
else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A'));
if (!isdigit(*p))
is_number = 0;
}
if (is_number)
flags = atol(flag);
return (flags);
}
/* load the rooms */
void parse_room(FILE * fl, int virtual_nr)
{
static int room_nr = 0, zone = 0;
int t[10], i;
char line[256], flags[128];
struct extra_descr_data *new_descr;
sprintf(buf2, "room #%d", virtual_nr);
world[room_nr].zone = zone;
world[room_nr].number = virtual_nr;
world[room_nr].name = fread_string(fl, buf2);
world[room_nr].description = fread_string(fl, buf2);
if (!get_line(fl, line) || sscanf(line, " %d %s %d ", t, flags, t + 2) != 3) {
fprintf(stderr, "Format error in room #%d\n", virtual_nr);
exit(1);
}
/* t[0] is the zone number; ignored with the zone-file system */
world[room_nr].room_flags = asciiflag_conv(flags);
world[room_nr].sector_type = t[2];
world[room_nr].light = 0; /* Zero light sources */
for (i = 0; i < NUM_OF_DIRS; i++)
world[room_nr].dir_option[i] = NULL;
world[room_nr].ex_description = NULL;
sprintf(buf, "Format error in room #%d (expecting D/E/S)", virtual_nr);
for (;;) {
if (!get_line(fl, line)) {
fprintf(stderr, "%s\n", buf);
exit(1);
}
switch (*line) {
case 'D':
setup_dir(fl, room_nr, atoi(line + 1));
break;
case 'E':
CREATE(new_descr, struct extra_descr_data, 1);
new_descr->keyword = fread_string(fl, buf2);
new_descr->description = fread_string(fl, buf2);
new_descr->next = world[room_nr].ex_description;
world[room_nr].ex_description = new_descr;
break;
case 'S': /* end of room */
top_of_world = room_nr++;
return;
break;
default:
fprintf(stderr, "%s\n", buf);
exit(1);
break;
}
}
}
/* read direction data */
void setup_dir(FILE * fl, int room, int dir)
{
int t[5];
char line[256];
sprintf(buf2, "room #%d, direction D%d", world[room].number, dir);
CREATE(world[room].dir_option[dir], struct room_direction_data, 1);
world[room].dir_option[dir]->general_description = fread_string(fl, buf2);
world[room].dir_option[dir]->keyword = fread_string(fl, buf2);
if (!get_line(fl, line)) {
fprintf(stderr, "Format error, %s\n", buf2);
exit(1);
}
if (sscanf(line, " %d %d %d ", t, t + 1, t + 2) != 3) {
fprintf(stderr, "Format error, %s\n", buf2);
exit(1);
}
if (t[0] == 1)
world[room].dir_option[dir]->exit_info = EX_ISDOOR;
else if (t[0] == 2)
world[room].dir_option[dir]->exit_info = EX_ISDOOR | EX_PICKPROOF;
else
world[room].dir_option[dir]->exit_info = 0;
world[room].dir_option[dir]->key = t[1];
world[room].dir_option[dir]->to_room = t[2];
}
/* resolve all vnums into rnums in the world */
void renum_world(void)
{
register int room, door;
for (room = 0; room <= top_of_world; room++)
for (door = 0; door < NUM_OF_DIRS; door++)
if (world[room].dir_option[door])
if (world[room].dir_option[door]->to_room != NOWHERE)
world[room].dir_option[door]->to_room =
real_room(world[room].dir_option[door]->to_room,
world[room].number);
}
/*************************************************************************
* procedures for resetting, both play-time and boot-time *
*********************************************************************** */
/* read and allocate space for a '~'-terminated string from a given file */
char *fread_string(FILE * fl, char *error)
{
char buf[MAX_STRING_LENGTH], tmp[512], *rslt;
register char *point;
int done = 0, length = 0, templength = 0;
*buf = '\0';
do {
if (!fgets(tmp, 512, fl)) {
fprintf(stderr, "SYSERR: fread_string: format error at or near %s\n",
error);
exit(1);
}
/* If there is a '~', end the string; else put an "\r\n" over the '\n'. */
if ((point = strchr(tmp, '~')) != NULL) {
*point = '\0';
done = 1;
} else {
point = tmp + strlen(tmp) - 1;
*(point++) = '\r';
*(point++) = '\n';
*point = '\0';
}
templength = strlen(tmp);
if (length + templength >= MAX_STRING_LENGTH) {
log("SYSERR: fread_string: string too large (db.c)");
log(error);
exit(1);
} else {
strcat(buf + length, tmp);
length += templength;
}
} while (!done);
/* allocate space for the new string and copy it */
if (strlen(buf) > 0) {
CREATE(rslt, char, length + 1);
strcpy(rslt, buf);
} else
rslt = NULL;
return (rslt);
}
/* returns the real number of the room with given virtual number */
int real_room(int virtual, int reference)
{
int bot, top, mid;
bot = 0;
top = top_of_world;
/* perform binary search on world-table */
for (;;) {
mid = (bot + top) / 2;
if ((world + mid)->number == virtual)
return (mid);
if (bot >= top) {
fprintf(stderr, "Room %d does not exist in database (referenced in room %d)\n", virtual, reference);
return (-1);
}
if ((world + mid)->number > virtual)
top = mid - 1;
else
bot = mid + 1;
}
}
/* get_line reads the next non-blank line off of the input stream.
* The newline character is removed from the input. Lines which begin
* with '*' are considered to be comments.
*/
int get_line(FILE * fl, char *buf)
{
char temp[256];
do {
fgets(temp, 256, fl);
if (*temp)
temp[strlen(temp) - 1] = '\0';
} while (!feof(fl) && (*temp == '*' || !*temp));
if (feof(fl))
return (0);
else {
strcpy(buf, temp);
return (1);
}
}

684
old-codebase/src/utils.c Normal file
View File

@@ -0,0 +1,684 @@
/* ************************************************************************
* File: utils.c Part of CircleMUD *
* Usage: various internal functions of a utility 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 "db.h"
#include "comm.h"
#include "screen.h"
#include "spells.h"
#include "handler.h"
#include "interpreter.h"
/* external globals */
extern struct time_data time_info;
/* local functions */
struct time_info_data *real_time_passed(time_t t2, time_t t1);
struct time_info_data *mud_time_passed(time_t t2, time_t t1);
void prune_crlf(char *txt);
/* creates a random number in interval [from;to] */
int rand_number(int from, int to)
{
/* error checking in case people call this incorrectly */
if (from > to) {
int tmp = from;
from = to;
to = tmp;
log("SYSERR: rand_number() should be called with lowest, then highest. (%d, %d), not (%d, %d).", from, to, to, from);
}
/*
* This should always be of the form:
*
* ((float)(to - from + 1) * rand() / (float)(RAND_MAX + from) + from);
*
* if you are using rand() due to historical non-randomness of the
* lower bits in older implementations. We always use circle_random()
* though, which shouldn't have that problem. Mean and standard
* deviation of both are identical (within the realm of statistical
* identity) if the rand() implementation is non-broken.
*/
return ((circle_random() % (to - from + 1)) + from);
}
/* simulates dice roll */
int dice(int num, int size)
{
int sum = 0;
if (size <= 0 || num <= 0)
return (0);
while (num-- > 0)
sum += rand_number(1, size);
return (sum);
}
/* Be wary of sign issues with this. */
int MIN(int a, int b)
{
return (a < b ? a : b);
}
/* Be wary of sign issues with this. */
int MAX(int a, int b)
{
return (a > b ? a : b);
}
char *CAP(char *txt)
{
*txt = UPPER(*txt);
return (txt);
}
#if !defined(HAVE_STRLCPY)
/*
* A 'strlcpy' function in the same fashion as 'strdup' below.
*
* This copies up to totalsize - 1 bytes from the source string, placing
* them and a trailing NUL into the destination string.
*
* Returns the total length of the string it tried to copy, not including
* the trailing NUL. So a '>= totalsize' test says it was truncated.
* (Note that you may have _expected_ truncation because you only wanted
* a few characters from the source string.)
*/
size_t strlcpy(char *dest, const char *source, size_t totalsize)
{
strncpy(dest, source, totalsize - 1); /* strncpy: OK (we must assume 'totalsize' is correct) */
dest[totalsize - 1] = '\0';
return strlen(source);
}
#endif
#if !defined(HAVE_STRDUP)
/* Create a duplicate of a string */
char *strdup(const char *source)
{
char *new_z;
CREATE(new_z, char, strlen(source) + 1);
return (strcpy(new_z, source)); /* strcpy: OK */
}
#endif
/*
* Strips \r\n from end of string.
*/
void prune_crlf(char *txt)
{
int i = strlen(txt) - 1;
while (txt[i] == '\n' || txt[i] == '\r')
txt[i--] = '\0';
}
#ifndef str_cmp
/*
* str_cmp: a case-insensitive version of strcmp().
* Returns: 0 if equal, > 0 if arg1 > arg2, or < 0 if arg1 < arg2.
*
* Scan until strings are found different or we reach the end of both.
*/
int str_cmp(const char *arg1, const char *arg2)
{
int chk, i;
if (arg1 == NULL || arg2 == NULL) {
log("SYSERR: str_cmp() passed a NULL pointer, %p or %p.", arg1, arg2);
return (0);
}
for (i = 0; arg1[i] || arg2[i]; i++)
if ((chk = LOWER(arg1[i]) - LOWER(arg2[i])) != 0)
return (chk); /* not equal */
return (0);
}
#endif
#ifndef strn_cmp
/*
* strn_cmp: a case-insensitive version of strncmp().
* Returns: 0 if equal, > 0 if arg1 > arg2, or < 0 if arg1 < arg2.
*
* Scan until strings are found different, the end of both, or n is reached.
*/
int strn_cmp(const char *arg1, const char *arg2, int n)
{
int chk, i;
if (arg1 == NULL || arg2 == NULL) {
log("SYSERR: strn_cmp() passed a NULL pointer, %p or %p.", arg1, arg2);
return (0);
}
for (i = 0; (arg1[i] || arg2[i]) && (n > 0); i++, n--)
if ((chk = LOWER(arg1[i]) - LOWER(arg2[i])) != 0)
return (chk); /* not equal */
return (0);
}
#endif
/* log a death trap hit */
void log_death_trap(struct char_data *ch)
{
mudlog(BRF, LVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(IN_ROOM(ch)), world[IN_ROOM(ch)].name);
}
/*
* New variable argument log() function. Works the same as the old for
* previously written code but is very nice for new code.
*/
void basic_mud_vlog(const char *format, va_list args)
{
time_t ct = time(0);
char *time_s = asctime(localtime(&ct));
if (logfile == NULL) {
puts("SYSERR: Using log() before stream was initialized!");
return;
}
if (format == NULL)
format = "SYSERR: log() received a NULL format.";
time_s[strlen(time_s) - 1] = '\0';
fprintf(logfile, "%-15.15s :: ", time_s + 4);
vfprintf(logfile, format, args);
fputc('\n', logfile);
fflush(logfile);
}
/* So mudlog() can use the same function. */
void basic_mud_log(const char *format, ...)
{
va_list args;
va_start(args, format);
basic_mud_vlog(format, args);
va_end(args);
}
/* the "touch" command, essentially. */
int touch(const char *path)
{
FILE *fl;
if (!(fl = fopen(path, "a"))) {
log("SYSERR: %s: %s", path, strerror(errno));
return (-1);
} else {
fclose(fl);
return (0);
}
}
/*
* mudlog -- log mud messages to a file & to online imm's syslogs
* based on syslog by Fen Jul 3, 1992
*/
void mudlog(int type, int level, int file, const char *str, ...)
{
char buf[MAX_STRING_LENGTH];
struct descriptor_data *i;
va_list args;
if (str == NULL)
return; /* eh, oh well. */
if (file) {
va_start(args, str);
basic_mud_vlog(str, args);
va_end(args);
}
if (level < 0)
return;
strcpy(buf, "[ "); /* strcpy: OK */
va_start(args, str);
vsnprintf(buf + 2, sizeof(buf) - 6, str, args);
va_end(args);
strcat(buf, " ]\r\n"); /* strcat: OK */
for (i = descriptor_list; i; i = i->next) {
if (STATE(i) != CON_PLAYING || IS_NPC(i->character)) /* switch */
continue;
if (GET_LEVEL(i->character) < level)
continue;
if (PLR_FLAGGED(i->character, PLR_WRITING))
continue;
if (type > (PRF_FLAGGED(i->character, PRF_LOG1) ? 1 : 0) + (PRF_FLAGGED(i->character, PRF_LOG2) ? 2 : 0))
continue;
send_to_char(i->character, "%s%s%s", CCGRN(i->character, C_NRM), buf, CCNRM(i->character, C_NRM));
}
}
/*
* If you don't have a 'const' array, just cast it as such. It's safer
* to cast a non-const array as const than to cast a const one as non-const.
* Doesn't really matter since this function doesn't change the array though.
*/
size_t sprintbit(bitvector_t bitvector, const char *names[], char *result, size_t reslen)
{
size_t len = 0;
int nlen;
long nr;
*result = '\0';
for (nr = 0; bitvector && len < reslen; bitvector >>= 1) {
if (IS_SET(bitvector, 1)) {
nlen = snprintf(result + len, reslen - len, "%s ", *names[nr] != '\n' ? names[nr] : "UNDEFINED");
if (len + nlen >= reslen || nlen < 0)
break;
len += nlen;
}
if (*names[nr] != '\n')
nr++;
}
if (!*result)
len = strlcpy(result, "NOBITS ", reslen);
return (len);
}
size_t sprinttype(int type, const char *names[], char *result, size_t reslen)
{
int nr = 0;
while (type && *names[nr] != '\n') {
type--;
nr++;
}
return strlcpy(result, *names[nr] != '\n' ? names[nr] : "UNDEFINED", reslen);
}
/* Calculate the REAL time passed over the last t2-t1 centuries (secs) */
struct time_info_data *real_time_passed(time_t t2, time_t t1)
{
long secs;
static struct time_info_data now;
secs = t2 - t1;
now.hours = (secs / SECS_PER_REAL_HOUR) % 24; /* 0..23 hours */
secs -= SECS_PER_REAL_HOUR * now.hours;
now.day = (secs / SECS_PER_REAL_DAY); /* 0..34 days */
/* secs -= SECS_PER_REAL_DAY * now.day; - Not used. */
now.month = -1;
now.year = -1;
return (&now);
}
/* Calculate the MUD time passed over the last t2-t1 centuries (secs) */
struct time_info_data *mud_time_passed(time_t t2, time_t t1)
{
long secs;
static struct time_info_data now;
secs = t2 - t1;
now.hours = (secs / SECS_PER_MUD_HOUR) % 24; /* 0..23 hours */
secs -= SECS_PER_MUD_HOUR * now.hours;
now.day = (secs / SECS_PER_MUD_DAY) % 35; /* 0..34 days */
secs -= SECS_PER_MUD_DAY * now.day;
now.month = (secs / SECS_PER_MUD_MONTH) % 17; /* 0..16 months */
secs -= SECS_PER_MUD_MONTH * now.month;
now.year = (secs / SECS_PER_MUD_YEAR); /* 0..XX? years */
return (&now);
}
time_t mud_time_to_secs(struct time_info_data *now)
{
time_t when = 0;
when += now->year * SECS_PER_MUD_YEAR;
when += now->month * SECS_PER_MUD_MONTH;
when += now->day * SECS_PER_MUD_DAY;
when += now->hours * SECS_PER_MUD_HOUR;
return (time(NULL) - when);
}
struct time_info_data *age(struct char_data *ch)
{
static struct time_info_data player_age;
player_age = *mud_time_passed(time(0), ch->player.time.birth);
player_age.year += 17; /* All players start at 17 */
return (&player_age);
}
/* Check if making CH follow VICTIM will create an illegal */
/* Follow "Loop/circle" */
bool circle_follow(struct char_data *ch, struct char_data *victim)
{
struct char_data *k;
for (k = victim; k; k = k->master) {
if (k == ch)
return (TRUE);
}
return (FALSE);
}
/* Called when stop following persons, or stopping charm */
/* This will NOT do if a character quits/dies!! */
void stop_follower(struct char_data *ch)
{
struct follow_type *j, *k;
if (ch->master == NULL) {
core_dump();
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM)) {
act("You realize that $N is a jerk!", FALSE, ch, 0, ch->master, TO_CHAR);
act("$n realizes that $N is a jerk!", FALSE, ch, 0, ch->master, TO_NOTVICT);
act("$n hates your guts!", FALSE, ch, 0, ch->master, TO_VICT);
if (affected_by_spell(ch, SPELL_CHARM))
affect_from_char(ch, SPELL_CHARM);
} else {
act("You stop following $N.", FALSE, ch, 0, ch->master, TO_CHAR);
act("$n stops following $N.", TRUE, ch, 0, ch->master, TO_NOTVICT);
act("$n stops following you.", TRUE, ch, 0, ch->master, TO_VICT);
}
if (ch->master->followers->follower == ch) { /* Head of follower-list? */
k = ch->master->followers;
ch->master->followers = k->next;
free(k);
} else { /* locate follower who is not head of list */
for (k = ch->master->followers; k->next->follower != ch; k = k->next);
j = k->next;
k->next = j->next;
free(j);
}
ch->master = NULL;
REMOVE_BIT(AFF_FLAGS(ch), AFF_CHARM | AFF_GROUP);
}
int num_followers_charmed(struct char_data *ch)
{
struct follow_type *lackey;
int total = 0;
for (lackey = ch->followers; lackey; lackey = lackey->next)
if (AFF_FLAGGED(lackey->follower, AFF_CHARM) && lackey->follower->master == ch)
total++;
return (total);
}
/* Called when a character that follows/is followed dies */
void die_follower(struct char_data *ch)
{
struct follow_type *j, *k;
if (ch->master)
stop_follower(ch);
for (k = ch->followers; k; k = j) {
j = k->next;
stop_follower(k->follower);
}
}
/* Do NOT call this before having checked if a circle of followers */
/* will arise. CH will follow leader */
void add_follower(struct char_data *ch, struct char_data *leader)
{
struct follow_type *k;
if (ch->master) {
core_dump();
return;
}
ch->master = leader;
CREATE(k, struct follow_type, 1);
k->follower = ch;
k->next = leader->followers;
leader->followers = k;
act("You now follow $N.", FALSE, ch, 0, leader, TO_CHAR);
if (CAN_SEE(leader, ch))
act("$n starts following you.", TRUE, ch, 0, leader, TO_VICT);
act("$n starts to follow $N.", TRUE, ch, 0, leader, TO_NOTVICT);
}
/*
* get_line reads the next non-blank line off of the input stream.
* The newline character is removed from the input. Lines which begin
* with '*' are considered to be comments.
*
* Returns the number of lines advanced in the file. Buffer given must
* be at least READ_SIZE (256) characters large.
*/
int get_line(FILE *fl, char *buf)
{
char temp[READ_SIZE];
int lines = 0;
int sl;
do {
if (!fgets(temp, READ_SIZE, fl))
return (0);
lines++;
} while (*temp == '*' || *temp == '\n' || *temp == '\r');
/* Last line of file doesn't always have a \n, but it should. */
sl = strlen(temp);
while (sl > 0 && (temp[sl - 1] == '\n' || temp[sl - 1] == '\r'))
temp[--sl] = '\0';
strcpy(buf, temp); /* strcpy: OK, if buf >= READ_SIZE (256) */
return (lines);
}
int get_filename(char *filename, size_t fbufsize, int mode, const char *orig_name)
{
const char *prefix, *middle, *suffix;
char name[PATH_MAX], *ptr;
if (orig_name == NULL || *orig_name == '\0' || filename == NULL) {
log("SYSERR: NULL pointer or empty string passed to get_filename(), %p or %p.",
orig_name, filename);
return (0);
}
switch (mode) {
case CRASH_FILE:
prefix = LIB_PLROBJS;
suffix = SUF_OBJS;
break;
case ALIAS_FILE:
prefix = LIB_PLRALIAS;
suffix = SUF_ALIAS;
break;
case ETEXT_FILE:
prefix = LIB_PLRTEXT;
suffix = SUF_TEXT;
break;
default:
return (0);
}
strlcpy(name, orig_name, sizeof(name));
for (ptr = name; *ptr; ptr++)
*ptr = LOWER(*ptr);
switch (LOWER(*name)) {
case 'a': case 'b': case 'c': case 'd': case 'e':
middle = "A-E";
break;
case 'f': case 'g': case 'h': case 'i': case 'j':
middle = "F-J";
break;
case 'k': case 'l': case 'm': case 'n': case 'o':
middle = "K-O";
break;
case 'p': case 'q': case 'r': case 's': case 't':
middle = "P-T";
break;
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
middle = "U-Z";
break;
default:
middle = "ZZZ";
break;
}
snprintf(filename, fbufsize, "%s%s"SLASH"%s.%s", prefix, middle, name, suffix);
return (1);
}
int num_pc_in_room(struct room_data *room)
{
int i = 0;
struct char_data *ch;
for (ch = room->people; ch != NULL; ch = ch->next_in_room)
if (!IS_NPC(ch))
i++;
return (i);
}
/*
* This function (derived from basic fork(); abort(); idea by Erwin S.
* Andreasen) causes your MUD to dump core (assuming you can) but
* continue running. The core dump will allow post-mortem debugging
* that is less severe than assert(); Don't call this directly as
* core_dump_unix() but as simply 'core_dump()' so that it will be
* excluded from systems not supporting them. (e.g. Windows '95).
*
* You still want to call abort() or exit(1) for
* non-recoverable errors, of course...
*
* XXX: Wonder if flushing streams includes sockets?
*/
extern FILE *player_fl;
void core_dump_real(const char *who, int line)
{
log("SYSERR: Assertion failed at %s:%d!", who, line);
#if 0 /* By default, let's not litter. */
#if defined(CIRCLE_UNIX)
/* These would be duplicated otherwise...make very sure. */
fflush(stdout);
fflush(stderr);
fflush(logfile);
fflush(player_fl);
/* Everything, just in case, for the systems that support it. */
fflush(NULL);
/*
* Kill the child so the debugger or script doesn't think the MUD
* crashed. The 'autorun' script would otherwise run it again.
*/
if (fork() == 0)
abort();
#endif
#endif
}
/*
* Rules (unless overridden by ROOM_DARK):
*
* Inside and City rooms are always lit.
* Outside rooms are dark at sunset and night.
*/
int room_is_dark(room_rnum room)
{
if (!VALID_ROOM_RNUM(room)) {
log("room_is_dark: Invalid room rnum %d. (0-%d)", room, top_of_world);
return (FALSE);
}
if (world[room].light)
return (FALSE);
if (ROOM_FLAGGED(room, ROOM_DARK))
return (TRUE);
if (SECT(room) == SECT_INSIDE || SECT(room) == SECT_CITY)
return (FALSE);
if (weather_info.sunlight == SUN_SET || weather_info.sunlight == SUN_DARK)
return (TRUE);
return (FALSE);
}

535
old-codebase/src/utils.h Normal file
View File

@@ -0,0 +1,535 @@
/* ************************************************************************
* File: utils.h Part of CircleMUD *
* Usage: header file: utility macros and prototypes of utility funcs *
* *
* 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. *
************************************************************************ */
/* external declarations and prototypes **********************************/
extern struct weather_data weather_info;
extern FILE *logfile;
#define log basic_mud_log
#define READ_SIZE 256
/* public functions in utils.c */
void basic_mud_log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
void basic_mud_vlog(const char *format, va_list args);
int touch(const char *path);
void mudlog(int type, int level, int file, const char *str, ...) __attribute__ ((format (printf, 4, 5)));
void log_death_trap(struct char_data *ch);
int rand_number(int from, int to);
int dice(int number, int size);
size_t sprintbit(bitvector_t vektor, const char *names[], char *result, size_t reslen);
size_t sprinttype(int type, const char *names[], char *result, size_t reslen);
int get_line(FILE *fl, char *buf);
int get_filename(char *filename, size_t fbufsize, int mode, const char *orig_name);
time_t mud_time_to_secs(struct time_info_data *now);
struct time_info_data *age(struct char_data *ch);
int num_pc_in_room(struct room_data *room);
void core_dump_real(const char *who, int line);
int room_is_dark(room_rnum room);
#define core_dump() core_dump_real(__FILE__, __LINE__)
/*
* Only provide our versions if one isn't in the C library. These macro names
* will be defined by sysdep.h if a strcasecmp or stricmp exists.
*/
#ifndef str_cmp
int str_cmp(const char *arg1, const char *arg2);
#endif
#ifndef strn_cmp
int strn_cmp(const char *arg1, const char *arg2, int n);
#endif
/* random functions in random.c */
void circle_srandom(unsigned long initial_seed);
unsigned long circle_random(void);
/* undefine MAX and MIN so that our functions are used instead */
#ifdef MAX
#undef MAX
#endif
#ifdef MIN
#undef MIN
#endif
int MAX(int a, int b);
int MIN(int a, int b);
char *CAP(char *txt);
/* Followers */
int num_followers_charmed(struct char_data *ch);
void die_follower(struct char_data *ch);
void add_follower(struct char_data *ch, struct char_data *leader);
void stop_follower(struct char_data *ch);
bool circle_follow(struct char_data *ch, struct char_data *victim);
/* in act.informative.c */
void look_at_room(struct char_data *ch, int mode);
/* in act.movmement.c */
int do_simple_move(struct char_data *ch, int dir, int following);
int perform_move(struct char_data *ch, int dir, int following);
/* in limits.c */
int mana_gain(struct char_data *ch);
int hit_gain(struct char_data *ch);
int move_gain(struct char_data *ch);
void advance_level(struct char_data *ch);
void set_title(struct char_data *ch, char *title);
void gain_exp(struct char_data *ch, int gain);
void gain_exp_regardless(struct char_data *ch, int gain);
void gain_condition(struct char_data *ch, int condition, int value);
void check_idling(struct char_data *ch);
void point_update(void);
void update_pos(struct char_data *victim);
/* various constants *****************************************************/
/* defines for mudlog() */
#define OFF 0
#define BRF 1
#define NRM 2
#define CMP 3
/* get_filename() */
#define CRASH_FILE 0
#define ETEXT_FILE 1
#define ALIAS_FILE 2
/* breadth-first searching */
#define BFS_ERROR (-1)
#define BFS_ALREADY_THERE (-2)
#define BFS_NO_PATH (-3)
/*
* XXX: These constants should be configurable. See act.informative.c
* and utils.c for other places to change.
*/
/* mud-life time */
#define SECS_PER_MUD_HOUR 75
#define SECS_PER_MUD_DAY (24*SECS_PER_MUD_HOUR)
#define SECS_PER_MUD_MONTH (35*SECS_PER_MUD_DAY)
#define SECS_PER_MUD_YEAR (17*SECS_PER_MUD_MONTH)
/* real-life time (remember Real Life?) */
#define SECS_PER_REAL_MIN 60
#define SECS_PER_REAL_HOUR (60*SECS_PER_REAL_MIN)
#define SECS_PER_REAL_DAY (24*SECS_PER_REAL_HOUR)
#define SECS_PER_REAL_YEAR (365*SECS_PER_REAL_DAY)
/* string utils **********************************************************/
#define YESNO(a) ((a) ? "YES" : "NO")
#define ONOFF(a) ((a) ? "ON" : "OFF")
#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c) )
#define ISNEWL(ch) ((ch) == '\n' || (ch) == '\r')
/* See also: ANA, SANA */
#define AN(string) (strchr("aeiouAEIOU", *string) ? "an" : "a")
/* memory utils **********************************************************/
#define CREATE(result, type, number) do {\
if ((number) * sizeof(type) <= 0) \
log("SYSERR: Zero bytes or less requested at %s:%d.", __FILE__, __LINE__); \
if (!((result) = (type *) calloc ((number), sizeof(type)))) \
{ perror("SYSERR: malloc failure"); abort(); } } while(0)
#define RECREATE(result,type,number) do {\
if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\
{ perror("SYSERR: realloc failure"); abort(); } } while(0)
/*
* the source previously used the same code in many places to remove an item
* from a list: if it's the list head, change the head, else traverse the
* list looking for the item before the one to be removed. Now, we have a
* macro to do this. To use, just make sure that there is a variable 'temp'
* declared as the same type as the list to be manipulated. BTW, this is
* a great application for C++ templates but, alas, this is not C++. Maybe
* CircleMUD 4.0 will be...
*/
#define REMOVE_FROM_LIST(item, head, next) \
if ((item) == (head)) \
head = (item)->next; \
else { \
temp = head; \
while (temp && (temp->next != (item))) \
temp = temp->next; \
if (temp) \
temp->next = (item)->next; \
} \
/* basic bitvector utils *************************************************/
#define IS_SET(flag,bit) ((flag) & (bit))
#define SET_BIT(var,bit) ((var) |= (bit))
#define REMOVE_BIT(var,bit) ((var) &= ~(bit))
#define TOGGLE_BIT(var,bit) ((var) ^= (bit))
/*
* Accessing player specific data structures on a mobile is a very bad thing
* to do. Consider that changing these variables for a single mob will change
* it for every other single mob in the game. If we didn't specifically check
* for it, 'wimpy' would be an extremely bad thing for a mob to do, as an
* example. If you really couldn't care less, change this to a '#if 0'.
*/
#if 1
/* Subtle bug in the '#var', but works well for now. */
#define CHECK_PLAYER_SPECIAL(ch, var) \
(*(((ch)->player_specials == &dummy_mob) ? (log("SYSERR: Mob using '"#var"' at %s:%d.", __FILE__, __LINE__), &(var)) : &(var)))
#else
#define CHECK_PLAYER_SPECIAL(ch, var) (var)
#endif
#define MOB_FLAGS(ch) ((ch)->char_specials.saved.act)
#define PLR_FLAGS(ch) ((ch)->char_specials.saved.act)
#define PRF_FLAGS(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.pref))
#define AFF_FLAGS(ch) ((ch)->char_specials.saved.affected_by)
#define ROOM_FLAGS(loc) (world[(loc)].room_flags)
#define SPELL_ROUTINES(spl) (spell_info[spl].routines)
/*
* See http://www.circlemud.org/~greerga/todo/todo.009 to eliminate MOB_ISNPC.
* IS_MOB() acts as a VALID_MOB_RNUM()-like function.
*/
#define IS_NPC(ch) (IS_SET(MOB_FLAGS(ch), MOB_ISNPC))
#define IS_MOB(ch) (IS_NPC(ch) && GET_MOB_RNUM(ch) <= top_of_mobt && \
GET_MOB_RNUM(ch) != NOBODY)
#define MOB_FLAGGED(ch, flag) (IS_NPC(ch) && IS_SET(MOB_FLAGS(ch), (flag)))
#define PLR_FLAGGED(ch, flag) (!IS_NPC(ch) && IS_SET(PLR_FLAGS(ch), (flag)))
#define AFF_FLAGGED(ch, flag) (IS_SET(AFF_FLAGS(ch), (flag)))
#define PRF_FLAGGED(ch, flag) (IS_SET(PRF_FLAGS(ch), (flag)))
#define ROOM_FLAGGED(loc, flag) (IS_SET(ROOM_FLAGS(loc), (flag)))
#define EXIT_FLAGGED(exit, flag) (IS_SET((exit)->exit_info, (flag)))
#define OBJAFF_FLAGGED(obj, flag) (IS_SET(GET_OBJ_AFFECT(obj), (flag)))
#define OBJVAL_FLAGGED(obj, flag) (IS_SET(GET_OBJ_VAL((obj), 1), (flag)))
#define OBJWEAR_FLAGGED(obj, flag) (IS_SET(GET_OBJ_WEAR(obj), (flag)))
#define OBJ_FLAGGED(obj, flag) (IS_SET(GET_OBJ_EXTRA(obj), (flag)))
#define HAS_SPELL_ROUTINE(spl, flag) (IS_SET(SPELL_ROUTINES(spl), (flag)))
/* IS_AFFECTED for backwards compatibility */
#define IS_AFFECTED(ch, skill) (AFF_FLAGGED((ch), (skill)))
#define PLR_TOG_CHK(ch,flag) ((TOGGLE_BIT(PLR_FLAGS(ch), (flag))) & (flag))
#define PRF_TOG_CHK(ch,flag) ((TOGGLE_BIT(PRF_FLAGS(ch), (flag))) & (flag))
/* room utils ************************************************************/
#define SECT(room) (VALID_ROOM_RNUM(room) ? \
world[(room)].sector_type : SECT_INSIDE)
#define IS_DARK(room) room_is_dark((room))
#define IS_LIGHT(room) (!IS_DARK(room))
#define VALID_ROOM_RNUM(rnum) ((rnum) != NOWHERE && (rnum) <= top_of_world)
#define GET_ROOM_VNUM(rnum) \
((room_vnum)(VALID_ROOM_RNUM(rnum) ? world[(rnum)].number : NOWHERE))
#define GET_ROOM_SPEC(room) \
(VALID_ROOM_RNUM(room) ? world[(room)].func : NULL)
/* char utils ************************************************************/
#define IN_ROOM(ch) ((ch)->in_room)
#define GET_WAS_IN(ch) ((ch)->was_in_room)
#define GET_AGE(ch) (age(ch)->year)
#define GET_PC_NAME(ch) ((ch)->player.name)
#define GET_NAME(ch) (IS_NPC(ch) ? \
(ch)->player.short_descr : GET_PC_NAME(ch))
#define GET_TITLE(ch) ((ch)->player.title)
#define GET_LEVEL(ch) ((ch)->player.level)
#define GET_PASSWD(ch) ((ch)->player.passwd)
#define GET_PFILEPOS(ch)((ch)->pfilepos)
/*
* I wonder if this definition of GET_REAL_LEVEL should be the definition
* of GET_LEVEL? JE
*/
#define GET_REAL_LEVEL(ch) \
(ch->desc && ch->desc->original ? GET_LEVEL(ch->desc->original) : \
GET_LEVEL(ch))
#define GET_CLASS(ch) ((ch)->player.chclass)
#define GET_RACE(ch) ((ch)->player.race)
#define GET_HOME(ch) ((ch)->player.hometown)
#define GET_HEIGHT(ch) ((ch)->player.height)
#define GET_WEIGHT(ch) ((ch)->player.weight)
#define GET_SEX(ch) ((ch)->player.sex)
#define GET_STR(ch) ((ch)->aff_abils.str)
#define GET_ADD(ch) ((ch)->aff_abils.str_add)
#define GET_DEX(ch) ((ch)->aff_abils.dex)
#define GET_INT(ch) ((ch)->aff_abils.intel)
#define GET_WIS(ch) ((ch)->aff_abils.wis)
#define GET_CON(ch) ((ch)->aff_abils.con)
#define GET_CHA(ch) ((ch)->aff_abils.cha)
#define GET_EXP(ch) ((ch)->points.exp)
#define GET_AC(ch) ((ch)->points.armor)
#define GET_HIT(ch) ((ch)->points.hit)
#define GET_MAX_HIT(ch) ((ch)->points.max_hit)
#define GET_MOVE(ch) ((ch)->points.move)
#define GET_MAX_MOVE(ch) ((ch)->points.max_move)
#define GET_MANA(ch) ((ch)->points.mana)
#define GET_MAX_MANA(ch) ((ch)->points.max_mana)
#define GET_GOLD(ch) ((ch)->points.gold)
#define GET_BANK_GOLD(ch) ((ch)->points.bank_gold)
#define GET_HITROLL(ch) ((ch)->points.hitroll)
#define GET_DAMROLL(ch) ((ch)->points.damroll)
#define GET_POS(ch) ((ch)->char_specials.position)
#define GET_IDNUM(ch) ((ch)->char_specials.saved.idnum)
#define IS_CARRYING_W(ch) ((ch)->char_specials.carry_weight)
#define IS_CARRYING_N(ch) ((ch)->char_specials.carry_items)
#define FIGHTING(ch) ((ch)->char_specials.fighting)
#define HUNTING(ch) ((ch)->char_specials.hunting)
#define GET_SAVE(ch, i) ((ch)->char_specials.saved.apply_saving_throw[i])
#define GET_ALIGNMENT(ch) ((ch)->char_specials.saved.alignment)
#define GET_COND(ch, i) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.conditions[(i)]))
#define GET_LOADROOM(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.load_room))
#define GET_PRACTICES(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.spells_to_learn))
#define GET_INVIS_LEV(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.invis_level))
#define GET_WIMP_LEV(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.wimp_level))
#define GET_FREEZE_LEV(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.freeze_level))
#define GET_BAD_PWS(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.bad_pws))
#define GET_TALK(ch, i) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.talks[i]))
#define POOFIN(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->poofin))
#define POOFOUT(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->poofout))
#define GET_LAST_OLC_TARG(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->last_olc_targ))
#define GET_LAST_OLC_MODE(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->last_olc_mode))
#define GET_ALIASES(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->aliases))
#define GET_LAST_TELL(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->last_tell))
#define GET_SKILL(ch, i) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.skills[i]))
#define SET_SKILL(ch, i, pct) do { CHECK_PLAYER_SPECIAL((ch), (ch)->player_specials->saved.skills[i]) = pct; } while(0)
#define GET_EQ(ch, i) ((ch)->equipment[i])
#define GET_MOB_SPEC(ch) (IS_MOB(ch) ? mob_index[(ch)->nr].func : NULL)
#define GET_MOB_RNUM(mob) ((mob)->nr)
#define GET_MOB_VNUM(mob) (IS_MOB(mob) ? \
mob_index[GET_MOB_RNUM(mob)].vnum : NOBODY)
#define GET_DEFAULT_POS(ch) ((ch)->mob_specials.default_pos)
#define MEMORY(ch) ((ch)->mob_specials.memory)
#define STRENGTH_APPLY_INDEX(ch) \
( ((GET_ADD(ch)==0) || (GET_STR(ch) != 18)) ? GET_STR(ch) :\
(GET_ADD(ch) <= 50) ? 26 :( \
(GET_ADD(ch) <= 75) ? 27 :( \
(GET_ADD(ch) <= 90) ? 28 :( \
(GET_ADD(ch) <= 99) ? 29 : 30 ) ) ) \
)
#define CAN_CARRY_W(ch) (str_app[STRENGTH_APPLY_INDEX(ch)].carry_w)
#define CAN_CARRY_N(ch) (5 + (GET_DEX(ch) >> 1) + (GET_LEVEL(ch) >> 1))
#define AWAKE(ch) (GET_POS(ch) > POS_SLEEPING)
#define CAN_SEE_IN_DARK(ch) \
(AFF_FLAGGED(ch, AFF_INFRAVISION) || (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_HOLYLIGHT)))
#define IS_GOOD(ch) (GET_ALIGNMENT(ch) >= 350)
#define IS_EVIL(ch) (GET_ALIGNMENT(ch) <= -350)
#define IS_NEUTRAL(ch) (!IS_GOOD(ch) && !IS_EVIL(ch))
/* These three deprecated. */
#define WAIT_STATE(ch, cycle) do { GET_WAIT_STATE(ch) = (cycle); } while(0)
#define CHECK_WAIT(ch) ((ch)->wait > 0)
#define GET_MOB_WAIT(ch) GET_WAIT_STATE(ch)
/* New, preferred macro. */
#define GET_WAIT_STATE(ch) ((ch)->wait)
/* descriptor-based utils ************************************************/
/* Hrm, not many. We should make more. -gg 3/4/99 */
#define STATE(d) ((d)->connected)
/* object utils **********************************************************/
/*
* Check for NOWHERE or the top array index?
* If using unsigned types, the top array index will catch everything.
* If using signed types, NOTHING will catch the majority of bad accesses.
*/
#define VALID_OBJ_RNUM(obj) (GET_OBJ_RNUM(obj) <= top_of_objt && \
GET_OBJ_RNUM(obj) != NOTHING)
#define GET_OBJ_TYPE(obj) ((obj)->obj_flags.type_flag)
#define GET_OBJ_COST(obj) ((obj)->obj_flags.cost)
#define GET_OBJ_RENT(obj) ((obj)->obj_flags.cost_per_day)
#define GET_OBJ_AFFECT(obj) ((obj)->obj_flags.bitvector)
#define GET_OBJ_EXTRA(obj) ((obj)->obj_flags.extra_flags)
#define GET_OBJ_WEAR(obj) ((obj)->obj_flags.wear_flags)
#define GET_OBJ_VAL(obj, val) ((obj)->obj_flags.value[(val)])
#define GET_OBJ_WEIGHT(obj) ((obj)->obj_flags.weight)
#define GET_OBJ_TIMER(obj) ((obj)->obj_flags.timer)
#define GET_OBJ_RNUM(obj) ((obj)->item_number)
#define GET_OBJ_VNUM(obj) (VALID_OBJ_RNUM(obj) ? \
obj_index[GET_OBJ_RNUM(obj)].vnum : NOTHING)
#define GET_OBJ_SPEC(obj) (VALID_OBJ_RNUM(obj) ? \
obj_index[GET_OBJ_RNUM(obj)].func : NULL)
#define IS_CORPSE(obj) (GET_OBJ_TYPE(obj) == ITEM_CONTAINER && \
GET_OBJ_VAL((obj), 3) == 1)
#define CAN_WEAR(obj, part) OBJWEAR_FLAGGED((obj), (part))
#define IS_BURIED(obj) (IS_SET(GET_OBJ_EXTRA((obj)), ITEM_BURIED))
/* compound utilities and other macros **********************************/
/*
* Used to compute CircleMUD version. To see if the code running is newer
* than 3.0pl13, you would use: #if _CIRCLEMUD > CIRCLEMUD_VERSION(3,0,13)
*/
#define CIRCLEMUD_VERSION(major, minor, patchlevel) \
(((major) << 16) + ((minor) << 8) + (patchlevel))
#define HSHR(ch) (GET_SEX(ch) ? (GET_SEX(ch)==SEX_MALE ? "his":"her") :"its")
#define HSSH(ch) (GET_SEX(ch) ? (GET_SEX(ch)==SEX_MALE ? "he" :"she") : "it")
#define HMHR(ch) (GET_SEX(ch) ? (GET_SEX(ch)==SEX_MALE ? "him":"her") : "it")
#define ANA(obj) (strchr("aeiouAEIOU", *(obj)->name) ? "An" : "A")
#define SANA(obj) (strchr("aeiouAEIOU", *(obj)->name) ? "an" : "a")
/* Various macros building up to CAN_SEE */
#define LIGHT_OK(sub) (!AFF_FLAGGED(sub, AFF_BLIND) && \
(IS_LIGHT(IN_ROOM(sub)) || AFF_FLAGGED((sub), AFF_INFRAVISION)))
#define INVIS_OK(sub, obj) \
((!AFF_FLAGGED((obj),AFF_INVISIBLE) || AFF_FLAGGED(sub,AFF_DETECT_INVIS)) && \
(!AFF_FLAGGED((obj), AFF_HIDE) || AFF_FLAGGED(sub, AFF_SENSE_LIFE)))
#define MORT_CAN_SEE(sub, obj) (LIGHT_OK(sub) && INVIS_OK(sub, obj))
#define IMM_CAN_SEE(sub, obj) \
(MORT_CAN_SEE(sub, obj) || (!IS_NPC(sub) && PRF_FLAGGED(sub, PRF_HOLYLIGHT)))
#define SELF(sub, obj) ((sub) == (obj))
/* Can subject see character "obj"? */
#define CAN_SEE(sub, obj) (SELF(sub, obj) || \
((GET_REAL_LEVEL(sub) >= (IS_NPC(obj) ? 0 : GET_INVIS_LEV(obj))) && \
IMM_CAN_SEE(sub, obj)))
/* End of CAN_SEE */
#define INVIS_OK_OBJ(sub, obj) \
(!OBJ_FLAGGED((obj), ITEM_INVISIBLE) || AFF_FLAGGED((sub), AFF_DETECT_INVIS))
/* Is anyone carrying this object and if so, are they visible? */
#define CAN_SEE_OBJ_CARRIER(sub, obj) \
((!obj->carried_by || CAN_SEE(sub, obj->carried_by)) && \
(!obj->worn_by || CAN_SEE(sub, obj->worn_by)))
#define MORT_CAN_SEE_OBJ(sub, obj) \
(LIGHT_OK(sub) && INVIS_OK_OBJ(sub, obj) && CAN_SEE_OBJ_CARRIER(sub, obj) )
#define CAN_SEE_OBJ(sub, obj) \
((MORT_CAN_SEE_OBJ(sub, obj) && !IS_BURIED(obj)) || (!IS_NPC(sub) && PRF_FLAGGED((sub), PRF_HOLYLIGHT)))
#define CAN_CARRY_OBJ(ch,obj) \
(((IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj)) <= CAN_CARRY_W(ch)) && \
((IS_CARRYING_N(ch) + 1) <= CAN_CARRY_N(ch)))
#define CAN_GET_OBJ(ch, obj) \
(CAN_WEAR((obj), ITEM_WEAR_TAKE) && CAN_CARRY_OBJ((ch),(obj)) && \
CAN_SEE_OBJ((ch),(obj)))
#define PERS(ch, vict) (CAN_SEE(vict, ch) ? GET_NAME(ch) : "someone")
#define OBJS(obj, vict) (CAN_SEE_OBJ((vict), (obj)) ? \
(obj)->short_description : "something")
#define OBJN(obj, vict) (CAN_SEE_OBJ((vict), (obj)) ? \
fname((obj)->name) : "something")
#define EXIT(ch, door) (world[IN_ROOM(ch)].dir_option[door])
#define CAN_GO(ch, door) (EXIT(ch,door) && \
(EXIT(ch,door)->to_room != NOWHERE) && \
!IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
#define CLASS_ABBR(ch) (IS_NPC(ch) ? "--" : class_abbrevs[(int)GET_CLASS(ch)])
#define RACE_ABBR(ch) (IS_NPC(ch) ? "--" : race_abbrevs[(int)GET_RACE(ch)])
#define IS_MAGIC_USER(ch) (!IS_NPC(ch) && \
(GET_CLASS(ch) == CLASS_MAGIC_USER))
#define IS_CLERIC(ch) (!IS_NPC(ch) && \
(GET_CLASS(ch) == CLASS_CLERIC))
#define IS_THIEF(ch) (!IS_NPC(ch) && \
(GET_CLASS(ch) == CLASS_THIEF))
#define IS_WARRIOR(ch) (!IS_NPC(ch) && \
(GET_CLASS(ch) == CLASS_WARRIOR))
#define OUTSIDE(ch) (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS))
/* OS compatibility ******************************************************/
/* there could be some strange OS which doesn't have NULL... */
#ifndef NULL
#define NULL (void *)0
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE (!FALSE)
#endif
/* defines for fseek */
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
/*
* NOCRYPT can be defined by an implementor manually in sysdep.h.
* CIRCLE_CRYPT is a variable that the 'configure' script
* automatically sets when it determines whether or not the system is
* capable of encrypting.
*/
#if defined(NOCRYPT) || !defined(CIRCLE_CRYPT)
#define CRYPT(a,b) (a)
#else
#define CRYPT(a,b) ((char *) crypt((a),(b)))
#endif

178
old-codebase/src/weather.c Normal file
View File

@@ -0,0 +1,178 @@
/* ************************************************************************
* File: weather.c Part of CircleMUD *
* Usage: functions handling time and the weather *
* *
* 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 "handler.h"
#include "interpreter.h"
#include "db.h"
extern struct time_info_data time_info;
void weather_and_time(int mode);
void another_hour(int mode);
void weather_change(void);
void weather_and_time(int mode)
{
another_hour(mode);
if (mode)
weather_change();
}
void another_hour(int mode)
{
time_info.hours++;
if (mode) {
switch (time_info.hours) {
case 5:
weather_info.sunlight = SUN_RISE;
send_to_outdoor("The sun rises in the east.\r\n");
break;
case 6:
weather_info.sunlight = SUN_LIGHT;
send_to_outdoor("The day has begun.\r\n");
break;
case 21:
weather_info.sunlight = SUN_SET;
send_to_outdoor("The sun slowly disappears in the west.\r\n");
break;
case 22:
weather_info.sunlight = SUN_DARK;
send_to_outdoor("The night has begun.\r\n");
break;
default:
break;
}
}
if (time_info.hours > 23) { /* Changed by HHS due to bug ??? */
time_info.hours -= 24;
time_info.day++;
if (time_info.day > 34) {
time_info.day = 0;
time_info.month++;
if (time_info.month > 16) {
time_info.month = 0;
time_info.year++;
}
}
}
}
void weather_change(void)
{
int diff, change;
if ((time_info.month >= 9) && (time_info.month <= 16))
diff = (weather_info.pressure > 985 ? -2 : 2);
else
diff = (weather_info.pressure > 1015 ? -2 : 2);
weather_info.change += (dice(1, 4) * diff + dice(2, 6) - dice(2, 6));
weather_info.change = MIN(weather_info.change, 12);
weather_info.change = MAX(weather_info.change, -12);
weather_info.pressure += weather_info.change;
weather_info.pressure = MIN(weather_info.pressure, 1040);
weather_info.pressure = MAX(weather_info.pressure, 960);
change = 0;
switch (weather_info.sky) {
case SKY_CLOUDLESS:
if (weather_info.pressure < 990)
change = 1;
else if (weather_info.pressure < 1010)
if (dice(1, 4) == 1)
change = 1;
break;
case SKY_CLOUDY:
if (weather_info.pressure < 970)
change = 2;
else if (weather_info.pressure < 990) {
if (dice(1, 4) == 1)
change = 2;
else
change = 0;
} else if (weather_info.pressure > 1030)
if (dice(1, 4) == 1)
change = 3;
break;
case SKY_RAINING:
if (weather_info.pressure < 970) {
if (dice(1, 4) == 1)
change = 4;
else
change = 0;
} else if (weather_info.pressure > 1030)
change = 5;
else if (weather_info.pressure > 1010)
if (dice(1, 4) == 1)
change = 5;
break;
case SKY_LIGHTNING:
if (weather_info.pressure > 1010)
change = 6;
else if (weather_info.pressure > 990)
if (dice(1, 4) == 1)
change = 6;
break;
default:
change = 0;
weather_info.sky = SKY_CLOUDLESS;
break;
}
switch (change) {
case 0:
break;
case 1:
send_to_outdoor("The sky starts to get cloudy.\r\n");
weather_info.sky = SKY_CLOUDY;
break;
case 2:
send_to_outdoor("It starts to rain.\r\n");
weather_info.sky = SKY_RAINING;
break;
case 3:
send_to_outdoor("The clouds disappear.\r\n");
weather_info.sky = SKY_CLOUDLESS;
break;
case 4:
send_to_outdoor("Lightning starts to show in the sky.\r\n");
weather_info.sky = SKY_LIGHTNING;
break;
case 5:
send_to_outdoor("The rain stops.\r\n");
weather_info.sky = SKY_CLOUDY;
break;
case 6:
send_to_outdoor("The lightning stops.\r\n");
weather_info.sky = SKY_RAINING;
break;
default:
break;
}
}