Recovered from microbel
This commit is contained in:
1
server/.cvsignore
Normal file
1
server/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
pvvmudsrv
|
||||
9
server/Makefile.am
Normal file
9
server/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
||||
INCLUDES = -I../common/include -Idriver -Ilib @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
SUBDIRS = driver lib
|
||||
|
||||
bin_PROGRAMS = pvvmudsrv
|
||||
|
||||
pvvmudsrv_SOURCES = mudpvvmud.C player.C pvvmudsrv.C srvgosprotocol.C
|
||||
|
||||
pvvmudsrv_LDADD = driver/libdriver.a -Llib -lsrvlib -L../common/lib/gos -lgos -L../common/lib/texture -ltexture -L../common/lib/srvcli -lsrvcli -L../common/lib/geometry -lgeometry -L../common/lib/world -lworld -L../common/lib/utils -lpvvmudutils -lsrvcli -Ldriver -ldriver -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff @GL_LIBS@ @NETLIBS@
|
||||
425
server/Makefile.in
Normal file
425
server/Makefile.in
Normal file
@@ -0,0 +1,425 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
GL_CFLAGS = @GL_CFLAGS@
|
||||
GL_LIBS = @GL_LIBS@
|
||||
LEX = @LEX@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NETLIBS = @NETLIBS@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
TIFF_CFLAGS = @TIFF_CFLAGS@
|
||||
TIFF_LIBS = @TIFF_LIBS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
|
||||
INCLUDES = -I../common/include -Idriver -Ilib @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
SUBDIRS = driver lib
|
||||
|
||||
bin_PROGRAMS = pvvmudsrv
|
||||
|
||||
pvvmudsrv_SOURCES = mudpvvmud.C player.C pvvmudsrv.C srvgosprotocol.C
|
||||
|
||||
pvvmudsrv_LDADD = driver/libdriver.a -Llib -lsrvlib -L../common/lib/gos -lgos -L../common/lib/texture -ltexture -L../common/lib/srvcli -lsrvcli -L../common/lib/geometry -lgeometry -L../common/lib/world -lworld -L../common/lib/utils -lpvvmudutils -lsrvcli -Ldriver -ldriver -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff @GL_LIBS@ @NETLIBS@
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
pvvmudsrv_OBJECTS = mudpvvmud.o player.o pvvmudsrv.o srvgosprotocol.o
|
||||
pvvmudsrv_DEPENDENCIES = driver/libdriver.a
|
||||
pvvmudsrv_LDFLAGS =
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in TODO
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/mudpvvmud.P .deps/player.P .deps/pvvmudsrv.P \
|
||||
.deps/srvgosprotocol.P
|
||||
SOURCES = $(pvvmudsrv_SOURCES)
|
||||
OBJECTS = $(pvvmudsrv_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .C .S .c .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign server/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-binPROGRAMS:
|
||||
|
||||
clean-binPROGRAMS:
|
||||
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||
|
||||
distclean-binPROGRAMS:
|
||||
|
||||
maintainer-clean-binPROGRAMS:
|
||||
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
|
||||
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
|
||||
done
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
pvvmudsrv: $(pvvmudsrv_OBJECTS) $(pvvmudsrv_DEPENDENCIES)
|
||||
@rm -f pvvmudsrv
|
||||
$(CXXLINK) $(pvvmudsrv_LDFLAGS) $(pvvmudsrv_OBJECTS) $(pvvmudsrv_LDADD) $(LIBS)
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" = "." && dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = server
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign server/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.C
|
||||
@echo '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am: install-binPROGRAMS
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am: uninstall-binPROGRAMS
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
|
||||
distclean-depend distclean-generic clean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
|
||||
maintainer-clean-am: maintainer-clean-binPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-depend maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
||||
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
|
||||
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile install-data-recursive \
|
||||
uninstall-data-recursive install-exec-recursive \
|
||||
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
|
||||
all-recursive check-recursive installcheck-recursive info-recursive \
|
||||
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
||||
mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs-am installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
77
server/TODO
Normal file
77
server/TODO
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
Include playerroom in world!
|
||||
-OK 13/2-1999
|
||||
|
||||
Create a list of liseners for each cell!
|
||||
-OK 14/2-1999
|
||||
|
||||
Update liseners when geometry changes! This can be done in
|
||||
worldobject->setPosition and worldobject->setDirection.
|
||||
-OK 14/2-1999 Did create updatePosition and updateDirection
|
||||
|
||||
Create code to move player!
|
||||
-Client side code for steping: OK 14/2-1999
|
||||
-Server side code for steping: OK 14/2-1999
|
||||
|
||||
Switch cell when player move outside cell!
|
||||
-Code for moving players between cells: OK 16/2-1999
|
||||
-Detect when moving outside a cell: OK 24/2-1999
|
||||
-Find new cell and switch: OK 2/3-1999
|
||||
-Update viewpoint information:
|
||||
|
||||
Client messagepump updated to read multiple messages between redraws.
|
||||
-OK 16/2-1999
|
||||
|
||||
Create PVS of cells. Send them to the client on requests.
|
||||
-OK 20/2-1999
|
||||
|
||||
Create clear world message.
|
||||
-OK 16/2-1999 Did use MsgCommand with msgid MSGCOMMAND_CLIENTCLEARWORLD
|
||||
|
||||
Send MsgGeoObjRemove to liseners when a object are deleted from a worldobject.
|
||||
-Recursivly deleting objects in the client world->removeGeometryObject(*): OK
|
||||
-Sending message: OK 22/2-1999
|
||||
|
||||
Send a message to liseners when objects are added to a worldobject.
|
||||
-OK 22/2-1999
|
||||
|
||||
Mapping between client input (keybord and mouse) and function
|
||||
-OK 23/2-1999
|
||||
|
||||
Picking object
|
||||
-Client opengl code: OK 23/2-1999
|
||||
-Sending pick message: OK 24/2-1999
|
||||
-Find worldobject holding picked geometryobject: OK 24/2-1999
|
||||
-Send worldobject actions to client: OK 28/2-1999
|
||||
-Display actionlist: OK 1/3-1999
|
||||
-Send action to server: OK 2/3-1999
|
||||
-Distribute action to worldobject: OK 2/3-1999
|
||||
|
||||
Messages with Variabel length needed to send worldobject command list:
|
||||
-OK 25/2-1999
|
||||
|
||||
Stream readString need reimplementation to allow strings greater than 1024
|
||||
char to be read:
|
||||
|
||||
Include MsgActionList in project
|
||||
-Include some objectId reference: OK 28/2-1999
|
||||
-Change char msg id with constants defined in message.H: OK 2/3-1999
|
||||
-Create MsgActionListCli: OK 28/2-1999
|
||||
|
||||
Have client servers contacting pvvmudsrv and clients connecting after
|
||||
receiveing serverinfo from pvvmudsrv
|
||||
-GOS list in server: OK 8/4-1999
|
||||
-Have gos contacting server: OK 11/4-1999
|
||||
-Create MsgServerInfo: OK 18/4-1999
|
||||
-Send MsgServerInfo to clients: OK 18/4-1999
|
||||
-Connect to gos useing serverinfo: OK 18/4-1999
|
||||
-Connect to worldsrv useing serverinfo: OK 25/4-1999
|
||||
|
||||
Remove files:
|
||||
area.* cell.* geometryobject.* geometryobjectlist.*
|
||||
srvlistener.* srvobject.* world.*
|
||||
|
||||
Move files:
|
||||
player.* -> driver/
|
||||
|
||||
|
||||
5
server/driver/Makefile.am
Normal file
5
server/driver/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I../../common/include -I.. -I../lib @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
noinst_LIBRARIES = libdriver.a
|
||||
|
||||
libdriver_a_SOURCES = mud.C srvaction.C srvclimanager.C srvclimessage.C srvcliprotocol.C srvclisrvsocket.C srvgeocache.C srvgos.C srvgosmanager.C srvgosmessage.C srvgosprotocol.C srvgossrvsocket.C srvlistenerlist.C srvobject.C srvviewpoint.C srvworld.C srvworldmanager.C srvworldmessage.C srvworldprotocol.C srvworldsrvsocket.C srvclicmdparser.C userdb.C
|
||||
340
server/driver/Makefile.in
Normal file
340
server/driver/Makefile.in
Normal file
@@ -0,0 +1,340 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
GL_CFLAGS = @GL_CFLAGS@
|
||||
GL_LIBS = @GL_LIBS@
|
||||
LEX = @LEX@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NETLIBS = @NETLIBS@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
TIFF_CFLAGS = @TIFF_CFLAGS@
|
||||
TIFF_LIBS = @TIFF_LIBS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
|
||||
INCLUDES = -I../../common/include -I.. -I../lib @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
noinst_LIBRARIES = libdriver.a
|
||||
|
||||
libdriver_a_SOURCES = mud.C srvaction.C srvclimanager.C srvclimessage.C srvcliprotocol.C srvclisrvsocket.C srvgeocache.C srvgos.C srvgosmanager.C srvgosmessage.C srvgosprotocol.C srvgossrvsocket.C srvlistenerlist.C srvobject.C srvviewpoint.C srvworld.C srvworldmanager.C srvworldmessage.C srvworldprotocol.C srvworldsrvsocket.C srvclicmdparser.C userdb.C
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libdriver_a_LIBADD =
|
||||
libdriver_a_OBJECTS = mud.o srvaction.o srvclimanager.o srvclimessage.o \
|
||||
srvcliprotocol.o srvclisrvsocket.o srvgeocache.o srvgos.o \
|
||||
srvgosmanager.o srvgosmessage.o srvgosprotocol.o srvgossrvsocket.o \
|
||||
srvlistenerlist.o srvobject.o srvviewpoint.o srvworld.o \
|
||||
srvworldmanager.o srvworldmessage.o srvworldprotocol.o \
|
||||
srvworldsrvsocket.o srvclicmdparser.o userdb.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/mud.P .deps/srvaction.P .deps/srvclicmdparser.P \
|
||||
.deps/srvclimanager.P .deps/srvclimessage.P .deps/srvcliprotocol.P \
|
||||
.deps/srvclisrvsocket.P .deps/srvgeocache.P .deps/srvgos.P \
|
||||
.deps/srvgosmanager.P .deps/srvgosmessage.P .deps/srvgosprotocol.P \
|
||||
.deps/srvgossrvsocket.P .deps/srvlistenerlist.P .deps/srvobject.P \
|
||||
.deps/srvviewpoint.P .deps/srvworld.P .deps/srvworldmanager.P \
|
||||
.deps/srvworldmessage.P .deps/srvworldprotocol.P \
|
||||
.deps/srvworldsrvsocket.P .deps/userdb.P
|
||||
SOURCES = $(libdriver_a_SOURCES)
|
||||
OBJECTS = $(libdriver_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .C .S .c .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign server/driver/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-noinstLIBRARIES:
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
|
||||
distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libdriver.a: $(libdriver_a_OBJECTS) $(libdriver_a_DEPENDENCIES)
|
||||
-rm -f libdriver.a
|
||||
$(AR) cru libdriver.a $(libdriver_a_OBJECTS) $(libdriver_a_LIBADD)
|
||||
$(RANLIB) libdriver.a
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = server/driver
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign server/driver/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.C
|
||||
@echo '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstLIBRARIES distclean-compile \
|
||||
distclean-tags distclean-depend distclean-generic \
|
||||
clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-depend maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
|
||||
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
|
||||
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
|
||||
distclean-depend clean-depend maintainer-clean-depend info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
368
server/driver/mud.C
Normal file
368
server/driver/mud.C
Normal file
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <iostream.h>
|
||||
#include "mud.H"
|
||||
//#include "cell.H"
|
||||
//#include "area.H"
|
||||
#include "srvgosmanager.H"
|
||||
#include "option.H"
|
||||
|
||||
|
||||
CMud::CMud(COption *option){
|
||||
TRACE_CREATE("Mud");
|
||||
|
||||
m_option = option;
|
||||
m_userDB = new CUserDB(m_option->getString("userdb"));
|
||||
|
||||
m_mudTime = 0;
|
||||
|
||||
m_timeKeeper = new CTimeKeeper();
|
||||
|
||||
m_markedClient = FALSE;
|
||||
m_markedGOS = FALSE;
|
||||
m_markedWorld = FALSE;
|
||||
|
||||
m_clientList = new CObjectList();
|
||||
m_gosList = new CObjectList();
|
||||
m_worldList = new CObjectList();
|
||||
|
||||
m_clientSocket = new CMudSrvSocket(this,option->getInt("port"),m_timeKeeper);
|
||||
m_GOSSocket = new CSrvGOSSrvSocket(this,option->getInt("gos_port"),
|
||||
m_timeKeeper);
|
||||
m_worldSocket =new CSrvWorldSrvSocket(this,option->getInt("world_port"),
|
||||
m_timeKeeper);
|
||||
|
||||
m_timeKeeper->addHeartBeat(SCHEDULE_INTERVAL,this);
|
||||
|
||||
m_gos = NULL;
|
||||
m_geoCache = new CSrvGEOCache(this);
|
||||
}
|
||||
|
||||
CMud::~CMud(){
|
||||
TRACE_DELETE("Mud");
|
||||
if (m_clientList != NULL) {
|
||||
m_clientList->deleteAll();
|
||||
delete m_clientList;
|
||||
}
|
||||
if (m_gosList != NULL) {
|
||||
m_gosList->deleteAll();
|
||||
delete m_gosList;
|
||||
}
|
||||
if (m_clientSocket != NULL) delete m_clientSocket;
|
||||
if (m_GOSSocket != NULL) delete m_GOSSocket;
|
||||
if (m_world != NULL) delete m_world;
|
||||
if (m_gos != NULL) delete m_gos;
|
||||
}
|
||||
|
||||
CSrvWorld * CMud::getWorld(){
|
||||
return m_world;
|
||||
}
|
||||
|
||||
COption * CMud::getOption(){
|
||||
return m_option;
|
||||
}
|
||||
|
||||
CUserDB * CMud::getUserDB(){
|
||||
return m_userDB;
|
||||
}
|
||||
|
||||
void CMud::addClient(CClientManager * client){
|
||||
m_clientList->addLast(client);
|
||||
}
|
||||
|
||||
void CMud::removeClient(CClientManager * client){
|
||||
m_clientList->remove(client);
|
||||
}
|
||||
|
||||
void CMud::checkMarkedClient(){
|
||||
CObjectListItem * item = m_clientList->getFirst();
|
||||
while (item != NULL){
|
||||
CClientManager * client = (CClientManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (client->getQuit()){
|
||||
removeClient(client);
|
||||
delete client;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CMud::addGOS(CSrvGOSManager * gos){
|
||||
m_gosList->addLast(gos);
|
||||
}
|
||||
|
||||
void CMud::removeGOS(CSrvGOSManager * gos){
|
||||
m_gosList->remove(gos);
|
||||
}
|
||||
|
||||
void CMud::checkMarkedGOS(){
|
||||
CObjectListItem * item = m_gosList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvGOSManager * gos = (CSrvGOSManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (gos->getOnLine()){
|
||||
// First time this it true notify everybody that are waiting for a GOS.
|
||||
if (m_gos == NULL){
|
||||
try {
|
||||
m_gos = new CSrvGOS(this,m_timeKeeper,gos->getAddress());
|
||||
} catch (CException * e){
|
||||
cdebug << *e << "\nERROR: Failed to connect to gos: "
|
||||
<< gos->getAddress()->getAddressString() << "\n";
|
||||
delete e;
|
||||
}
|
||||
}
|
||||
|
||||
gos->setRunning();
|
||||
|
||||
}
|
||||
|
||||
if (gos->getQuit()){
|
||||
cdebug << "Removing GOS from server\n";
|
||||
removeGOS(gos);
|
||||
delete gos;
|
||||
|
||||
// Remove gos: Have to include a test to check if this is the gos
|
||||
// that went down.
|
||||
if (m_gos != NULL){
|
||||
delete m_gos;
|
||||
m_gos = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CInetAddress * CMud::getGOSAddress(){
|
||||
CSrvGOSManager * foundGOS = NULL;
|
||||
int foundNum;
|
||||
CObjectListItem * item = m_gosList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvGOSManager * gos = (CSrvGOSManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (gos->getRunning()){
|
||||
if ((foundGOS == NULL) || (gos->getNumClients() < foundNum)){
|
||||
foundNum = gos->getNumClients();
|
||||
foundGOS = gos;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (foundGOS != NULL){
|
||||
foundGOS->addNumClients();
|
||||
return foundGOS->getAddress();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CMud::freeGOSAddress(CInetAddress * address){
|
||||
CObjectListItem * item = m_gosList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvGOSManager * gos = (CSrvGOSManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (gos->getAddress() == address){
|
||||
gos->addNumClients(-1);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CMud::addWorld(CSrvWorldManager * worldSrv){
|
||||
m_worldList->addLast(worldSrv);
|
||||
}
|
||||
|
||||
void CMud::removeWorld(CSrvWorldManager * worldSrv){
|
||||
m_worldList->remove(worldSrv);
|
||||
if (m_world != NULL) m_world->removeListener( worldSrv );
|
||||
}
|
||||
|
||||
void CMud::checkMarkedWorld(){
|
||||
CObjectListItem * item = m_worldList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * worldSrv = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (worldSrv->getOnLine()){
|
||||
// First time this it true notify everybody that are waiting for a
|
||||
// world server.
|
||||
|
||||
if (m_world != NULL){
|
||||
m_world->addListener( worldSrv );
|
||||
m_world->sendWorld( worldSrv );
|
||||
}
|
||||
|
||||
worldSrv->setRunning();
|
||||
|
||||
}
|
||||
|
||||
if (worldSrv->getQuit()){
|
||||
cdebug << "Removing WorldSrv from server\n";
|
||||
removeWorld(worldSrv);
|
||||
delete worldSrv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CInetAddress * CMud::getWorldSrvAddress(){
|
||||
CSrvWorldManager * foundWorld = NULL;
|
||||
int foundNum;
|
||||
CObjectListItem * item = m_worldList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * worldSrv = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (worldSrv->getRunning()){
|
||||
if ((foundWorld == NULL) || (worldSrv->getNumClients() < foundNum)){
|
||||
foundNum = worldSrv->getNumClients();
|
||||
foundWorld = worldSrv;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (foundWorld != NULL){
|
||||
foundWorld->addNumClients();
|
||||
return foundWorld->getAddress();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int CMud::freeWorldAddress(CInetAddress * address){
|
||||
CObjectListItem * item = m_worldList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * worldSrv = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (worldSrv->getAddress() == address){
|
||||
worldSrv->addNumClients(-1);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CMud::timeKeeperHB(){
|
||||
m_mudTime ++;
|
||||
|
||||
// cdebug << "Schedule Mud Time = " << m_mudTime << " tics\n";
|
||||
|
||||
if (m_markedClient){
|
||||
checkMarkedClient();
|
||||
m_markedClient = FALSE;
|
||||
}
|
||||
|
||||
if (m_markedGOS){
|
||||
checkMarkedGOS();
|
||||
m_markedGOS = FALSE;
|
||||
}
|
||||
|
||||
if (m_markedWorld){
|
||||
checkMarkedWorld();
|
||||
m_markedWorld = FALSE;
|
||||
}
|
||||
|
||||
// m_world->animate( (double)SCHEDULE_INTERVAL / 1000.0 );
|
||||
m_world->animate( );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CMud::loadWorld(){
|
||||
|
||||
m_world = newWorld();
|
||||
createWorld(m_world);
|
||||
|
||||
CObjectListItem * item = m_worldList->getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * worldSrv = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
if (worldSrv->getRunning())
|
||||
m_world->addListener(worldSrv);
|
||||
}
|
||||
}
|
||||
|
||||
CSrvWorld * CMud::newWorld(){
|
||||
return new CSrvWorld(this);
|
||||
}
|
||||
|
||||
void CMud::createWorld(CSrvWorld * world){
|
||||
cdebug << "CreateWorld not overloaded!\n";
|
||||
}
|
||||
|
||||
void CMud::run(){
|
||||
loadWorld();
|
||||
m_timeKeeper->mainLoop();
|
||||
}
|
||||
|
||||
void CMud::stop(){
|
||||
m_timeKeeper->stopLoop();
|
||||
}
|
||||
|
||||
void CMud::request(int requestType,int requestId){
|
||||
if (m_gos != NULL) m_gos->request(requestType,requestId);
|
||||
}
|
||||
|
||||
void CMud::error(){
|
||||
}
|
||||
|
||||
void CMud::geometry(CGeometry * geometry){
|
||||
CGeometry * geo = (CGeometry*)m_geoCache->add(geometry->getId(),geometry);
|
||||
if (geo != NULL) delete geo;
|
||||
|
||||
// char name[256];
|
||||
// sprintf(name,"tmp/%i.geo",geometry->getId());
|
||||
// FILE * geofile = fopen(name,"w");
|
||||
// geometry->writeBOG(geofile);
|
||||
// fclose(geofile);
|
||||
}
|
||||
|
||||
void CMud::material(CMaterial * material){
|
||||
delete material;
|
||||
}
|
||||
|
||||
void CMud::texture(CTexture * texture){
|
||||
delete texture;
|
||||
}
|
||||
|
||||
CGeometry * CMud::getGeometry(DWORD geometryId){
|
||||
return (CGeometry*)m_geoCache->get(geometryId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// chatMessage
|
||||
// Send a message to every client connected
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CMud::chatMessage(const char * message){
|
||||
CObjectListItem * item = m_clientList->getFirst();
|
||||
while (item != NULL){
|
||||
CClientManager * client = (CClientManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
client->sendMsg( message );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
114
server/driver/mud.H
Normal file
114
server/driver/mud.H
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MUD_H
|
||||
#define _MUD_H
|
||||
|
||||
#include "srvclimanager.H"
|
||||
#include "srvclisrvsocket.H"
|
||||
#include "srvgosmanager.H"
|
||||
#include "srvgossrvsocket.H"
|
||||
#include "srvworldmanager.H"
|
||||
#include "srvworldsrvsocket.H"
|
||||
#include "timekeeper.H"
|
||||
#include "inetaddress.H"
|
||||
#include "srvworld.H"
|
||||
#include "srvgos.H"
|
||||
#include "srvgeocache.H"
|
||||
#include "option.H"
|
||||
#include "userdb.H"
|
||||
|
||||
class CMud: public CTimeKeeperItem {
|
||||
|
||||
COption * m_option;
|
||||
CSrvWorld * m_world;
|
||||
CUserDB * m_userDB;
|
||||
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
|
||||
CMudSrvSocket * m_clientSocket;
|
||||
CObjectList * m_clientList;
|
||||
int m_markedClient;
|
||||
|
||||
CSrvGOSSrvSocket * m_GOSSocket;
|
||||
CObjectList * m_gosList;
|
||||
int m_markedGOS;
|
||||
|
||||
CSrvWorldSrvSocket * m_worldSocket;
|
||||
CObjectList * m_worldList;
|
||||
int m_markedWorld;
|
||||
|
||||
CSrvGOS * m_gos;
|
||||
CSrvGEOCache * m_geoCache;
|
||||
|
||||
unsigned long m_mudTime; // Time in tics
|
||||
|
||||
public:
|
||||
CMud(COption *option);
|
||||
virtual ~CMud();
|
||||
|
||||
CSrvWorld * getWorld();
|
||||
COption * getOption();
|
||||
CUserDB * getUserDB();
|
||||
|
||||
|
||||
void addClient(CClientManager * client);
|
||||
void removeClient(CClientManager * client);
|
||||
void markClient(){ m_markedClient = TRUE; }
|
||||
void checkMarkedClient();
|
||||
|
||||
void addGOS(CSrvGOSManager * gos);
|
||||
void removeGOS(CSrvGOSManager * gos);
|
||||
void markGOS(){ m_markedGOS = TRUE; }
|
||||
void checkMarkedGOS();
|
||||
CInetAddress * getGOSAddress();
|
||||
int freeGOSAddress(CInetAddress * address);
|
||||
|
||||
void addWorld(CSrvWorldManager * worldSrv);
|
||||
void removeWorld(CSrvWorldManager * worldSrv);
|
||||
void markWorld(){ m_markedWorld = TRUE; }
|
||||
void checkMarkedWorld();
|
||||
CInetAddress * getWorldSrvAddress();
|
||||
int freeWorldAddress(CInetAddress * address);
|
||||
|
||||
private:
|
||||
virtual int timeKeeperHB();
|
||||
void loadWorld();
|
||||
|
||||
public:
|
||||
// virtual void createOldWorld(CWorld * world);
|
||||
virtual CSrvWorld * newWorld();
|
||||
virtual void createWorld(CSrvWorld * world);
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
// GOS functions
|
||||
void request(int requestType,int requestId);
|
||||
void error();
|
||||
void geometry(CGeometry * geometry);
|
||||
void material(CMaterial * material);
|
||||
void texture(CTexture * texture);
|
||||
|
||||
// Cache functions
|
||||
CGeometry * getGeometry(DWORD geometryId);
|
||||
void chatMessage(const char * message);
|
||||
|
||||
};
|
||||
|
||||
#endif /* _MUD_H */
|
||||
49
server/driver/server.H
Normal file
49
server/driver/server.H
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SERVER_H
|
||||
#define _SERVER_H
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "mudtypes.h"
|
||||
|
||||
#define SCHEDULE_INTERVAL 512 // In milliseconds. NB 2^n
|
||||
|
||||
#ifdef _DEBUG_TRACE_DELETE
|
||||
|
||||
#define TRACE_DELETE(str) printf("Delete "str"\n")
|
||||
#define TRACE_DELETE2(str,arg2) printf("Delete "str"\n",arg2)
|
||||
|
||||
#define TRACE_CREATE(str) printf("Create "str"\n")
|
||||
|
||||
#else
|
||||
|
||||
#define TRACE_DELETE(str)
|
||||
#define TRACE_DELETE2(str,arg2)
|
||||
|
||||
#define TRACE_CREATE(str)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.1415927
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _SERVER_H */
|
||||
26
server/driver/srvaction.C
Normal file
26
server/driver/srvaction.C
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include "srvaction.H"
|
||||
|
||||
CSrvAction::CSrvAction(char * name, CObject * masterObject):CAction(name){
|
||||
this->masterObject = masterObject;
|
||||
}
|
||||
|
||||
32
server/driver/srvaction.H
Normal file
32
server/driver/srvaction.H
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVACTION_H
|
||||
#define _SRVACTION_H
|
||||
|
||||
#include "action.H"
|
||||
|
||||
class CSrvAction : public CAction {
|
||||
CObject * masterObject;
|
||||
public:
|
||||
CSrvAction(char * name,CObject * masterObject);
|
||||
CObject * getMasterObject(){ return masterObject; }
|
||||
};
|
||||
|
||||
#endif // _ACTION_H
|
||||
215
server/driver/srvclicmdparser.C
Normal file
215
server/driver/srvclicmdparser.C
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "pvvmud.H"
|
||||
#include "mud.H"
|
||||
#include "srvclimanager.H"
|
||||
|
||||
|
||||
CSrvCliCmdParser::CSrvCliCmdParser(CMud * mud, CClientManager * manager):
|
||||
CCommandParser()
|
||||
{
|
||||
m_mud = mud;
|
||||
m_manager = manager;
|
||||
|
||||
addCommand("help",(CommandFunc_t)&commandHelp);
|
||||
addCommand("create",(CommandFunc_t)&commandCreate);
|
||||
addCommand("delete",(CommandFunc_t)&commandDelete);
|
||||
addCommand("move",(CommandFunc_t)&commandMove);
|
||||
addCommand("rotate",(CommandFunc_t)&commandRotate);
|
||||
|
||||
}
|
||||
|
||||
CSrvCliCmdParser::~CSrvCliCmdParser(){
|
||||
}
|
||||
|
||||
void CSrvCliCmdParser::commandUnknown(const string & commandString){
|
||||
m_manager->sendMsg("Unkown command!\n");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandHelp
|
||||
// Syntax: /help [command]
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandHelp(argv_t & argv){
|
||||
if (argv.size() == 2){
|
||||
if (argv[1] == "help"){
|
||||
m_manager->sendMsg(
|
||||
"help [<command>]\n"
|
||||
" Use this command to get help.\n"
|
||||
);
|
||||
} else if (argv[1] == "create"){
|
||||
m_manager->sendMsg(
|
||||
"create object <geometryId> <parentId> <pos> [<dir>]\n"
|
||||
" Add geometry to the world.\n"
|
||||
);
|
||||
} else if (argv[1] == "delete"){
|
||||
m_manager->sendMsg(
|
||||
"delete <objectId>\n"
|
||||
" Delete a object from the world.\n"
|
||||
);
|
||||
} else if (argv[1] == "move"){
|
||||
m_manager->sendMsg(
|
||||
"move <objectId> <position>\n"
|
||||
" Move a object to the given position.\n"
|
||||
);
|
||||
} else if (argv[1] == "rotate"){
|
||||
m_manager->sendMsg(
|
||||
"rotate <objectId> <direction> [<time>]\n"
|
||||
" Rotate a object to the given direction.\n"
|
||||
);
|
||||
} else {
|
||||
m_manager->sendMsg( "Unkown kommand\n" );
|
||||
}
|
||||
} else {
|
||||
m_manager->sendMsg(
|
||||
"Help\n"
|
||||
" Commands start with '/' everything else is chat messages\n"
|
||||
" Commands:\n"
|
||||
" /help\n"
|
||||
" /create\n"
|
||||
" /delete\n"
|
||||
" /move\n"
|
||||
" /rotate\n"
|
||||
" Use /help <command> for help about a command\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandChat
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandChat(const string & chatMessage){
|
||||
string msg = string("<") + m_manager->getName() + "> " + chatMessage + "\n";
|
||||
m_mud->chatMessage(msg.c_str());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandCreate
|
||||
// Syntax: /create <objectType> <objectArgs> <parentId> <pos> [<dir>]
|
||||
// Eks : /create object geometry/common/plants/Tree_1 cell4 20.5 23.2 0.0
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandCreate(argv_t & argv){
|
||||
|
||||
for (int i = 0; i < argv.size(); i++){
|
||||
cout << ":" << argv[i];
|
||||
}
|
||||
|
||||
cout << ":" << endl;
|
||||
|
||||
if (argv.size() < 6){
|
||||
m_manager->sendMsg("Wrong arguments!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv[1] == "object"){ // Object
|
||||
char * objectType = (char*)argv[1].c_str();
|
||||
int geometryId = atoi(argv[2].c_str());
|
||||
int parentId = atoi(argv[3].c_str());
|
||||
float posx = atof(argv[4].c_str());
|
||||
float posy = atof(argv[5].c_str());
|
||||
float posz = atof(argv[6].c_str());
|
||||
float heading = 0.0,roll = 0.0,pitch = 0.0;
|
||||
if (argv.size() >= 9){
|
||||
heading = atof(argv[7].c_str());
|
||||
roll = atof(argv[8].c_str());
|
||||
pitch = atof(argv[9].c_str());
|
||||
}
|
||||
CPosition pos = CPosition(posx,posy,posz);
|
||||
CDirection dir = CDirection(heading,roll,pitch);
|
||||
DWORD objectId = m_mud->getWorld()->getNewObjectId();
|
||||
m_mud->getWorld()->createObject(parentId,objectType,objectId,geometryId,pos,dir);
|
||||
} else {
|
||||
m_manager->sendMsg("Unknown objecType!\n");
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandDelete
|
||||
// Syntax: /delete <objectId>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandDelete(argv_t & argv){
|
||||
|
||||
if (argv.size() != 2){
|
||||
m_manager->sendMsg("Wrong number of arguments!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int objectId = atoi(argv[1].c_str());
|
||||
|
||||
CSrvObject * object = (CSrvObject*)m_mud->getWorld()->getObject(objectId);
|
||||
|
||||
if (object != NULL)
|
||||
m_mud->getWorld()->removeObject(objectId,object->getParentId());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandMove
|
||||
// Syntax: /move <objectId> <position>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandMove(argv_t & argv){
|
||||
|
||||
if (argv.size() != 5){
|
||||
m_manager->sendMsg("Wrong number of arguments!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int objectId = atoi(argv[1].c_str());
|
||||
float posx = atof(argv[2].c_str());
|
||||
float posy = atof(argv[3].c_str());
|
||||
float posz = atof(argv[4].c_str());
|
||||
CPosition position = CPosition(posx,posy,posz);
|
||||
|
||||
m_mud->getWorld()->updatePosition(objectId,position);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandDelete
|
||||
// Syntax: /rotate <objectId> <direction> [<time>]
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CSrvCliCmdParser::commandRotate(argv_t & argv){
|
||||
|
||||
if (argv.size() < 5 || argv.size() > 6){
|
||||
m_manager->sendMsg("Wrong number of arguments!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int objectId = atoi(argv[1].c_str());
|
||||
float heading = atof(argv[2].c_str());
|
||||
float roll = atof(argv[3].c_str());
|
||||
float pitch = atof(argv[4].c_str());
|
||||
|
||||
if (argv.size() == 6){
|
||||
float time = atof(argv[5].c_str());
|
||||
if (time == 0.0) time = 1.0;
|
||||
|
||||
CDirection angleSpeed = CDirection(heading/time,roll/time,pitch/time);
|
||||
|
||||
cdebug << "Angle: " << angleSpeed << endl;
|
||||
|
||||
m_mud->getWorld()->rotate(objectId,angleSpeed);
|
||||
} else {
|
||||
CDirection direction = CDirection(heading,roll,pitch);
|
||||
|
||||
m_mud->getWorld()->updateDirection(objectId,direction);
|
||||
}
|
||||
}
|
||||
|
||||
48
server/driver/srvclicmdparser.H
Normal file
48
server/driver/srvclicmdparser.H
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVCLICMDPARSER_H
|
||||
#define _SRVCLICMDPARSER_H
|
||||
|
||||
#include "commandparser.H"
|
||||
#include "mud.H"
|
||||
#include "srvclimanager.H"
|
||||
|
||||
class CSrvCliCmdParser : public CCommandParser {
|
||||
|
||||
CMud * m_mud;
|
||||
CClientManager * m_manager;
|
||||
|
||||
public:
|
||||
CSrvCliCmdParser(CMud * mud, CClientManager * manager);
|
||||
virtual ~CSrvCliCmdParser();
|
||||
|
||||
private:
|
||||
virtual void commandUnknown(const string & commandString);
|
||||
|
||||
void commandHelp(argv_t & argv);
|
||||
void commandChat(const string & chatMessage);
|
||||
void commandCreate(argv_t & argv);
|
||||
void commandDelete(argv_t & argv);
|
||||
void commandMove(argv_t & argv);
|
||||
void commandRotate(argv_t & argv);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVCLICMDPARSER_H
|
||||
296
server/driver/srvclimanager.C
Normal file
296
server/driver/srvclimanager.C
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <iostream.h>
|
||||
#include "srvclimanager.H"
|
||||
#include "srvcliprotocol.H"
|
||||
#include "mud.H"
|
||||
#include "viewpoint_1p.H"
|
||||
|
||||
static int currSrvCliId = 0;
|
||||
|
||||
CClientManager::CClientManager(CMud * mud, CSrvProtocol * protocol):CManager(protocol){
|
||||
m_mud = mud;
|
||||
m_viewpoint = new CViewpoint_1p();
|
||||
// status = MANAGER_INIT;
|
||||
m_commandParser = new CSrvCliCmdParser(mud,this);
|
||||
|
||||
// Set client connection name
|
||||
char name[16];
|
||||
sprintf(name,"Client %i",currSrvCliId++);
|
||||
getProtocol()->setName(name);
|
||||
|
||||
getProtocol()->sendHello();
|
||||
// status = MANAGER_LOGIN;
|
||||
m_quit = FALSE;
|
||||
}
|
||||
|
||||
CClientManager::~CClientManager(){
|
||||
cdebug << "Destructor CClientManager\n";
|
||||
if (m_viewpoint != NULL) delete m_viewpoint;
|
||||
}
|
||||
|
||||
void CClientManager::quit(){
|
||||
m_quit = TRUE;
|
||||
m_mud->markClient();
|
||||
}
|
||||
|
||||
CWorldWorld * CClientManager::getWorld(){
|
||||
return m_mud->getWorld();
|
||||
}
|
||||
|
||||
void CClientManager::setPlayer(CPlayer * player){
|
||||
m_player = player;
|
||||
}
|
||||
|
||||
void CClientManager::login(char * name,char *passwd,BOOL newUser){
|
||||
static CInetAddress noAddr;
|
||||
|
||||
setName(name);
|
||||
|
||||
if (!m_mud->getUserDB()->verifyUser(name,passwd)){
|
||||
// Login failed
|
||||
sendMsg("Failed to verify username and password!");
|
||||
quit();
|
||||
return;
|
||||
}
|
||||
|
||||
CInetAddress * worldAddr = m_mud->getWorldSrvAddress();
|
||||
if (worldAddr == NULL) worldAddr = &noAddr;
|
||||
CInetAddress * gosAddr = m_mud->getGOSAddress();
|
||||
if (gosAddr == NULL) gosAddr = &noAddr;
|
||||
|
||||
cdebug << "ServerInfo : world = " << *worldAddr
|
||||
<< " GOS = " << *gosAddr << "\n";
|
||||
|
||||
getProtocol()->sendServerInfo(*worldAddr,*gosAddr);
|
||||
|
||||
}
|
||||
|
||||
void CClientManager::online(){
|
||||
cdebug << "Client online\n";
|
||||
|
||||
CSrvObject * cell = (CSrvObject*)getWorld()->getObject("cell5");
|
||||
|
||||
if (cell != NULL){
|
||||
|
||||
m_player = (CPlayer*)cell->createObject("player",0,CPosition(0,0,0),
|
||||
CDirection(0,0,0),getName());
|
||||
cdebug << "Player created\n";
|
||||
|
||||
m_player->setManager(this);
|
||||
|
||||
m_viewpoint->setTargetId(m_player->getObjectId());
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
|
||||
sendWorld();
|
||||
} else {
|
||||
cdebug << "Player online failed to get cell!\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CClientManager::logout(){
|
||||
cdebug << "Player " << m_player->getName() << " logout!\n";
|
||||
sendBye(MSGBYE_QUIT);
|
||||
CWorldObject * parent = (CWorldObject*)m_player->getParent();
|
||||
if (parent != NULL){
|
||||
parent->removeObject(m_player);
|
||||
}
|
||||
}
|
||||
|
||||
void CClientManager::sendWorld(){
|
||||
CWorldObject * parent = (CWorldObject*)m_player->getParent();
|
||||
if (parent != NULL){
|
||||
getProtocol()->sendClearWorld();
|
||||
getProtocol()->sendPlayerInfo(parent->getObjectId());
|
||||
// getProtocol()->sendCell(cell);
|
||||
}
|
||||
}
|
||||
|
||||
void CClientManager::sendBye(WORD reason){
|
||||
getProtocol()->sendBye(reason);
|
||||
}
|
||||
|
||||
void CClientManager::userCommand(WORD command){
|
||||
switch(command){
|
||||
case PLAYERMOVE_STEPFORWARD:
|
||||
m_player->move(0.25);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_STEPBACKWARD:
|
||||
m_player->move(-0.25);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_STEPLEFT:
|
||||
m_player->turn(5.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_STEPRIGHT:
|
||||
m_player->turn(-5.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_MOVEFORWARD:
|
||||
m_player->move(1.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_MOVEBACKWARD:
|
||||
m_player->move(-1.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_MOVELEFT:
|
||||
m_player->turn(10.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_MOVERIGHT:
|
||||
m_player->turn(-10.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_RUNFORWARD:
|
||||
m_player->move(10.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_RUNBACKWARD:
|
||||
m_player->move(-10.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_RUNLEFT:
|
||||
m_player->turn(20.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERMOVE_RUNRIGHT:
|
||||
m_player->turn(-20.0);
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_DEFAULT:
|
||||
m_viewpoint->lookDefault();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_UP:
|
||||
m_viewpoint->lookUp();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_DOWN:
|
||||
m_viewpoint->lookDown();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_RIGHT:
|
||||
m_viewpoint->lookRight();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_LEFT:
|
||||
m_viewpoint->lookLeft();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_FORWARD:
|
||||
m_viewpoint->lookForward();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case PLAYERLOOK_BACKWARD:
|
||||
m_viewpoint->lookBackward();
|
||||
m_viewpoint->update(m_player);
|
||||
getProtocol()->sendViewpoint( m_viewpoint );
|
||||
break;
|
||||
case USERCOMMAND_0:
|
||||
// CWorld * world = getWorld();
|
||||
// movePlayer(world->getCell("City central"));
|
||||
break;
|
||||
case MSGCOMMAND_ONLINE:
|
||||
online();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void CClientManager::updatePosition( CGeometryObject * geometryObject ){
|
||||
getProtocol()->sendUpdatePosition( geometryObject );
|
||||
}
|
||||
|
||||
void CClientManager::updateDirection( CGeometryObject * geometryObject ){
|
||||
getProtocol()->sendUpdateDirection( geometryObject );
|
||||
}
|
||||
|
||||
void CClientManager::sendAddGeometryObject(CGeometryObject * geometryObject){
|
||||
getProtocol()->sendAddGeometryObject(geometryObject);
|
||||
}
|
||||
void CClientManager::sendRemoveGeometryObject(CGeometryObject * geometryObject){
|
||||
getProtocol()->sendRemoveGeometryObject(geometryObject);
|
||||
}
|
||||
*/
|
||||
|
||||
void CClientManager::selection(WORD objectId){
|
||||
CWorldWorld * world = getWorld();
|
||||
CWorldObject * object = world->getObject(objectId);
|
||||
if (m_player->objectReachable( object )){
|
||||
getProtocol()->sendObjectCommands( object );
|
||||
}
|
||||
}
|
||||
|
||||
void CClientManager::action(WORD objectId,WORD actionId){
|
||||
CWorldWorld * world = getWorld();
|
||||
CWorldObject * object = world->getObject(objectId);
|
||||
if (m_player->objectReachable( object )){
|
||||
cdebug << "CWorldObject->action not implemented!!!\n";
|
||||
// object->action(actionId);
|
||||
}
|
||||
}
|
||||
|
||||
void CClientManager::userCommand(char * messageString){
|
||||
cdebug << "MESSAGE FROM CLIENT: " << messageString << "\n";
|
||||
m_commandParser->parseCommand(messageString);
|
||||
}
|
||||
|
||||
void CClientManager::sendMsg(const char *message){
|
||||
getProtocol()->sendMsg(message);
|
||||
}
|
||||
|
||||
void CClientManager::updateMasterCell(CSrvObject * newcell){
|
||||
|
||||
// cdebug << "CClientManager::updateMasterCell: HACK Do not clear world and build world from scratch!!!!\n"
|
||||
// << " Only need to update some cells.\n";
|
||||
// sendWorld();
|
||||
|
||||
// Update client with new cells.
|
||||
getProtocol()->sendPlayerInfo(newcell->getObjectId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
85
server/driver/srvclimanager.H
Normal file
85
server/driver/srvclimanager.H
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLIENTMANAGER_H
|
||||
#define _CLIENTMANAGER_H
|
||||
|
||||
#include "manager.H"
|
||||
#include "objectlist.H"
|
||||
#include "worldworld.H"
|
||||
#include "srvobject.H"
|
||||
#include "player.H"
|
||||
#include "srvviewpoint.H"
|
||||
#include "srvclicmdparser.H"
|
||||
|
||||
#define MANAGER_INIT 0
|
||||
#define MANAGER_LOGIN 1
|
||||
#define MANAGER_PLAYING 2
|
||||
|
||||
class CSrvProtocol;
|
||||
class CMud;
|
||||
|
||||
class CClientManager : public CManager {
|
||||
|
||||
// int m_status;
|
||||
int m_quit;
|
||||
|
||||
CPlayer * m_player;
|
||||
CSrvViewpoint * m_viewpoint;
|
||||
|
||||
CMud * m_mud;
|
||||
CSrvCliCmdParser * m_commandParser;
|
||||
|
||||
public:
|
||||
|
||||
CClientManager(CMud * mud, CSrvProtocol * protocol);
|
||||
virtual ~CClientManager();
|
||||
|
||||
CSrvProtocol * getProtocol(){ return (CSrvProtocol*)CManager::getCommunicate(); }
|
||||
|
||||
void quit();
|
||||
int getQuit(){ return m_quit; }
|
||||
|
||||
CWorldWorld * getWorld();
|
||||
|
||||
void setPlayer(CPlayer * player);
|
||||
|
||||
// Message/Communication rutines
|
||||
void login(char * name,char * passwd,BOOL newUser);
|
||||
void online();
|
||||
void logout();
|
||||
void sendWorld();
|
||||
void sendBye(WORD reason);
|
||||
void userCommand(WORD command);
|
||||
|
||||
void selection(WORD objectId);
|
||||
void action(WORD objectId,WORD actionId);
|
||||
void userCommand(char * messageString);
|
||||
void sendMsg(const char * message);
|
||||
|
||||
virtual void updateMasterCell(CSrvObject * newcell);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* _CLIENTMANAGER_H */
|
||||
|
||||
|
||||
|
||||
|
||||
178
server/driver/srvclimessage.C
Normal file
178
server/driver/srvclimessage.C
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
#include "srvclimanager.H"
|
||||
#include "msgsrvcli.H"
|
||||
#include "msgmsg.H"
|
||||
#include "srvclimessage.H"
|
||||
#include "player.H"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgLoginSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgLoginSrv::CMsgLoginSrv():CMsgLogin(){
|
||||
}
|
||||
|
||||
CMsgLoginSrv * CMsgLoginSrv::createMsg(){
|
||||
return new CMsgLoginSrv();
|
||||
}
|
||||
|
||||
int CMsgLoginSrv::executeMsg(){
|
||||
cdebug << "Execute MsgLoginSrv: Name " << getUserName() << "\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->login(getUserName(),getPasswd(),getNewUser());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgByeSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgByeSrv::CMsgByeSrv():CMsgBye(){
|
||||
}
|
||||
|
||||
CMsgByeSrv * CMsgByeSrv::createMsg(){
|
||||
return new CMsgByeSrv();
|
||||
}
|
||||
|
||||
int CMsgByeSrv::executeMsg(){
|
||||
cdebug << "Execute MsgByeSrv\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->logout();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgGetWorldSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgGetWorldSrv::CMsgGetWorldSrv():CMsgGetWorld(){
|
||||
}
|
||||
|
||||
CMsgGetWorldSrv * CMsgGetWorldSrv::createMsg(){
|
||||
return new CMsgGetWorldSrv();
|
||||
}
|
||||
|
||||
int CMsgGetWorldSrv::executeMsg(){
|
||||
cdebug << "Execute MsgGetWorldSrv\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->sendWorld();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgCommandSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgCommandSrv::CMsgCommandSrv():CMsgCommand(){
|
||||
}
|
||||
|
||||
CMsgCommandSrv * CMsgCommandSrv::createMsg(){
|
||||
return new CMsgCommandSrv();
|
||||
}
|
||||
|
||||
int CMsgCommandSrv::executeMsg(){
|
||||
cdebug << "Execute MsgCommandSrv: " << getCommand() << "\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->userCommand(getCommand());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgSelectionSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgSelectionSrv::CMsgSelectionSrv():CMsgSelection(){
|
||||
}
|
||||
|
||||
CMsgSelectionSrv * CMsgSelectionSrv::createMsg(){
|
||||
return new CMsgSelectionSrv();
|
||||
}
|
||||
|
||||
int CMsgSelectionSrv::executeMsg(){
|
||||
cdebug << "Execute MsgSelectionSrv: " << getObjectId() << "\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->selection(getObjectId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgActionSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgActionSrv::CMsgActionSrv():CMsgAction(){
|
||||
}
|
||||
|
||||
CMsgActionSrv * CMsgActionSrv::createMsg(){
|
||||
return new CMsgActionSrv();
|
||||
}
|
||||
|
||||
int CMsgActionSrv::executeMsg(){
|
||||
cdebug << "Execute MsgActionSrv: object " << getObjectId() << " action "
|
||||
<< getActionId() << "\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->action(getObjectId(),getActionId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgMsgSrv
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgMsgSrv::CMsgMsgSrv():CMsgMsg(){
|
||||
}
|
||||
|
||||
CMsgMsgSrv * CMsgMsgSrv::createMsg(){
|
||||
return new CMsgMsgSrv();
|
||||
}
|
||||
|
||||
int CMsgMsgSrv::executeMsg(){
|
||||
char * msg = (char*)malloc(getMsgLength());
|
||||
getMsg(msg);
|
||||
cout << "Execute MsgMsgSrv: " << msg << "\n";
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->userCommand(msg);
|
||||
free(msg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
73
server/driver/srvclimessage.H
Normal file
73
server/driver/srvclimessage.H
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MESSAGE_SRV_H
|
||||
#define _MESSAGE_SRV_H
|
||||
|
||||
class CMsgLoginSrv: public CMsgLogin {
|
||||
public:
|
||||
CMsgLoginSrv();
|
||||
static CMsgLoginSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgByeSrv: public CMsgBye {
|
||||
public:
|
||||
CMsgByeSrv();
|
||||
static CMsgByeSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgGetWorldSrv: public CMsgGetWorld {
|
||||
public:
|
||||
CMsgGetWorldSrv();
|
||||
static CMsgGetWorldSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCommandSrv: public CMsgCommand {
|
||||
public:
|
||||
CMsgCommandSrv();
|
||||
static CMsgCommandSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgSelectionSrv: public CMsgSelection {
|
||||
public:
|
||||
CMsgSelectionSrv();
|
||||
static CMsgSelectionSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgActionSrv: public CMsgAction {
|
||||
public:
|
||||
CMsgActionSrv();
|
||||
static CMsgActionSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgMsgSrv: public CMsgMsg {
|
||||
public:
|
||||
CMsgMsgSrv();
|
||||
static CMsgMsgSrv * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
#endif // _MESSAGE_SRV_H
|
||||
|
||||
101
server/driver/srvcliprotocol.C
Normal file
101
server/driver/srvcliprotocol.C
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <iostream.h>
|
||||
#include "srvcliprotocol.H"
|
||||
#include "msgmsg.H"
|
||||
#include "srvclimessage.H"
|
||||
#include "msgworld.H"
|
||||
#include "action.H"
|
||||
#include "msgactionlist.H"
|
||||
|
||||
CSrvProtocol::CSrvProtocol(CSocket * socket,CTimeKeeper * timeKeeper) : CCommunicate(socket,timeKeeper) {
|
||||
addMsg((MsgCreateFunc_t)CMsgLoginSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgByeSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgGetWorldSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCommandSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgSelectionSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgActionSrv::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgMsgSrv::createMsg);
|
||||
}
|
||||
|
||||
CSrvProtocol::~CSrvProtocol(){
|
||||
}
|
||||
|
||||
void CSrvProtocol::quit(){
|
||||
CClientManager * manager = (CClientManager*)getManager();
|
||||
manager->quit();
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendHello(){
|
||||
CMsgHello * msg = new CMsgHello(PROTOCOL_VERSION);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendServerInfo(CInetAddress &worldSrvAddress,
|
||||
CInetAddress &gosAddress){
|
||||
CMsgServerInfo * msg = new CMsgServerInfo(worldSrvAddress,gosAddress);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendBye(WORD reason){
|
||||
CMsgBye * msg = new CMsgBye(reason);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendViewpoint(CViewpoint * viewpoint){
|
||||
CMsgViewpoint * msg = new CMsgViewpoint( *viewpoint );
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendClearWorld(){
|
||||
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_CLIENTCLEARWORLD);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendPlayerInfo( DWORD masterCellId ){
|
||||
CMsgPlayerInfo * msg = new CMsgPlayerInfo(masterCellId);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
|
||||
void CSrvProtocol::sendObjectCommands( CWorldObject * object ){
|
||||
CMsgActionList * msg = new CMsgActionList(object->getGeometryId());
|
||||
cdebug << "Get action list in sendObjectCommands not implemented!!!!\n";
|
||||
/*
|
||||
CActionList * actionList = object->getActionList();
|
||||
if (actionList != NULL){
|
||||
CObjectListItem * item = actionList->getFirst();
|
||||
while (item != NULL){
|
||||
CAction * action = (CAction*)item->getObject();
|
||||
msg->addAction(action);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
*/
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvProtocol::sendMsg( const char * message ){
|
||||
CMsgMsg * msg = new CMsgMsg(message);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
|
||||
46
server/driver/srvcliprotocol.H
Normal file
46
server/driver/srvcliprotocol.H
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVPROTOCOL_H
|
||||
#define _SRVPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
#include "socket.H"
|
||||
#include "msgsrvcli.H"
|
||||
#include "srvclimanager.H"
|
||||
#include "viewpoint.H"
|
||||
|
||||
class CSrvProtocol : public CCommunicate {
|
||||
|
||||
public:
|
||||
CSrvProtocol(CSocket * socket,CTimeKeeper * timeKeeper);
|
||||
~CSrvProtocol();
|
||||
virtual void quit();
|
||||
void sendHello();
|
||||
void sendServerInfo(CInetAddress &worldSrvAddress, CInetAddress &gosAddress);
|
||||
void sendBye(WORD reason);
|
||||
void sendViewpoint( CViewpoint * viewpoint );
|
||||
void readClient();
|
||||
void sendClearWorld();
|
||||
void sendPlayerInfo( DWORD masterCellId );
|
||||
void sendObjectCommands( CWorldObject * object );
|
||||
void sendMsg( const char * message );
|
||||
};
|
||||
|
||||
#endif // _SRVPROTOCOL_H
|
||||
46
server/driver/srvclisrvsocket.C
Normal file
46
server/driver/srvclisrvsocket.C
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <iostream.h>
|
||||
#include "srvclisrvsocket.H"
|
||||
#include "srvclimanager.H"
|
||||
#include "srvcliprotocol.H"
|
||||
#include "mud.H"
|
||||
|
||||
CMudSrvSocket::CMudSrvSocket(CMud * mud, int port,CTimeKeeper * timeKeeper)
|
||||
:CServerSocket(port){
|
||||
m_timeKeeper = timeKeeper;
|
||||
m_mud = mud;
|
||||
m_timeKeeper->addFd(getFileDescriptor(),this,TIMEKEEPER_IN);
|
||||
}
|
||||
|
||||
CMudSrvSocket::~CMudSrvSocket(){
|
||||
m_timeKeeper->rmFd(getFileDescriptor());
|
||||
}
|
||||
|
||||
int CMudSrvSocket::timeKeeperFD(int event){
|
||||
CSocket * socket = accept();
|
||||
socket->setNonBlocking();
|
||||
CClientManager * client = new CClientManager(m_mud,new CSrvProtocol(socket,m_timeKeeper));
|
||||
cdebug << "New client: " << socket->getAddress().getAddressString() << "\n";
|
||||
m_mud->addClient(client);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
39
server/driver/srvclisrvsocket.H
Normal file
39
server/driver/srvclisrvsocket.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MUDSRVSOCKET_H
|
||||
#define _MUDSRVSOCKET_H
|
||||
|
||||
#include "socket.H"
|
||||
#include "timekeeper.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CMudSrvSocket : public CServerSocket , public CTimeKeeperItem {
|
||||
CMud * m_mud;
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
public:
|
||||
CMudSrvSocket(CMud * mud, int port,CTimeKeeper * timeKeeper);
|
||||
virtual ~CMudSrvSocket();
|
||||
|
||||
virtual int timeKeeperFD(int event);
|
||||
|
||||
};
|
||||
|
||||
#endif // _MUDSRVSOCKET_H
|
||||
34
server/driver/srvgeocache.C
Normal file
34
server/driver/srvgeocache.C
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvgeocache.H"
|
||||
#include "mud.H"
|
||||
#include "msggos.H"
|
||||
|
||||
CSrvGEOCache::CSrvGEOCache(CMud * mud){
|
||||
m_mud = mud;
|
||||
}
|
||||
|
||||
CObject * CSrvGEOCache::failFunc(int id){
|
||||
m_mud->request(GOSREQUEST_GEOMETRY,id);
|
||||
CCache::add(id,NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
36
server/driver/srvgeocache.H
Normal file
36
server/driver/srvgeocache.H
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGEOCACHE_H
|
||||
#define _SRVGEOCACHE_H
|
||||
|
||||
#include "cache.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvGEOCache : public CCache {
|
||||
CMud * m_mud;
|
||||
public:
|
||||
CSrvGEOCache(CMud * mud);
|
||||
|
||||
virtual CObject * failFunc(int id);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGEOCACHE_H
|
||||
45
server/driver/srvgos.C
Normal file
45
server/driver/srvgos.C
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvgos.H"
|
||||
#include "mud.H"
|
||||
|
||||
CSrvGOS::CSrvGOS(CMud * mud,CTimeKeeper * timeKeeper, CInetAddress *addr):CGOS(timeKeeper,addr){
|
||||
m_mud = mud;
|
||||
}
|
||||
|
||||
void CSrvGOS::error(){
|
||||
m_mud->error();
|
||||
}
|
||||
|
||||
void CSrvGOS::geometry(CGeometry * geometry){
|
||||
m_mud->geometry(geometry);
|
||||
}
|
||||
|
||||
void CSrvGOS::material(CMaterial * material){
|
||||
m_mud->material(material);
|
||||
}
|
||||
|
||||
void CSrvGOS::texture(CTexture * texture){
|
||||
m_mud->texture(texture);
|
||||
}
|
||||
|
||||
|
||||
|
||||
39
server/driver/srvgos.H
Normal file
39
server/driver/srvgos.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOS_H
|
||||
#define _SRVGOS_H
|
||||
|
||||
#include "gos.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvGOS : public CGOS {
|
||||
CMud * m_mud;
|
||||
public:
|
||||
CSrvGOS(CMud * mud,CTimeKeeper * timeKeeper, CInetAddress *addr);
|
||||
|
||||
virtual void error();
|
||||
virtual void geometry(CGeometry * geometry);
|
||||
virtual void material(CMaterial * material);
|
||||
virtual void texture(CTexture * texture);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGOS_H
|
||||
83
server/driver/srvgosmanager.C
Normal file
83
server/driver/srvgosmanager.C
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <iostream.h>
|
||||
#include "srvgosmanager.H"
|
||||
#include "mud.H"
|
||||
|
||||
#define GOSSTATE_LOGIN 1
|
||||
#define GOSSTATE_QUIT 2
|
||||
#define GOSSTATE_ONLINE 3
|
||||
#define GOSSTATE_RUNNING 4
|
||||
|
||||
CSrvGOSManager::CSrvGOSManager(CMud * mud, CSrvGOSProtocol * protocol): CManager(protocol){
|
||||
m_mud = mud;
|
||||
m_state = GOSSTATE_LOGIN;
|
||||
m_numberOfClients = 0;
|
||||
getProtocol()->setName("GOS Srv");
|
||||
getProtocol()->sendHello();
|
||||
}
|
||||
|
||||
CSrvGOSProtocol * CSrvGOSManager::getProtocol() {
|
||||
return (CSrvGOSProtocol*)CManager::getCommunicate();
|
||||
}
|
||||
|
||||
int CSrvGOSManager::getQuit(){
|
||||
return m_state == GOSSTATE_QUIT;
|
||||
}
|
||||
|
||||
int CSrvGOSManager::getOnLine(){
|
||||
return m_state == GOSSTATE_ONLINE;
|
||||
}
|
||||
|
||||
int CSrvGOSManager::getRunning(){
|
||||
return m_state == GOSSTATE_RUNNING;
|
||||
}
|
||||
|
||||
void CSrvGOSManager::setRunning(){
|
||||
m_state = GOSSTATE_RUNNING;
|
||||
}
|
||||
|
||||
int CSrvGOSManager::getNumClients(){
|
||||
return m_numberOfClients;
|
||||
}
|
||||
|
||||
int CSrvGOSManager::addNumClients(int add){
|
||||
return m_numberOfClients += add;
|
||||
}
|
||||
|
||||
CInetAddress * CSrvGOSManager::getAddress(){
|
||||
return m_gosAddress;
|
||||
}
|
||||
|
||||
void CSrvGOSManager::quit(){
|
||||
m_state = GOSSTATE_QUIT;
|
||||
m_mud->markGOS();
|
||||
}
|
||||
|
||||
|
||||
void CSrvGOSManager::login(CInetAddress * gosAddress){
|
||||
m_gosAddress = gosAddress;
|
||||
m_state = GOSSTATE_ONLINE;
|
||||
m_mud->markGOS();
|
||||
cdebug << "GOS online at address: " << m_gosAddress->getAddressString() << "\n";
|
||||
}
|
||||
|
||||
|
||||
54
server/driver/srvgosmanager.H
Normal file
54
server/driver/srvgosmanager.H
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOSMANAGER_H
|
||||
#define _SRVGOSMANAGER_H
|
||||
|
||||
#include "manager.H"
|
||||
#include "srvgosprotocol.H"
|
||||
#include "inetaddress.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvGOSManager : public CManager {
|
||||
|
||||
CMud * m_mud;
|
||||
int m_state;
|
||||
CInetAddress * m_gosAddress;
|
||||
int m_numberOfClients;
|
||||
|
||||
public:
|
||||
CSrvGOSManager(CMud * mud, CSrvGOSProtocol * protocol);
|
||||
CSrvGOSProtocol * getProtocol();
|
||||
|
||||
int getQuit();
|
||||
int getOnLine();
|
||||
int getRunning();
|
||||
void setRunning();
|
||||
int getNumClients();
|
||||
int addNumClients(int add = 1);
|
||||
CInetAddress * getAddress();
|
||||
|
||||
void quit();
|
||||
|
||||
void login(CInetAddress * gosAddress);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGOSMANAGER_H
|
||||
37
server/driver/srvgosmessage.C
Normal file
37
server/driver/srvgosmessage.C
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvgosmessage.H"
|
||||
#include "srvgosmanager.H"
|
||||
|
||||
CMsgSrvGOSLogin::CMsgSrvGOSLogin():CMsgServerLogin(){
|
||||
}
|
||||
|
||||
CMsgSrvGOSLogin * CMsgSrvGOSLogin::createMsg(){
|
||||
return new CMsgSrvGOSLogin();
|
||||
}
|
||||
|
||||
|
||||
int CMsgSrvGOSLogin::executeMsg(){
|
||||
CSrvGOSManager * manager = (CSrvGOSManager*)getManager();
|
||||
manager->login(getAddress());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
34
server/driver/srvgosmessage.H
Normal file
34
server/driver/srvgosmessage.H
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOSMESSAGE_H
|
||||
#define _SRVGOSMESSAGE_H
|
||||
|
||||
#include "msgserver.H"
|
||||
#include "msgsrvgos.H"
|
||||
|
||||
class CMsgSrvGOSLogin : public CMsgServerLogin {
|
||||
|
||||
public:
|
||||
CMsgSrvGOSLogin();
|
||||
static CMsgSrvGOSLogin * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
#endif // _SRVGOSMESSAGE_H
|
||||
41
server/driver/srvgosprotocol.C
Normal file
41
server/driver/srvgosprotocol.C
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvgosprotocol.H"
|
||||
#include "srvgosmanager.H"
|
||||
#include "srvgosmessage.H"
|
||||
#include "msgsrvcli.H"
|
||||
|
||||
CSrvGOSProtocol::CSrvGOSProtocol(CSocket * socket, CTimeKeeper * timeKeeper):
|
||||
CCommunicate(socket,timeKeeper){
|
||||
addMsg((MsgCreateFunc_t)CMsgSrvGOSLogin::createMsg);
|
||||
}
|
||||
|
||||
void CSrvGOSProtocol::quit(){
|
||||
CSrvGOSManager * manager = (CSrvGOSManager*)getManager();
|
||||
|
||||
manager->quit();
|
||||
}
|
||||
|
||||
void CSrvGOSProtocol::sendHello(){
|
||||
CMsgHello * msg = new CMsgHello(PROTOCOL_VERSION);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
36
server/driver/srvgosprotocol.H
Normal file
36
server/driver/srvgosprotocol.H
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOSPROTOCOL_H
|
||||
#define _SRVGOSPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
|
||||
class CSrvGOSProtocol: public CCommunicate {
|
||||
|
||||
public:
|
||||
CSrvGOSProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
|
||||
|
||||
virtual void quit();
|
||||
|
||||
void sendHello();
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGOSPROTOCOL_H
|
||||
53
server/driver/srvgossrvsocket.C
Normal file
53
server/driver/srvgossrvsocket.C
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <iostream.h>
|
||||
#include "srvgossrvsocket.H"
|
||||
#include "srvgosmanager.H"
|
||||
#include "srvgosprotocol.H"
|
||||
#include "mud.H"
|
||||
|
||||
CSrvGOSSrvSocket::CSrvGOSSrvSocket(CMud * mud,int port, CTimeKeeper * timeKeeper):CServerSocket(port){
|
||||
m_timeKeeper = timeKeeper;
|
||||
m_mud = mud;
|
||||
m_timeKeeper->addFd(getFileDescriptor(),this,TIMEKEEPER_IN);
|
||||
}
|
||||
|
||||
CSrvGOSSrvSocket::~CSrvGOSSrvSocket(){
|
||||
m_timeKeeper->rmFd(getFileDescriptor());
|
||||
}
|
||||
|
||||
int CSrvGOSSrvSocket::timeKeeperFD(int event){
|
||||
CSocket * socket;
|
||||
try {
|
||||
socket = accept();
|
||||
socket->setNonBlocking();
|
||||
} catch (CException * e){
|
||||
cdebug << *e << "\n";
|
||||
delete e;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CSrvGOSManager * gos = new CSrvGOSManager(m_mud,new CSrvGOSProtocol(socket,m_timeKeeper));
|
||||
cdebug << "New gos: " << socket->getAddress().getAddressString() << "\n";
|
||||
m_mud->addGOS(gos);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
39
server/driver/srvgossrvsocket.H
Normal file
39
server/driver/srvgossrvsocket.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOSSRVSOCKET_H
|
||||
#define _SRVGOSSRVSOCKET_H
|
||||
|
||||
#include "socket.H"
|
||||
#include "timekeeper.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvGOSSrvSocket : CServerSocket , public CTimeKeeperItem {
|
||||
CMud * m_mud;
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
public:
|
||||
CSrvGOSSrvSocket(CMud * mud,int port, CTimeKeeper * timeKeeper);
|
||||
virtual ~CSrvGOSSrvSocket();
|
||||
|
||||
virtual int timeKeeperFD(int event);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGOSSRVSOCKET_H
|
||||
113
server/driver/srvlistenerlist.C
Normal file
113
server/driver/srvlistenerlist.C
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvlistenerlist.H"
|
||||
#include "srvworldmanager.H"
|
||||
|
||||
CSrvListenerList::CSrvListenerList(){
|
||||
}
|
||||
|
||||
void CSrvListenerList::add( CSrvWorldManager * listener ){
|
||||
addLast((CObject*)listener);
|
||||
}
|
||||
|
||||
void CSrvListenerList::remove( CSrvWorldManager * listener ){
|
||||
CObjectList::remove((CObject*)listener);
|
||||
}
|
||||
|
||||
void CSrvListenerList::sendAnimation(CWorldAnimation * animation ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
listener->sendAnimation(animation);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void CSrvListenerList::addCell(CWorldObject * cell ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
listener->sendAddCell((CSrvObject*)cell);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvListenerList::removeCell(CWorldObject * cell ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
listener->sendRemoveCell((CSrvObject*)cell);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvListenerList::addObject( CWorldObject * object ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
listener->sendAddObject((CSrvObject*)object);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvListenerList::removeObject( CWorldObject * object ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
listener->sendRemoveObject((CSrvObject*)object);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void CSrvListenerList::updatePosition( CWorldObject * object ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
listener->sendUpdatePosition( (CSrvObject*)object );
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvListenerList::updateDirection( CWorldObject * object ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
listener->sendUpdateDirection( (CSrvObject*)object );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvListenerList::updateHierarchy( CWorldObject * object ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvWorldManager * listener = (CSrvWorldManager*)item->getObject();
|
||||
item = item->getNext();
|
||||
listener->sendUpdateHierarchy( (CSrvObject*)object );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
51
server/driver/srvlistenerlist.H
Normal file
51
server/driver/srvlistenerlist.H
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVLISTENERLIST_H
|
||||
#define _SRVLISTENERLIST_H
|
||||
|
||||
#include "objectlist.H"
|
||||
#include "srvworld.H"
|
||||
|
||||
class CSrvWorldManager;
|
||||
|
||||
class CSrvListenerList : private CObjectList, public CListener {
|
||||
|
||||
public:
|
||||
CSrvListenerList();
|
||||
|
||||
void add( CSrvWorldManager * listener );
|
||||
void remove( CSrvWorldManager * listener );
|
||||
|
||||
// Abstract function from CListener
|
||||
void sendAnimation(CWorldAnimation * animation);
|
||||
|
||||
// void addCell( CWorldObject * cell );
|
||||
// void removeCell( CWorldObject * cell );
|
||||
// void addObject( CWorldObject * object );
|
||||
// void removeObject( CWorldObject * object );
|
||||
|
||||
// void updatePosition( CWorldObject * object );
|
||||
// void updateDirection( CWorldObject * object );
|
||||
|
||||
void updateHierarchy( CWorldObject * object );
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVLISTENERLIST_H
|
||||
131
server/driver/srvobject.C
Normal file
131
server/driver/srvobject.C
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvobject.H"
|
||||
#include "srvworldmanager.H"
|
||||
#include "srvlistenerlist.H"
|
||||
#include "mud.H"
|
||||
|
||||
|
||||
CSrvObject::CSrvObject(DWORD objectId,CWorldHierarchy * parent, DWORD geometryId,const CPosition & position, const CDirection & direction )
|
||||
:CWorldObject(objectId,parent,geometryId,position,direction){
|
||||
|
||||
m_geometry = NULL;
|
||||
|
||||
}
|
||||
|
||||
CSrvObject::~CSrvObject(){
|
||||
}
|
||||
|
||||
CListener * CSrvObject::getListener(){
|
||||
return ((CSrvWorld*)getWorld())->getListenerList();
|
||||
}
|
||||
|
||||
CGeometry * CSrvObject::getGeometry(){
|
||||
if (m_geometry == NULL){
|
||||
m_geometry = getMud()->getGeometry(getGeometryId());
|
||||
}
|
||||
return m_geometry;
|
||||
}
|
||||
|
||||
CMud * CSrvObject::getMud(){
|
||||
return ((CSrvWorld*)getWorld())->getMud();
|
||||
}
|
||||
|
||||
CSrvObject * CSrvObject::createObject(char * objectName, DWORD geometryId, const CPosition & position, const CDirection & direction, char * name)
|
||||
{
|
||||
|
||||
CSrvObject * object = (CSrvObject*)CWorldObject::createObject(
|
||||
objectName,((CSrvWorld*)getWorld())->getNewObjectId(),geometryId,
|
||||
position,direction);
|
||||
|
||||
object->setName(name);
|
||||
return object;
|
||||
}
|
||||
|
||||
// Include this in CMovingObject
|
||||
void CSrvObject::updatePosition( const CPosition & position ){
|
||||
|
||||
cdebug << "CSrvObject::updatePosition " << position << endl;
|
||||
|
||||
CSrvObject * masterCell = (CSrvObject*)getMasterCell();
|
||||
CPosition newpos = position;
|
||||
|
||||
if ((masterCell != NULL) && (!masterCell->checkPosition(position))){
|
||||
cdebug << "Object " << getName() << " is outside boundary of "
|
||||
<< masterCell->getName() << "!\n";
|
||||
CCellPVS * cellPVS = masterCell->getPVS();
|
||||
CSrvObject * newCell;
|
||||
// Find new cell and new position. If this fails return.
|
||||
if ((newCell = (CSrvObject*)cellPVS->findCell(&newpos))== NULL) return;
|
||||
moveTo(newCell);
|
||||
}
|
||||
|
||||
CWorldObject::updatePosition(newpos);
|
||||
}
|
||||
|
||||
/* void CSrvObject::sendCell( CSrvWorldManager * listener ){
|
||||
listener->sendAddCell( this );
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvObject * object = (CSrvObject*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
object->sendObject( listener );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvObject::sendObject( CSrvWorldManager * listener ){
|
||||
listener->sendAddObject( this );
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvObject * object = (CSrvObject*)item->getObject();
|
||||
item = item->getNext();
|
||||
object->sendObject( listener );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CDoubleArray * CSrvObject::getDistances(const CBeam & beam, double max, double min){
|
||||
CDoubleArray * result = new CDoubleArray();
|
||||
distances(*result,beam,max,min);
|
||||
|
||||
CCellPVS * pvs = getPVS();
|
||||
CObjectListItem * item = pvs->getFirstPVCell();
|
||||
while (item != NULL){
|
||||
CPVCell * pv = (CPVCell*)item->getObject();
|
||||
|
||||
int cellId = pv->getCellId();
|
||||
|
||||
CSrvObject * cell = (CSrvObject*)getWorld()->getObject(cellId);
|
||||
if (cell != NULL){
|
||||
CBeam pvBeam = beam + pv->getPosition();
|
||||
cell->distances(*result,pvBeam,max,min);
|
||||
}
|
||||
|
||||
item = item->getNext();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
57
server/driver/srvobject.H
Normal file
57
server/driver/srvobject.H
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVOBJECT_H
|
||||
#define _SRVOBJECT_H
|
||||
|
||||
#include "worldobject.H"
|
||||
#include "doublearray.H"
|
||||
#include "beam.H"
|
||||
#include "geometry.H"
|
||||
|
||||
class CSrvWorldManager;
|
||||
class CSrvListenerList;
|
||||
class CMud;
|
||||
|
||||
class CSrvObject : public CWorldObject {
|
||||
|
||||
CGeometry * m_geometry;
|
||||
|
||||
public:
|
||||
CSrvObject(DWORD objectId, CWorldHierarchy * parent, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
virtual ~CSrvObject();
|
||||
|
||||
CListener * getListener();
|
||||
virtual CGeometry * getGeometry();
|
||||
CMud * getMud();
|
||||
|
||||
virtual void updatePosition( const CPosition & position );
|
||||
|
||||
CSrvObject * createObject(char * objectName, DWORD geometryId, const CPosition & position, const CDirection & direction, char * name);
|
||||
|
||||
|
||||
// void sendCell( CSrvWorldManager * listener );
|
||||
void sendObject( CSrvWorldManager * listener );
|
||||
|
||||
CDoubleArray * getDistances(const CBeam & beam, double min, double max);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVOBJECT_H
|
||||
54
server/driver/srvviewpoint.C
Normal file
54
server/driver/srvviewpoint.C
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include "srvviewpoint.H"
|
||||
|
||||
CSrvViewpoint::CSrvViewpoint():CViewpoint(){
|
||||
}
|
||||
|
||||
CSrvViewpoint::~CSrvViewpoint(){
|
||||
}
|
||||
|
||||
//void CSrvViewpoint::update( CSrvObject * target ){
|
||||
void CSrvViewpoint::update( CWorldObject * target ){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookDefault(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookUp(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookDown(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookRight(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookLeft(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookForward(){
|
||||
}
|
||||
|
||||
void CSrvViewpoint::lookBackward(){
|
||||
}
|
||||
|
||||
|
||||
47
server/driver/srvviewpoint.H
Normal file
47
server/driver/srvviewpoint.H
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVVIEWPOINT_H
|
||||
#define _SRVVIEWPOINT_H
|
||||
|
||||
#include "viewpoint.H"
|
||||
//#include "srvobject.H"
|
||||
#include "worldobject.H"
|
||||
|
||||
class CSrvViewpoint: public CViewpoint {
|
||||
public:
|
||||
double persionHeight;
|
||||
|
||||
public:
|
||||
CSrvViewpoint();
|
||||
virtual ~CSrvViewpoint();
|
||||
|
||||
// virtual void update(CSrvObject * target);
|
||||
virtual void update(CWorldObject * target);
|
||||
virtual void lookDefault();
|
||||
virtual void lookUp();
|
||||
virtual void lookDown();
|
||||
virtual void lookRight();
|
||||
virtual void lookLeft();
|
||||
virtual void lookForward();
|
||||
virtual void lookBackward();
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVVIEWPOINT_H
|
||||
163
server/driver/srvworld.C
Normal file
163
server/driver/srvworld.C
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvworld.H"
|
||||
#include "srvlistenerlist.H"
|
||||
#include "srvworldmanager.H"
|
||||
#include "player.H"
|
||||
#include "mud.H"
|
||||
|
||||
CSrvWorld::CSrvWorld(CMud * mud):CWorldWorld(){
|
||||
m_listenerList = new CSrvListenerList();
|
||||
m_nextObjectId = 10000; // User defined id's under 10000
|
||||
m_mud = mud;
|
||||
}
|
||||
|
||||
CSrvWorld::~CSrvWorld(){
|
||||
delete m_listenerList;
|
||||
}
|
||||
|
||||
CListener * CSrvWorld::getListener(){
|
||||
return getListenerList();
|
||||
}
|
||||
|
||||
CMud * CSrvWorld::getMud(){
|
||||
return m_mud;
|
||||
}
|
||||
|
||||
CWorldObject * CSrvWorld::newObject(char * objectName,DWORD objectId,
|
||||
CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction )
|
||||
{
|
||||
|
||||
if (parent == NULL){
|
||||
return new CSrvObject(objectId,this,geometryId,position,direction);
|
||||
}
|
||||
|
||||
if (strcmp(objectName,"player")==0){
|
||||
cdebug << "New player " << objectId << " geometry " << geometryId << "\n";
|
||||
return new CPlayer(objectId,parent,geometryId,position,direction);
|
||||
}
|
||||
|
||||
// Default return new SrvObject
|
||||
cdebug << "New object " << objectId << " geometry " << geometryId << "\n";
|
||||
return new CSrvObject(objectId,parent,geometryId,position,direction);
|
||||
|
||||
}
|
||||
|
||||
DWORD CSrvWorld::getNewObjectId(){
|
||||
return m_nextObjectId++;
|
||||
}
|
||||
|
||||
void CSrvWorld::addListener( CSrvWorldManager * listener ){
|
||||
m_listenerList->add( listener );
|
||||
}
|
||||
|
||||
void CSrvWorld::removeListener( CSrvWorldManager * listener ){
|
||||
m_listenerList->remove( listener );
|
||||
}
|
||||
|
||||
CSrvListenerList * CSrvWorld::getListenerList(){
|
||||
return m_listenerList;
|
||||
}
|
||||
|
||||
void CSrvWorld::sendWorld( CSrvWorldManager * listener ){
|
||||
listener->sendAddWorld(this);
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CSrvObject * cell = (CSrvObject*)item->getObject();
|
||||
item = item->getNext();
|
||||
cell->sendObject( listener );
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvWorld::loadObjects(FILE * cellFile,CWorldObject * parent,int numObjects){
|
||||
int ii;
|
||||
for (ii = 0; ii < numObjects; ii++){
|
||||
int geometryId,numChildren;
|
||||
double posx,posy,posz;
|
||||
char objectType[256];
|
||||
char objectName[256];
|
||||
if (fscanf(cellFile,"%s %i %lf %lf %lf %s %i\n",objectType,&geometryId,&posx,&posy,&posz,objectName,&numChildren)==7){
|
||||
printf(" Obj: %s geometryId %i\n",objectType,geometryId);
|
||||
CWorldObject * object = parent->createObject(objectType,getNewObjectId(),geometryId,CPosition(posx,posy,posz),CDirection(0.0,0.0,0.0));
|
||||
parent->addObject( object );
|
||||
object->setName(objectName);
|
||||
loadObjects(cellFile,object,numChildren);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSrvWorld::loadWorld( char * worldFilePath ){
|
||||
char worldFileName[256];
|
||||
int cellId,numPVS;
|
||||
char cellName[256];
|
||||
char cellFileName[256];
|
||||
int pvsId;
|
||||
double posx,posy,posz;
|
||||
|
||||
// Find and open world file
|
||||
sprintf(worldFileName,"%s/world",worldFilePath);
|
||||
FILE * worldFile = fopen(worldFileName,"r");
|
||||
if (worldFile == NULL) {
|
||||
printf("Failed to open file: %s\n",worldFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read sections from world
|
||||
while (fscanf(worldFile,"%i %s %i\n",&cellId,cellName,&numPVS)==3){
|
||||
printf(" Cell: %s(%i) with %i pvs's\n",cellName,cellId,numPVS);
|
||||
|
||||
// Load cell
|
||||
sprintf(cellFileName,"%s/%s",worldFilePath,cellName);
|
||||
FILE * cellFile = fopen(cellFileName,"r");
|
||||
if (cellFile != NULL){
|
||||
int geometryId,numChildren;
|
||||
char objectType[256];
|
||||
CSrvObject * cell;
|
||||
if (fscanf(cellFile,"%s %i %lf %lf %lf %i\n",objectType,&geometryId,&posx,&posy,&posz,&numChildren)==6){
|
||||
printf(" Obj: %s geometryId %i\n",objectType,geometryId);
|
||||
|
||||
cell = (CSrvObject*)createObject(-1,objectType,cellId,geometryId,CPosition(0,0,0),CDirection(0,0,0));
|
||||
|
||||
// Hack have to create this from input files or geometry files
|
||||
cell->setBBox(new CBBox(-250,-250,0,250,250,300));
|
||||
cell->setName(cellName);
|
||||
|
||||
loadObjects(cellFile,cell,numChildren);
|
||||
}
|
||||
|
||||
// Load PVS
|
||||
while ((numPVS-- > 0) && (fscanf(worldFile,"%i %lf %lf %lf\n",&pvsId,&posx,&posy,&posz)==4)){
|
||||
printf(" PVS: %i %f %f %f\n",pvsId,posx,posy,posz);
|
||||
cell->addPVCell(pvsId,CPosition(posx,posy,posz));
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("Failed to load cell\n");
|
||||
}
|
||||
|
||||
}
|
||||
fclose(worldFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
65
server/driver/srvworld.H
Normal file
65
server/driver/srvworld.H
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVWORLD_H
|
||||
#define _SRVWORLD_H
|
||||
|
||||
#include "worldworld.H"
|
||||
#include "srvobject.H"
|
||||
|
||||
class CSrvListenerList;
|
||||
class CSrvWorldManger;
|
||||
class CMud;
|
||||
|
||||
class CSrvWorld : public CWorldWorld {
|
||||
|
||||
CSrvListenerList * m_listenerList;
|
||||
|
||||
DWORD m_nextObjectId;
|
||||
|
||||
CMud * m_mud;
|
||||
|
||||
public:
|
||||
CSrvWorld(CMud * mud);
|
||||
virtual ~CSrvWorld();
|
||||
|
||||
virtual CListener * getListener();
|
||||
|
||||
CMud * getMud();
|
||||
|
||||
virtual CWorldObject * newObject(char * objectName,DWORD objectId,
|
||||
CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
|
||||
DWORD getNewObjectId();
|
||||
|
||||
void addListener( CSrvWorldManager * listener );
|
||||
void removeListener( CSrvWorldManager * listener );
|
||||
|
||||
CSrvListenerList * getListenerList();
|
||||
|
||||
void sendWorld( CSrvWorldManager * listener );
|
||||
|
||||
private:
|
||||
void loadObjects(FILE * cellFile,CWorldObject * parent,int numObjects);
|
||||
public:
|
||||
void loadWorld( char * worldFilePath );
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVWORLD_H
|
||||
145
server/driver/srvworldmanager.C
Normal file
145
server/driver/srvworldmanager.C
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <iostream.h>
|
||||
#include "srvworldmanager.H"
|
||||
#include "mud.H"
|
||||
|
||||
#define WORLDSTATE_LOGIN 1
|
||||
#define WORLDSTATE_QUIT 2
|
||||
#define WORLDSTATE_ONLINE 3
|
||||
#define WORLDSTATE_RUNNING 4
|
||||
|
||||
CSrvWorldManager::CSrvWorldManager(CMud * mud, CSrvWorldProtocol * protocol): CManager(protocol){
|
||||
m_mud = mud;
|
||||
m_state = WORLDSTATE_LOGIN;
|
||||
m_numberOfClients = 0;
|
||||
getProtocol()->setName("World");
|
||||
getProtocol()->sendHello();
|
||||
}
|
||||
|
||||
CSrvWorldProtocol * CSrvWorldManager::getProtocol() {
|
||||
return (CSrvWorldProtocol*)CManager::getCommunicate();
|
||||
}
|
||||
|
||||
int CSrvWorldManager::getQuit(){
|
||||
return m_state == WORLDSTATE_QUIT;
|
||||
}
|
||||
|
||||
int CSrvWorldManager::getOnLine(){
|
||||
return m_state == WORLDSTATE_ONLINE;
|
||||
}
|
||||
|
||||
int CSrvWorldManager::getRunning(){
|
||||
return m_state == WORLDSTATE_RUNNING;
|
||||
}
|
||||
|
||||
void CSrvWorldManager::setRunning(){
|
||||
m_state = WORLDSTATE_RUNNING;
|
||||
}
|
||||
|
||||
int CSrvWorldManager::getNumClients(){
|
||||
return m_numberOfClients;
|
||||
}
|
||||
|
||||
int CSrvWorldManager::addNumClients(int add){
|
||||
return m_numberOfClients += add;
|
||||
}
|
||||
|
||||
CInetAddress * CSrvWorldManager::getAddress(){
|
||||
return m_worldAddress;
|
||||
}
|
||||
|
||||
void CSrvWorldManager::quit(){
|
||||
m_state = WORLDSTATE_QUIT;
|
||||
m_mud->markWorld();
|
||||
}
|
||||
|
||||
|
||||
void CSrvWorldManager::login(CInetAddress * worldAddress){
|
||||
static CInetAddress noAddr;
|
||||
|
||||
m_worldAddress = worldAddress;
|
||||
m_state = WORLDSTATE_ONLINE;
|
||||
m_mud->markWorld();
|
||||
cdebug << "WorldSrv online at address: " << m_worldAddress->getAddressString() << "\n";
|
||||
|
||||
CInetAddress * gosAddr = m_mud->getGOSAddress();
|
||||
if (gosAddr == NULL) gosAddr = &noAddr;
|
||||
|
||||
getProtocol()->sendGOSInfo(*gosAddr);
|
||||
|
||||
}
|
||||
|
||||
void CSrvWorldManager::ping( BYTE sequenceNumber){
|
||||
DWORD time = m_mud->getWorld()->getTime();
|
||||
cdebug << "Send pong: sequence number " << (int)sequenceNumber << " server time : " << time << endl;
|
||||
getProtocol()->sendPong(sequenceNumber,time);
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendAddWorld( CSrvWorld * world){
|
||||
getProtocol()->sendAddWorld();
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendRemoveWorld( CSrvWorld * world){
|
||||
getProtocol()->sendRemoveWorld();
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendAnimation( CWorldAnimation * animation){
|
||||
getProtocol()->sendAnimation(animation);
|
||||
}
|
||||
|
||||
/*
|
||||
void CSrvWorldManager::sendAddCell( CSrvObject * cell){
|
||||
getProtocol()->sendAddCell(cell);
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendRemoveCell( CSrvObject * cell){
|
||||
getProtocol()->sendRemoveCell(cell);
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvWorldManager::sendCellPVS( CSrvObject * cell){
|
||||
getProtocol()->sendCellPVS(cell);
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendAddObject( CSrvObject * object){
|
||||
getProtocol()->sendAddObject(object);
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendRemoveObject( CSrvObject * object){
|
||||
getProtocol()->sendRemoveObject(object);
|
||||
}
|
||||
|
||||
/*
|
||||
void CSrvWorldManager::sendUpdatePosition( CSrvObject * object ){
|
||||
getProtocol()->sendUpdatePosition(object);
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvWorldManager::sendUpdateDirection( CSrvObject * object ){
|
||||
getProtocol()->sendUpdateDirection(object);
|
||||
}
|
||||
|
||||
void CSrvWorldManager::sendUpdateHierarchy( CSrvObject * object ){
|
||||
getProtocol()->sendUpdateHierarchy(object);
|
||||
}
|
||||
|
||||
|
||||
77
server/driver/srvworldmanager.H
Normal file
77
server/driver/srvworldmanager.H
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVWORLDMANAGER_H
|
||||
#define _SRVWORLDMANAGER_H
|
||||
|
||||
#include "manager.H"
|
||||
#include "srvworldprotocol.H"
|
||||
#include "inetaddress.H"
|
||||
|
||||
//#include "worldlistener.H"
|
||||
#include "srvworld.H"
|
||||
//#include "geometryobject.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvWorldManager : public CManager {
|
||||
|
||||
CMud * m_mud;
|
||||
int m_state;
|
||||
CInetAddress * m_worldAddress;
|
||||
int m_numberOfClients;
|
||||
|
||||
public:
|
||||
CSrvWorldManager(CMud * mud, CSrvWorldProtocol * protocol);
|
||||
CSrvWorldProtocol * getProtocol();
|
||||
|
||||
int getQuit();
|
||||
int getOnLine();
|
||||
int getRunning();
|
||||
void setRunning();
|
||||
int getNumClients();
|
||||
int addNumClients(int add = 1);
|
||||
CInetAddress * getAddress();
|
||||
|
||||
void quit();
|
||||
|
||||
void login(CInetAddress * worldAddress);
|
||||
void ping(BYTE sequenceNumber);
|
||||
|
||||
// WorldListener
|
||||
void sendAnimation( CWorldAnimation * animation);
|
||||
void sendAddWorld( CSrvWorld * world);
|
||||
void sendRemoveWorld( CSrvWorld * world);
|
||||
// void sendAddCell( CSrvObject * cell);
|
||||
// void sendRemoveCell( CSrvObject * cell);
|
||||
void sendCellPVS( CSrvObject * cell);
|
||||
void sendAddObject( CSrvObject * object);
|
||||
void sendRemoveObject( CSrvObject * object);
|
||||
// void sendUpdatePosition( CSrvObject * object );
|
||||
void sendUpdateDirection( CSrvObject * object );
|
||||
void sendUpdateHierarchy( CSrvObject * object );
|
||||
|
||||
|
||||
// virtual void sendAddGeometryObject(CGeometryObject * geometryObject);
|
||||
// virtual void sendRemoveGeometryObject(CGeometryObject * geometryObject);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVWORLDMANAGER_H
|
||||
57
server/driver/srvworldmessage.C
Normal file
57
server/driver/srvworldmessage.C
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvworldmessage.H"
|
||||
#include "srvworldmanager.H"
|
||||
|
||||
CMsgSrvWorldLogin::CMsgSrvWorldLogin():CMsgServerLogin(){
|
||||
}
|
||||
|
||||
CMsgSrvWorldLogin * CMsgSrvWorldLogin::createMsg(){
|
||||
return new CMsgSrvWorldLogin();
|
||||
}
|
||||
|
||||
|
||||
int CMsgSrvWorldLogin::executeMsg(){
|
||||
CSrvWorldManager * manager = (CSrvWorldManager*)getManager();
|
||||
manager->login(getAddress());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* CMsgSrvWorldPing
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMsgSrvWorldPing::CMsgSrvWorldPing():CMsgPing(){
|
||||
}
|
||||
|
||||
CMsgSrvWorldPing * CMsgSrvWorldPing::createMsg(){
|
||||
return new CMsgSrvWorldPing();
|
||||
}
|
||||
|
||||
int CMsgSrvWorldPing::executeMsg(){
|
||||
cout << "Execute MsgSrvWorldPing: SequenceNumber " << (int)getSequenceNumber() << endl;
|
||||
CSrvWorldManager * manager = (CSrvWorldManager*)getManager();
|
||||
manager->ping(getSequenceNumber());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
42
server/driver/srvworldmessage.H
Normal file
42
server/driver/srvworldmessage.H
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVWORLDMESSAGE_H
|
||||
#define _SRVWORLDMESSAGE_H
|
||||
|
||||
#include "msgserver.H"
|
||||
#include "msgsrvcli.H"
|
||||
|
||||
class CMsgSrvWorldLogin : public CMsgServerLogin {
|
||||
|
||||
public:
|
||||
CMsgSrvWorldLogin();
|
||||
static CMsgSrvWorldLogin * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgSrvWorldPing: public CMsgPing {
|
||||
public:
|
||||
CMsgSrvWorldPing();
|
||||
static CMsgSrvWorldPing* createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
|
||||
#endif // _SRVWORLDMESSAGE_H
|
||||
135
server/driver/srvworldprotocol.C
Normal file
135
server/driver/srvworldprotocol.C
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvworldprotocol.H"
|
||||
#include "srvworldmanager.H"
|
||||
#include "srvworldmessage.H"
|
||||
#include "msgsrvcli.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
CSrvWorldProtocol::CSrvWorldProtocol(CSocket * socket, CTimeKeeper * timeKeeper)
|
||||
:CCommunicate(socket,timeKeeper){
|
||||
addMsg((MsgCreateFunc_t)CMsgSrvWorldLogin::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgSrvWorldPing::createMsg);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::quit(){
|
||||
CSrvWorldManager * manager = (CSrvWorldManager*)getManager();
|
||||
manager->quit();
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendHello(){
|
||||
CMsgHello * msg = new CMsgHello(PROTOCOL_VERSION);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendGOSInfo(CInetAddress & gosAddr){
|
||||
CMsgGOSInfo * msg = new CMsgGOSInfo(gosAddr);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendPong( BYTE sequenceNumber, DWORD serverTime ){
|
||||
CMsgPong * msg = new CMsgPong(sequenceNumber,serverTime);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendAnimation(CWorldAnimation * animation){
|
||||
CMessage * msg = animation->createMessage();
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendAddWorld(){
|
||||
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_ADDWORLD);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendRemoveWorld(){
|
||||
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_REMOVEWORLD);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
void CSrvWorldProtocol::sendAddCell( CSrvObject * cell ){
|
||||
// Send cell
|
||||
CMsgCell * msg = new CMsgCell( cell->getId(),cell->getGeometryId(),
|
||||
CPosition(0,0,0) );
|
||||
sendMessage(msg,TRUE);
|
||||
|
||||
// Send PVS
|
||||
sendCellPVS( cell );
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendRemoveCell( CSrvObject * cell ){
|
||||
CMsgRemoveCell* msg = new CMsgRemoveCell(cell->getId());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvWorldProtocol::sendCellPVS( CSrvObject * cell ){
|
||||
CObjectListItem * item = cell->getPVS()->getFirstPVCell();
|
||||
while (item != NULL){
|
||||
CPVCell * pvCell = (CPVCell*)item->getObject();
|
||||
item = item->getNext();
|
||||
CMsgPVCell * msg = new CMsgPVCell( cell->getObjectId(),
|
||||
pvCell->getCellId(),
|
||||
pvCell->getPosition());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendAddObject( CSrvObject * object){
|
||||
CMsgObject * msg = new CMsgObject( object->getObjectId(),
|
||||
object->getGeometryId(),
|
||||
object->getParentId(),
|
||||
object->getPosition(),
|
||||
object->getDirection());
|
||||
sendMessage(msg,TRUE);
|
||||
|
||||
if (object->getPVS() != NULL) sendCellPVS( object );
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendRemoveObject( CSrvObject * object){
|
||||
CMsgRemoveObject * msg = new CMsgRemoveObject( object->getObjectId(),
|
||||
object->getParentId());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
void CSrvWorldProtocol::sendUpdatePosition( CSrvObject * object ){
|
||||
CMsgUpdatePosition * msg = new CMsgUpdatePosition(object->getObjectId(),
|
||||
object->getPosition());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
*/
|
||||
|
||||
void CSrvWorldProtocol::sendUpdateDirection( CSrvObject * object ){
|
||||
CMsgUpdateDirection * msg = new CMsgUpdateDirection(object->getObjectId(),
|
||||
object->getDirection());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CSrvWorldProtocol::sendUpdateHierarchy( CSrvObject * object ){
|
||||
CMsgUpdateHierarchy * msg = new CMsgUpdateHierarchy(object->getObjectId(),
|
||||
object->getParentId());
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
53
server/driver/srvworldprotocol.H
Normal file
53
server/driver/srvworldprotocol.H
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVWORLDPROTOCOL_H
|
||||
#define _SRVWORLDPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
#include "srvworld.H"
|
||||
#include "position.H"
|
||||
#include "direction.H"
|
||||
|
||||
class CSrvWorldProtocol: public CCommunicate {
|
||||
|
||||
public:
|
||||
CSrvWorldProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
|
||||
|
||||
virtual void quit();
|
||||
|
||||
void sendHello();
|
||||
void sendGOSInfo(CInetAddress & gosAddr);
|
||||
void sendPong( BYTE sequenceNumber, DWORD serverTime );
|
||||
|
||||
void sendAddWorld();
|
||||
void sendRemoveWorld();
|
||||
void sendAnimation( CWorldAnimation * animation );
|
||||
// void sendAddCell( CSrvObject * cell );
|
||||
// void sendRemoveCell( CSrvObject * cell );
|
||||
void sendCellPVS( CSrvObject * cell );
|
||||
void sendAddObject( CSrvObject * object );
|
||||
void sendRemoveObject( CSrvObject * object );
|
||||
// void sendUpdatePosition( CSrvObject * object );
|
||||
void sendUpdateDirection( CSrvObject * object );
|
||||
void sendUpdateHierarchy( CSrvObject * object );
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVWORLDPROTOCOL_H
|
||||
53
server/driver/srvworldsrvsocket.C
Normal file
53
server/driver/srvworldsrvsocket.C
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <iostream.h>
|
||||
#include "srvworldsrvsocket.H"
|
||||
#include "srvworldmanager.H"
|
||||
#include "srvworldprotocol.H"
|
||||
#include "mud.H"
|
||||
|
||||
CSrvWorldSrvSocket::CSrvWorldSrvSocket(CMud * mud,int port, CTimeKeeper * timeKeeper):CServerSocket(port){
|
||||
m_timeKeeper = timeKeeper;
|
||||
m_mud = mud;
|
||||
m_timeKeeper->addFd(getFileDescriptor(),this,TIMEKEEPER_IN);
|
||||
}
|
||||
|
||||
CSrvWorldSrvSocket::~CSrvWorldSrvSocket(){
|
||||
m_timeKeeper->rmFd(getFileDescriptor());
|
||||
}
|
||||
|
||||
int CSrvWorldSrvSocket::timeKeeperFD(int event){
|
||||
CSocket * socket;
|
||||
try {
|
||||
socket = accept();
|
||||
socket->setNonBlocking();
|
||||
} catch (CException * e){
|
||||
cdebug << *e << "\n";
|
||||
delete e;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CSrvWorldManager * worldSrv = new CSrvWorldManager(m_mud,new CSrvWorldProtocol(socket,m_timeKeeper));
|
||||
cdebug << "New worldSrv: " << socket->getAddress().getAddressString() << "\n";
|
||||
m_mud->addWorld(worldSrv);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
39
server/driver/srvworldsrvsocket.H
Normal file
39
server/driver/srvworldsrvsocket.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVWORLDSRVSOCKET_H
|
||||
#define _SRVWORLDSRVSOCKET_H
|
||||
|
||||
#include "socket.H"
|
||||
#include "timekeeper.H"
|
||||
|
||||
class CMud;
|
||||
|
||||
class CSrvWorldSrvSocket : CServerSocket , public CTimeKeeperItem {
|
||||
CMud * m_mud;
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
public:
|
||||
CSrvWorldSrvSocket(CMud * mud,int port, CTimeKeeper * timeKeeper);
|
||||
virtual ~CSrvWorldSrvSocket();
|
||||
|
||||
virtual int timeKeeperFD(int event);
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVWORLDSRVSOCKET_H
|
||||
89
server/driver/userdb.C
Normal file
89
server/driver/userdb.C
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <stdio.h>
|
||||
#include "userdb.H"
|
||||
#include "msgsrvcli.H"
|
||||
|
||||
|
||||
CUserDB::CUserDB(char * userDBFileName){
|
||||
m_userDBFileName = userDBFileName;
|
||||
}
|
||||
|
||||
CUserDB::~CUserDB(){
|
||||
}
|
||||
|
||||
BOOL CUserDB::verifyUser(char * userName,char * passwd){
|
||||
|
||||
FILE *fd;
|
||||
char user[LOGINNAMELENGTH],pwd[LOGINPASSWDLENGTH];
|
||||
|
||||
fd=fopen("userdb/index.dat","r");
|
||||
if (!fd) return FALSE;
|
||||
|
||||
while(!feof(fd)) {
|
||||
fread(user,LOGINNAMELENGTH,1,fd);
|
||||
fread(pwd,LOGINPASSWDLENGTH,1,fd);
|
||||
|
||||
if (!strcmp(user,userName)) {
|
||||
if (!strcmp(pwd,passwd)) {
|
||||
fclose(fd);
|
||||
return TRUE;
|
||||
} else {
|
||||
fclose(fd);
|
||||
return FALSE;
|
||||
};
|
||||
};
|
||||
};
|
||||
fclose(fd);
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
BOOL CUserDB::newUser(char * userName,char * passwd){
|
||||
|
||||
FILE *fd;
|
||||
char user[LOGINNAMELENGTH],pwd[LOGINPASSWDLENGTH];
|
||||
|
||||
fd=fopen("userdb/index.dat","r");
|
||||
if (fd) {
|
||||
while (!feof(fd)) {
|
||||
fread(user,LOGINNAMELENGTH,1,fd);
|
||||
fread(pwd,LOGINPASSWDLENGTH,1,fd);
|
||||
|
||||
if (!strcmp(user,userName)) {
|
||||
fclose(fd);
|
||||
return FALSE;
|
||||
};
|
||||
};
|
||||
fclose(fd);
|
||||
};
|
||||
|
||||
fd=fopen("userdb/index.dat","a");
|
||||
if (!fd) return FALSE;
|
||||
|
||||
fwrite(userName,LOGINNAMELENGTH,1,fd);
|
||||
fwrite(passwd,LOGINPASSWDLENGTH,1,fd);
|
||||
|
||||
fclose(fd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
35
server/driver/userdb.H
Normal file
35
server/driver/userdb.H
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _USERDB_H
|
||||
#define _USERDB_H
|
||||
|
||||
class CUserDB {
|
||||
char * m_userDBFileName;
|
||||
public:
|
||||
CUserDB(char * userDBFileName);
|
||||
virtual ~CUserDB();
|
||||
|
||||
BOOL verifyUser(char * userName,char * passwd);
|
||||
BOOL newUser(char * userName,char * passwd);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _USERDB_H
|
||||
6
server/lib/Makefile.am
Normal file
6
server/lib/Makefile.am
Normal file
@@ -0,0 +1,6 @@
|
||||
INCLUDES = -I../../common/include -I.. -I../driver @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
noinst_LIBRARIES = libsrvlib.a
|
||||
|
||||
libsrvlib_a_SOURCES = actionclose.C actionopen.C chest.C door.C magicchest.C viewpoint_1p.C viewpoint_3p.C viewpoint_free.C
|
||||
|
||||
331
server/lib/Makefile.in
Normal file
331
server/lib/Makefile.in
Normal file
@@ -0,0 +1,331 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
GL_CFLAGS = @GL_CFLAGS@
|
||||
GL_LIBS = @GL_LIBS@
|
||||
LEX = @LEX@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NETLIBS = @NETLIBS@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
TIFF_CFLAGS = @TIFF_CFLAGS@
|
||||
TIFF_LIBS = @TIFF_LIBS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
|
||||
INCLUDES = -I../../common/include -I.. -I../driver @X_CFLAGS@ @GL_CFLAGS@
|
||||
|
||||
noinst_LIBRARIES = libsrvlib.a
|
||||
|
||||
libsrvlib_a_SOURCES = actionclose.C actionopen.C chest.C door.C magicchest.C viewpoint_1p.C viewpoint_3p.C viewpoint_free.C
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libsrvlib_a_LIBADD =
|
||||
libsrvlib_a_OBJECTS = actionclose.o actionopen.o chest.o door.o \
|
||||
magicchest.o viewpoint_1p.o viewpoint_3p.o viewpoint_free.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in TODO
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/actionclose.P .deps/actionopen.P .deps/chest.P \
|
||||
.deps/door.P .deps/magicchest.P .deps/viewpoint_1p.P \
|
||||
.deps/viewpoint_3p.P .deps/viewpoint_free.P
|
||||
SOURCES = $(libsrvlib_a_SOURCES)
|
||||
OBJECTS = $(libsrvlib_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .C .S .c .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign server/lib/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-noinstLIBRARIES:
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
|
||||
distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libsrvlib.a: $(libsrvlib_a_OBJECTS) $(libsrvlib_a_DEPENDENCIES)
|
||||
-rm -f libsrvlib.a
|
||||
$(AR) cru libsrvlib.a $(libsrvlib_a_OBJECTS) $(libsrvlib_a_LIBADD)
|
||||
$(RANLIB) libsrvlib.a
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = server/lib
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign server/lib/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.C
|
||||
@echo '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstLIBRARIES distclean-compile \
|
||||
distclean-tags distclean-depend distclean-generic \
|
||||
clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-depend maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
|
||||
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
|
||||
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
|
||||
distclean-depend clean-depend maintainer-clean-depend info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
1
server/lib/TODO
Normal file
1
server/lib/TODO
Normal file
@@ -0,0 +1 @@
|
||||
Delete createworld.*
|
||||
32
server/lib/actionclose.C
Normal file
32
server/lib/actionclose.C
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
/*
|
||||
#include "actionclose.H"
|
||||
|
||||
CActionClose::CActionClose(CChest * chest):CSrvAction("Close",chest){
|
||||
|
||||
}
|
||||
|
||||
void CActionClose::execute(){
|
||||
CChest * chest = (CChest*)getMasterObject();
|
||||
chest->close();
|
||||
}
|
||||
*/
|
||||
37
server/lib/actionclose.H
Normal file
37
server/lib/actionclose.H
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _ACTIONCLOSE_H
|
||||
#define _ACTIONCLOSE_H
|
||||
|
||||
/*
|
||||
|
||||
#include "srvaction.H"
|
||||
#include "chest.H"
|
||||
|
||||
class CActionClose: public CSrvAction {
|
||||
|
||||
public:
|
||||
CActionClose(CChest * chest);
|
||||
virtual void execute();
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#endif // _ACTIONCLOSE_H
|
||||
32
server/lib/actionopen.C
Normal file
32
server/lib/actionopen.C
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
/*
|
||||
#include "actionopen.H"
|
||||
|
||||
CActionOpen::CActionOpen(CChest * chest):CSrvAction("Open",chest){
|
||||
|
||||
}
|
||||
|
||||
void CActionOpen::execute(){
|
||||
CChest * chest = (CChest*)getMasterObject();
|
||||
chest->open();
|
||||
}
|
||||
*/
|
||||
38
server/lib/actionopen.H
Normal file
38
server/lib/actionopen.H
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _ACTIONOPEN_H
|
||||
#define _ACTIONOPEN_H
|
||||
|
||||
/*
|
||||
|
||||
|
||||
#include "srvaction.H"
|
||||
#include "chest.H"
|
||||
|
||||
class CActionOpen: public CSrvAction {
|
||||
|
||||
public:
|
||||
CActionOpen(CChest * chest);
|
||||
virtual void execute();
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#endif // _ACTIONOPEN_H
|
||||
102
server/lib/chest.C
Normal file
102
server/lib/chest.C
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
/*
|
||||
#include "server.H"
|
||||
#include "chest.H"
|
||||
#include "actionopen.H"
|
||||
#include "actionclose.H"
|
||||
|
||||
CChest::CChest():CSrvObject(){
|
||||
|
||||
setName("Chest");
|
||||
|
||||
state = CHESTSTATE_OPENED;
|
||||
doorAngle = 45;
|
||||
|
||||
CGeometryObject * geometry = new CGeometryObject("Chest",7);
|
||||
geometry->setBBox( new CBBox(-0.25,0.4,0,0.25,-0.4,0.5) );
|
||||
|
||||
doorGeometry = new CGeometryObject("Chest door",8);
|
||||
doorGeometry->setPosition( CPosition(-0.25,0,0.5) );
|
||||
doorGeometry->setDirection( CDirection(0,-doorAngle,0) );
|
||||
doorGeometry->setBBox( new CBBox(0.0,0.4,0,0.5,-0.4,0.5) );
|
||||
|
||||
geometry->addGeometryObject( doorGeometry );
|
||||
|
||||
setGeometry(geometry);
|
||||
|
||||
addAction( new CActionOpen(this) );
|
||||
addAction( new CActionClose(this) );
|
||||
|
||||
}
|
||||
|
||||
int CChest::open(){
|
||||
if (state == CHESTSTATE_CLOSED) {
|
||||
printf("Chest: open!\n");
|
||||
state = CHESTSTATE_OPEN;
|
||||
} else return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CChest::close(){
|
||||
if (state == CHESTSTATE_OPENED) {
|
||||
printf("Chest: close!\n");
|
||||
state = CHESTSTATE_CLOSE;
|
||||
} else return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CChest::animate( double time ){
|
||||
// printf("Chest: animate( %f )\n",time );
|
||||
switch (state) {
|
||||
case CHESTSTATE_OPENED:
|
||||
case CHESTSTATE_CLOSED:
|
||||
return ;
|
||||
break;
|
||||
case CHESTSTATE_OPEN:
|
||||
doorAngle += CHESTANGLE_SPEED*time;
|
||||
if (doorAngle > 45.0){
|
||||
doorAngle = 45.0;
|
||||
state = CHESTSTATE_OPENED;
|
||||
doorOpened();
|
||||
}
|
||||
doorGeometry->updateDirection( CDirection(0,-doorAngle,0) );
|
||||
break;
|
||||
case CHESTSTATE_CLOSE:
|
||||
doorAngle -= CHESTANGLE_SPEED*time;
|
||||
if (doorAngle < 0.0){
|
||||
doorAngle = 0.0;
|
||||
state = CHESTSTATE_CLOSED;
|
||||
doorClosed();
|
||||
}
|
||||
doorGeometry->updateDirection( CDirection(0,-doorAngle,0) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CChest::doorOpened(){
|
||||
printf("Chest: doorOpened!\n");
|
||||
}
|
||||
|
||||
void CChest::doorClosed(){
|
||||
printf("Chest: doorClosed!\n");
|
||||
}
|
||||
*/
|
||||
60
server/lib/chest.H
Normal file
60
server/lib/chest.H
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CHEST_H
|
||||
#define _CHEST_H
|
||||
|
||||
/*
|
||||
|
||||
#include "srvobject.H"
|
||||
#include "geometryobject.H"
|
||||
|
||||
#define CHESTSTATE_NO 0
|
||||
#define CHESTSTATE_OPENED 1
|
||||
#define CHESTSTATE_CLOSED 2
|
||||
#define CHESTSTATE_OPEN 3
|
||||
#define CHESTSTATE_CLOSE 4
|
||||
|
||||
#define CHESTANGLE_SPEED 360/60 // 360 grader per min
|
||||
|
||||
|
||||
class CChest: public CSrvObject {
|
||||
|
||||
CGeometryObject * doorGeometry;
|
||||
double doorAngle;
|
||||
|
||||
public:
|
||||
int state;
|
||||
|
||||
public:
|
||||
|
||||
CChest();
|
||||
|
||||
int open();
|
||||
int close();
|
||||
|
||||
virtual void animate( double time );
|
||||
|
||||
virtual void doorOpened();
|
||||
virtual void doorClosed();
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
#endif // _CHEST_H
|
||||
91
server/lib/door.C
Normal file
91
server/lib/door.C
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
/*
|
||||
#include "server.H"
|
||||
#include "door.H"
|
||||
|
||||
CDoor::CDoor():CSrvObject(){
|
||||
|
||||
state = DOORSTATE_OPENED;
|
||||
doorAngle = 45;
|
||||
|
||||
CGeometryObject * geometry = new CGeometryObject("Door",7);
|
||||
geometry->setBBox( new CBBox(-0.4,-0.1,0,0.4,0.1,1.8) );
|
||||
|
||||
setGeometry(geometry);
|
||||
|
||||
setDirection( CDirection(0,-doorAngle,0) );
|
||||
|
||||
}
|
||||
|
||||
int CDoor::open(){
|
||||
if (state == DOORSTATE_CLOSED) {
|
||||
printf("Door: open!\n");
|
||||
state = DOORSTATE_OPEN;
|
||||
} else return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CDoor::close(){
|
||||
if (state == DOORSTATE_OPENED) {
|
||||
printf("Door: close!\n");
|
||||
state = DOORSTATE_CLOSE;
|
||||
} else return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CDoor::animate( double time ){
|
||||
// printf("Door: animate( %f )\n",time );
|
||||
switch (state) {
|
||||
case DOORSTATE_OPENED:
|
||||
case DOORSTATE_CLOSED:
|
||||
return ;
|
||||
break;
|
||||
case DOORSTATE_OPEN:
|
||||
doorAngle += DOORANGLE_SPEED*time;
|
||||
if (doorAngle > 45.0){
|
||||
doorAngle = 45.0;
|
||||
state = DOORSTATE_OPENED;
|
||||
doorOpened();
|
||||
}
|
||||
updateDirection( CDirection(0,-doorAngle,0) );
|
||||
break;
|
||||
case DOORSTATE_CLOSE:
|
||||
doorAngle -= DOORANGLE_SPEED*time;
|
||||
if (doorAngle < 0.0){
|
||||
doorAngle = 0.0;
|
||||
state = DOORSTATE_CLOSED;
|
||||
doorClosed();
|
||||
}
|
||||
updateDirection( CDirection(0,-doorAngle,0) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CDoor::doorOpened(){
|
||||
printf("Door: doorOpened!\n");
|
||||
}
|
||||
|
||||
void CDoor::doorClosed(){
|
||||
printf("Door: doorClosed!\n");
|
||||
}
|
||||
|
||||
*/
|
||||
59
server/lib/door.H
Normal file
59
server/lib/door.H
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _DOOR_H
|
||||
#define _DOOR_H
|
||||
/*
|
||||
|
||||
#include "srvobject.H"
|
||||
#include "geometryobject.H"
|
||||
|
||||
#define DOORSTATE_NO 0
|
||||
#define DOORSTATE_OPENED 1
|
||||
#define DOORSTATE_CLOSED 2
|
||||
#define DOORSTATE_OPEN 3
|
||||
#define DOORSTATE_CLOSE 4
|
||||
|
||||
#define DOORANGLE_SPEED 360/60 // 360 grader per min
|
||||
|
||||
|
||||
class CDoor: public CSrvObject {
|
||||
|
||||
double doorAngle;
|
||||
|
||||
public:
|
||||
int state;
|
||||
|
||||
public:
|
||||
|
||||
CDoor();
|
||||
|
||||
int open();
|
||||
int close();
|
||||
|
||||
virtual void animate( double time );
|
||||
|
||||
virtual void doorOpened();
|
||||
virtual void doorClosed();
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#endif // _DOOR_H
|
||||
127
server/lib/gamefunction.C
Normal file
127
server/lib/gamefunction.C
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "gamefunction.H"
|
||||
|
||||
CGameFunctionObject :: CGameFunctionObject () {
|
||||
type=-1;
|
||||
func.c=NULL;
|
||||
}
|
||||
|
||||
CGameFunctionObject :: ~CGameFunctionObject () {
|
||||
type=-1;
|
||||
func.c=NULL;
|
||||
}
|
||||
|
||||
CGameFunction :: ~CGameFunction() {
|
||||
funchash::iterator i;
|
||||
for(i=hash.begin();i!=hash.end();i++) delete (*i).second;
|
||||
hash.clear();
|
||||
}
|
||||
|
||||
void CGameFunction :: add(char *name, void (*function)()) {
|
||||
CGameFunctionObject *gfo;
|
||||
|
||||
gfo=new CGameFunctionObject;
|
||||
|
||||
gfo->type = 0;
|
||||
gfo->func.c = function;
|
||||
|
||||
hash[name] = gfo;
|
||||
}
|
||||
|
||||
void CGameFunction :: add(char *name, char *function) {
|
||||
CGameFunctionObject *gfo;
|
||||
|
||||
gfo=new CGameFunctionObject;
|
||||
|
||||
gfo->type = 1;
|
||||
gfo->func.scriptSource = function;
|
||||
|
||||
hash[name] = gfo;
|
||||
}
|
||||
|
||||
void CGameFunction :: add(char *name, WORD *function) {
|
||||
CGameFunctionObject *gfo;
|
||||
|
||||
gfo=new CGameFunctionObject;
|
||||
|
||||
gfo->type = 2;
|
||||
gfo->func.scriptByteCode = function;
|
||||
|
||||
hash[name] = gfo;
|
||||
}
|
||||
|
||||
void CGameFunction :: remove(char *name) {
|
||||
CGameFunctionObject *gfo;
|
||||
|
||||
free(hash[name]);
|
||||
hash.erase(name);
|
||||
}
|
||||
|
||||
bool CGameFunction :: execute(char *name, CGameEvent *gameEvent) {
|
||||
CGameFunctionObject *gfo;
|
||||
|
||||
gfo=getGameFuncObj(name);
|
||||
return(execute(gfo,gameEvent));
|
||||
}
|
||||
|
||||
CGameFunctionObject *CGameFunction::getGameFuncObj(char *name) {
|
||||
CGameFunctionObject *gfo=NULL;
|
||||
|
||||
gfo=hash[name];
|
||||
return gfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool CGameFunctionObject :: execute (CGameEvent *gameEvent) {
|
||||
|
||||
switch(type) {
|
||||
case 0:
|
||||
return(func->c());
|
||||
// case 1:
|
||||
// return(executeScript(func.scriptSource,gameEvent));
|
||||
// case 2:
|
||||
// return(executeByteCode(func.scriptByteCode,gameEvent));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bool CGameFunction :: execute(CGameFunctionObject *gfo,
|
||||
CGameEvent *gameEvent) {
|
||||
|
||||
if (gfo == NULL) return;
|
||||
return (gfo->execute(gameEvent));
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool CGameFunction :: load(iostream &readFile) {
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
bool CGameFunction :: save(iostream &writeFile {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
83
server/lib/gamefunction.H
Normal file
83
server/lib/gamefunction.H
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GAMEFUNCTION_H
|
||||
#define _GAMEFUNCTION_H
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include <hash_map>
|
||||
#include <iostream>
|
||||
|
||||
class CGameFunctionObject {
|
||||
|
||||
public:
|
||||
|
||||
CGameFunctionObject(void);
|
||||
~CGameFunctionObject(void);
|
||||
|
||||
int type;
|
||||
union {
|
||||
bool (*c)();
|
||||
char *scriptSource;
|
||||
WORD *scriptByteCode;
|
||||
} func;
|
||||
|
||||
bool execute(CGameEvent *gameEvent);
|
||||
};
|
||||
|
||||
class CGameFunction {
|
||||
struct eqstr {
|
||||
bool operator()(const char* s1,const char* s2) const
|
||||
{
|
||||
return strcmp(s1,s2)==0;
|
||||
}
|
||||
};
|
||||
typedef hash_map<const char*, CGameFunctionObject *, hash<const char*>, eqstr> funchash;
|
||||
funchash hash;
|
||||
|
||||
public:
|
||||
|
||||
CGameFunction(void) {};
|
||||
~CGameFunction(void);
|
||||
|
||||
// Handling of C++ functions
|
||||
void add(char *name, void (*function) (CGameEvent *gameEvent));
|
||||
// Handling of functions in script code
|
||||
void add(char *name, char *function,CGameEvent *gameEvent);
|
||||
// Handling of byte code functions
|
||||
void add(char *name, WORD *function,CGameEvent *gameEvent);
|
||||
void remove(char *name);
|
||||
|
||||
bool execute(char *name, CGameEvent *gameEvent);
|
||||
bool execute(CGameFunctionObject *gfo, CGameEvent *gameEvent);
|
||||
|
||||
CGameFunctionObject *getGameFuncObj(char *name);
|
||||
|
||||
bool load(iostream &readFile);
|
||||
bool save(iostream &writeFile);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
97
server/lib/gamelistener.C
Normal file
97
server/lib/gamelistener.C
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "gamelistener.H"
|
||||
|
||||
|
||||
CGameListenerItem::CGameListenerItem() {
|
||||
m_s=0;
|
||||
m_v=NULL;
|
||||
m_priority=0;
|
||||
}
|
||||
|
||||
CGameListenerItem::CGameListenerItem(DWORD gameObject, CGameFunctionObject
|
||||
*func, int priority) {
|
||||
m_s=gameObject;
|
||||
m_v=func;
|
||||
m_priority=priority;
|
||||
}
|
||||
|
||||
CGameListenerItem::~CGameListenerItem() {
|
||||
}
|
||||
|
||||
void CGameListenerList::CGameListenerList() {
|
||||
}
|
||||
|
||||
void CGameListenerList::CGameListenerList() {
|
||||
listenerlist.clear();
|
||||
}
|
||||
|
||||
void CGameListenerList::add(DWORD gameObject, CGameFunctionObject *func,
|
||||
int priority) {
|
||||
list<CGameListenerItem>::iterator i;
|
||||
|
||||
for(i=listenerlist.begin();i!=listenerlist.end;i++) {
|
||||
if ( (*i).second.priority > priority) {
|
||||
listenerlist.insert(i,CGameListenerItem(gameObject, func, priority));
|
||||
return;
|
||||
};
|
||||
};
|
||||
listenerlist.push_back(CGameListenerItem(gameObject, func, priority));
|
||||
}
|
||||
|
||||
void CGameListenerList::execute(CGameEvent *gameEvent) {
|
||||
list<CGameListenerItem>::iterator i;
|
||||
|
||||
for(i=i.begin(); i!=i.end; i++) {
|
||||
if (!(*i).second.m_v->execute(gameEvent)) return;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void CGameListener::CGameListener() {
|
||||
}
|
||||
|
||||
void CGameListener::~CGameListener() {
|
||||
hash.clear();
|
||||
}
|
||||
|
||||
void CGameListener::add(DWORD event, DWORD gameObject,
|
||||
CGameFunctionObject *func, int priority) {
|
||||
|
||||
key.event = event;
|
||||
key.object = gameObject;
|
||||
|
||||
hash[key]=CGameListenerList();
|
||||
hash[key].add(gameObject, func, priority);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CGameListener::execute(CGameEvent *gameEvent) {
|
||||
|
||||
key.event = gameEvent.id;
|
||||
key.object = gameEvent.subject;
|
||||
|
||||
hash[key].execute(gameEvent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
95
server/lib/gamelistener.H
Normal file
95
server/lib/gamelistener.H
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GAMELISTENER_H
|
||||
#define _GAMELISTENER_H
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "gameevent.H"
|
||||
#include "gamefunction.H"
|
||||
#include "gameobject.H"
|
||||
#include <list>
|
||||
#include <hash_map>
|
||||
|
||||
class CGameListenerItem {
|
||||
|
||||
public:
|
||||
DWORD s;
|
||||
CGameFunctionObject *v;
|
||||
int priority;
|
||||
|
||||
CGameListenerItem::CGameListenerItem(DWORD gameObject, CGameFunctionObject
|
||||
*func, int priority) {
|
||||
CGameListenerItem();
|
||||
~CGameListenerItem();
|
||||
};
|
||||
|
||||
class CGameListenerList {
|
||||
|
||||
list<CGameListenerItem> listenerList;
|
||||
|
||||
public:
|
||||
CGameListenerList();
|
||||
~CGameListenerList();
|
||||
void add(DWORD s, CGameFunctionObject *v, int priority);
|
||||
void execute(CGameEvent *gameEvent);
|
||||
|
||||
};
|
||||
|
||||
class CGameListener {
|
||||
|
||||
struct _key {
|
||||
DWORD event;
|
||||
DWORD object;
|
||||
} key;
|
||||
|
||||
struct eqkey
|
||||
{
|
||||
bool operator()(struct _key s1, struct _key s2) const
|
||||
{
|
||||
return ( (s1.event==s2.event) && (s1.object==s2.object) );
|
||||
}
|
||||
};
|
||||
|
||||
typedef listenerHash = hash_map<const char *, CGameListenerList, hash<const
|
||||
char *>,eqkey);
|
||||
listenerHash hash;
|
||||
|
||||
public:
|
||||
CGameListener();
|
||||
~GameListener();
|
||||
void add(DWORD event, DWORD gameObject, CGameFunctionObject *func,
|
||||
int priority);
|
||||
void execute(CGameEvent *gameEvent);
|
||||
};
|
||||
|
||||
#endif _GAMELISTENER_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
277
server/lib/gamevalue.C
Normal file
277
server/lib/gamevalue.C
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "gamevalue.H"
|
||||
|
||||
CGameValueObject::CGameValueObject() {
|
||||
type=GV_INVALID;
|
||||
value._dword=0;
|
||||
_ptr=NULL;
|
||||
}
|
||||
|
||||
CGameValueObject::~CGameValueObject() {
|
||||
type=GV_INVALID;
|
||||
value._dword=0;
|
||||
_ptr=NULL;
|
||||
}
|
||||
|
||||
CGameValue::CGameValue() {};
|
||||
|
||||
CGameValue::~CGameValue() {
|
||||
valhash::iterator i;
|
||||
for(i=hash.begin();i!=hash.end();i++) delete (*i).second;
|
||||
hash.clear();
|
||||
}
|
||||
|
||||
void CGameValue::add(char *name, BYTE *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_BYTE;
|
||||
gvo->value._byte = *value;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
void CGameValue::add(char *name, WORD *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_WORD;
|
||||
gvo->value._word = *value;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
|
||||
void CGameValue::add(char *name, DWORD *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_DWORD;
|
||||
gvo->value._byte = *value;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
void CGameValue::add(char *name, float *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_FLOAT;
|
||||
gvo->value._float = *value;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
void CGameValue::add(char *name, double *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_DOUBLE;
|
||||
gvo->value._double = *value;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
void CGameValue::add(char *name, char *data, int *length) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = new CGameValueObject;
|
||||
gvo->type = GV_STRING;
|
||||
gvo->value._dword = (DWORD) *length;
|
||||
gvo->_ptr = data;
|
||||
|
||||
hash[name] = gvo;
|
||||
}
|
||||
|
||||
|
||||
bool CGameValue::get(char *name, BYTE *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*value = gvo->value._byte;
|
||||
if (gvo->type != GV_BYTE) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
bool CGameValue::get(char *name, WORD *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*value = gvo->value._word;
|
||||
if (gvo->type != GV_WORD) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
bool CGameValue::get(char *name, DWORD *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*value = gvo->value._dword;
|
||||
if (gvo->type != GV_DWORD) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
bool CGameValue::get(char *name, float *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*value = gvo->value._float;
|
||||
if (gvo->type != GV_FLOAT) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
bool CGameValue::get(char *name, double *value) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*value = gvo->value._double;
|
||||
if (gvo->type != GV_DOUBLE) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
bool CGameValue::get(char *name, char *data, int *length) {
|
||||
CGameValueObject *gvo;
|
||||
|
||||
gvo = hash[name];
|
||||
*length = gvo->value._dword;
|
||||
data = gvo->_ptr;
|
||||
if (gvo->type != GV_STRING) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
return(TRUE);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
bool CGameValue::load(iostream &readFile) {
|
||||
char name[256];
|
||||
int type;
|
||||
union {
|
||||
BYTE _byte;
|
||||
WORD _word;
|
||||
DWORD _dword;
|
||||
float _float;
|
||||
double _double;
|
||||
} value;
|
||||
char *_ptr;
|
||||
|
||||
valhash::iterator i;
|
||||
for(i=hash.begin();i!=hash.end();i++) delete (*i).second;
|
||||
hash.clear();
|
||||
|
||||
while (!readFile.eof()) {
|
||||
readFile >> name;
|
||||
if (!strcmp(name, "[\\Values]")) break;
|
||||
readFile >> type;
|
||||
switch (type) {
|
||||
|
||||
case GV_BYTE:
|
||||
readFile >> value._byte;
|
||||
add(name,value._byte);
|
||||
break;
|
||||
case GV_WORD:
|
||||
readFile >> value._word;
|
||||
add(name,value._word);
|
||||
break;
|
||||
case GV_DWORD:
|
||||
readFile >> value._dword;
|
||||
add(name,value._dword);
|
||||
break;
|
||||
case GV_FLOAT:
|
||||
readFile >> value._float;
|
||||
add(name,value._float);
|
||||
break;
|
||||
case GV_DOUBLE:
|
||||
readFile >> value._double;
|
||||
add(name,value._double);
|
||||
break;
|
||||
case GV_STRING:
|
||||
readFile >> value._dword;
|
||||
_ptr = new string();
|
||||
for (int n=0;n<value._dword;n++){
|
||||
char ch;
|
||||
readFile >> ch;
|
||||
_ptr += ch;
|
||||
}
|
||||
add(name,value._dword,_ptr);
|
||||
_ptr=NULL;
|
||||
break;
|
||||
default:
|
||||
cout << "Failed : Unknown type of variable";
|
||||
return FALSE;
|
||||
break;
|
||||
};
|
||||
};
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CGameValue::save(iostream &writefile) {
|
||||
writeFile << "[Values]" << newln;
|
||||
|
||||
valhash::iterator i;
|
||||
for(i=hash.begin();i!=hash.end();i++) {
|
||||
writeFile << (*i).first() << (*i).second->type;
|
||||
switch((*i).second->type) {
|
||||
case GV_BYTE:
|
||||
writeFile << (*i).second->value._byte;
|
||||
break;
|
||||
case GV_WORD:
|
||||
writeFile << (*i).second->value._word;
|
||||
break;
|
||||
case GV_DWORD:
|
||||
writeFile << (*i).second->value._dword;
|
||||
break;
|
||||
case GV_FLOAT:
|
||||
writeFile << (*i).second->value._float;
|
||||
break;
|
||||
case GV_DOUBLE:
|
||||
writeFile << (*i).second->value._double;
|
||||
break;
|
||||
case GV_STRING:
|
||||
writeFile << (*i).second->value._dword << newln;
|
||||
for (int n=0;n<(*i).second->value._dword;n++){
|
||||
writeFile << *((*i).second->_ptr+n);
|
||||
}
|
||||
writeFile << newln;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
writeFile << "[\\Values]" << newln;
|
||||
return TRUE;
|
||||
}
|
||||
81
server/lib/gamevalue.H
Normal file
81
server/lib/gamevalue.H
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GAMEVALUE_H
|
||||
#define _GAMEVALUE_H
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include <hash_map>
|
||||
#include <iostream>
|
||||
|
||||
class CGameValueObject {
|
||||
|
||||
public:
|
||||
|
||||
CGameValueObject();
|
||||
~CGameValueObject();
|
||||
|
||||
int type;
|
||||
union {
|
||||
BYTE _byte;
|
||||
WORD _word;
|
||||
DWORD _dword;
|
||||
float _float;
|
||||
double _double;
|
||||
} value;
|
||||
char *_ptr;
|
||||
|
||||
};
|
||||
|
||||
class CGameValue {
|
||||
enum {GV_INVALID=-1,GV_BYTE,GV_WORD,GV_DWORD,GV_FLOAT,GV_DOUBLE,GV_STRING};
|
||||
|
||||
struct eqstr {
|
||||
bool operator()(const char* s1,const char* s2) const
|
||||
{
|
||||
return strcmp(s1,s2)==0;
|
||||
};
|
||||
};
|
||||
typedef hash_map<const char *, CGameValueObject *, hash<const char *>,eqstr> valhash;
|
||||
valhash hash;
|
||||
|
||||
public:
|
||||
|
||||
CGameValue(void);
|
||||
~CGameValue(void);
|
||||
|
||||
void add(char *, BYTE *);
|
||||
void add(char *, WORD *);
|
||||
void add(char *, DWORD *);
|
||||
void add(char *, float *);
|
||||
void add(char *, double *);
|
||||
void add(char *, char *, int *);
|
||||
|
||||
bool get(char *, BYTE *);
|
||||
bool get(char *, WORD *);
|
||||
bool get(char *, DWORD *);
|
||||
bool get(char *, float *);
|
||||
bool get(char *, double *);
|
||||
bool get(char *, char *, int *);
|
||||
|
||||
bool load(iostream &readFile);
|
||||
bool save(iostream &saveFile);
|
||||
};
|
||||
|
||||
#endif
|
||||
36
server/lib/magicchest.C
Normal file
36
server/lib/magicchest.C
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
/*
|
||||
#include "server.H"
|
||||
#include "magicchest.H"
|
||||
|
||||
CMagicChest::CMagicChest():CChest(){
|
||||
close();
|
||||
}
|
||||
|
||||
void CMagicChest::doorOpened(){
|
||||
close();
|
||||
}
|
||||
|
||||
void CMagicChest::doorClosed(){
|
||||
open();
|
||||
}
|
||||
*/
|
||||
40
server/lib/magicchest.H
Normal file
40
server/lib/magicchest.H
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MAGICCHEST_H
|
||||
#define _MAGICCHEST_H
|
||||
|
||||
/*
|
||||
|
||||
#include "chest.H"
|
||||
|
||||
class CMagicChest: public CChest {
|
||||
|
||||
public:
|
||||
|
||||
CMagicChest();
|
||||
|
||||
virtual void doorOpened();
|
||||
virtual void doorClosed();
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#endif // _MAGICCHEST_H
|
||||
72
server/lib/mudlib.C
Normal file
72
server/lib/mudlib.C
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "mudlib.H"
|
||||
|
||||
CMudLib::CMudLib() {
|
||||
|
||||
m_gameclass=new CGameClass();
|
||||
load();
|
||||
|
||||
}
|
||||
|
||||
CMudLib::~CMudLib() {
|
||||
|
||||
save();
|
||||
delete CGameClass();
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool CMudLib::load() {
|
||||
bool state;
|
||||
|
||||
try {
|
||||
ifstream readFile(DATABASEFILE);
|
||||
state = m_gameclass->load(readFile);
|
||||
readFile.close();
|
||||
} catch (CIOException *err){
|
||||
cdebug << "Failed to load mudlib: " << *err << endl;
|
||||
delete err;
|
||||
return FALSE;
|
||||
};
|
||||
return state;
|
||||
}
|
||||
|
||||
bool CMudLib::save() {
|
||||
bool state;
|
||||
|
||||
try {
|
||||
ofstream writeFile(DATABASEFILE);
|
||||
state = m_gameclass->save(writeFile);
|
||||
writeFile.close();
|
||||
} catch (CIOException *err) {
|
||||
cdebug << "Failed to save mudlib: " << *err << endl;
|
||||
delete err;
|
||||
return FALSE;
|
||||
};
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
57
server/lib/mudlib.H
Normal file
57
server/lib/mudlib.H
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MUDLIB_H
|
||||
#define _MUDLIB_H
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "exception.H"
|
||||
#include "gameclass.H"
|
||||
|
||||
#define DATABASEFILE "mudlib/mud.db"
|
||||
|
||||
class CMudLib {
|
||||
|
||||
CGameClass *m_gameclass;
|
||||
|
||||
public:
|
||||
CMudLib();
|
||||
~CMudLib();
|
||||
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
void event(CGameEvent *gameEvent);
|
||||
|
||||
};
|
||||
|
||||
#endif _MUDLIB_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
server/lib/task.txt
Normal file
2
server/lib/task.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
%s/Open/Close/g
|
||||
w
|
||||
69
server/lib/viewpoint_1p.C
Normal file
69
server/lib/viewpoint_1p.C
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "server.H"
|
||||
#include "viewpoint_1p.H"
|
||||
|
||||
CViewpoint_1p::CViewpoint_1p(){
|
||||
persionHeight = 1.5;
|
||||
lookDefault();
|
||||
}
|
||||
|
||||
|
||||
void CViewpoint_1p::update( CWorldObject * target ){
|
||||
// CPosition position = target->getPosition();
|
||||
// CDirection direction = target->getDirection();
|
||||
// position += CPosition(0,0,persionHeight);
|
||||
// position += headPosition ;
|
||||
// direction += headDirection ;
|
||||
// setPosition( position );
|
||||
// setDirection( direction );
|
||||
setPosition( headPosition );
|
||||
setDirection( headDirection );
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookDefault(){
|
||||
headDirection = CDirection(0,0,0);
|
||||
headPosition = CPosition(0,0,persionHeight);
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookUp(){
|
||||
headPosition.moveZ(1);
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookDown(){
|
||||
headPosition.moveZ(-1);
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookRight(){
|
||||
headDirection.rotateHeading(-5.0);
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookLeft(){
|
||||
headDirection.rotateHeading(5.0);
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookForward(){
|
||||
}
|
||||
|
||||
void CViewpoint_1p::lookBackward(){
|
||||
}
|
||||
|
||||
|
||||
45
server/lib/viewpoint_1p.H
Normal file
45
server/lib/viewpoint_1p.H
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _VIEWPOINT_1P_H
|
||||
#define _VIEWPOINT_1P_H
|
||||
|
||||
#include "srvviewpoint.H"
|
||||
|
||||
class CViewpoint_1p: public CSrvViewpoint {
|
||||
|
||||
CDirection headDirection;
|
||||
CPosition headPosition;
|
||||
|
||||
public:
|
||||
CViewpoint_1p();
|
||||
|
||||
// virtual void update(CSrvObject * target);
|
||||
virtual void update(CWorldObject * target);
|
||||
virtual void lookDefault();
|
||||
virtual void lookUp();
|
||||
virtual void lookDown();
|
||||
virtual void lookRight();
|
||||
virtual void lookLeft();
|
||||
virtual void lookForward();
|
||||
virtual void lookBackward();
|
||||
|
||||
};
|
||||
|
||||
#endif // _VIEWPOINT_1P_H
|
||||
55
server/lib/viewpoint_3p.C
Normal file
55
server/lib/viewpoint_3p.C
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include "viewpoint_3p.H"
|
||||
|
||||
CViewpoint_3p::CViewpoint_3p(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//void CViewpoint_3p::update( CSrvObject * target ){
|
||||
void CViewpoint_3p::update( CWorldObject * target ){
|
||||
CPosition position = target->getPosition();
|
||||
CDirection direction = target->getDirection();
|
||||
position += CPosition(0,-3.0,1.0);
|
||||
setPosition( position );
|
||||
// setDirection( direction );
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookUp(){
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookDown(){
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookRight(){
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookLeft(){
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookForward(){
|
||||
}
|
||||
|
||||
void CViewpoint_3p::lookBackward(){
|
||||
}
|
||||
|
||||
|
||||
41
server/lib/viewpoint_3p.H
Normal file
41
server/lib/viewpoint_3p.H
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _VIEWPOINT_3P_H
|
||||
#define _VIEWPOINT_3P_H
|
||||
|
||||
#include "srvviewpoint.H"
|
||||
|
||||
class CViewpoint_3p: public CSrvViewpoint {
|
||||
|
||||
public:
|
||||
CViewpoint_3p();
|
||||
|
||||
// virtual void update(CSrvObject * target);
|
||||
virtual void update(CWorldObject * target);
|
||||
virtual void lookUp();
|
||||
virtual void lookDown();
|
||||
virtual void lookRight();
|
||||
virtual void lookLeft();
|
||||
virtual void lookForward();
|
||||
virtual void lookBackward();
|
||||
|
||||
};
|
||||
|
||||
#endif // _VIEWPOINT_3P_H
|
||||
54
server/lib/viewpoint_free.C
Normal file
54
server/lib/viewpoint_free.C
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include "viewpoint_free.H"
|
||||
|
||||
CViewpoint_free::CViewpoint_free(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CViewpoint_free::update( CWorldObject * target ){
|
||||
CPosition position = target->getPosition();
|
||||
CDirection direction = target->getDirection();
|
||||
position += CPosition(0,-3.0,1.0);
|
||||
setPosition( position );
|
||||
// setDirection( direction );
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookUp(){
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookDown(){
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookRight(){
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookLeft(){
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookForward(){
|
||||
}
|
||||
|
||||
void CViewpoint_free::lookBackward(){
|
||||
}
|
||||
|
||||
|
||||
40
server/lib/viewpoint_free.H
Normal file
40
server/lib/viewpoint_free.H
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _VIEWPOINT_FREE_H
|
||||
#define _VIEWPOINT_FREE_H
|
||||
|
||||
#include "srvviewpoint.H"
|
||||
|
||||
class CViewpoint_free: public CSrvViewpoint {
|
||||
|
||||
public:
|
||||
CViewpoint_free();
|
||||
|
||||
virtual void update(CWorldObject * target);
|
||||
virtual void lookUp();
|
||||
virtual void lookDown();
|
||||
virtual void lookRight();
|
||||
virtual void lookLeft();
|
||||
virtual void lookForward();
|
||||
virtual void lookBackward();
|
||||
|
||||
};
|
||||
|
||||
#endif // _VIEWPOINT_FREE_H
|
||||
34
server/mudpvvmud.C
Normal file
34
server/mudpvvmud.C
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "mudpvvmud.H"
|
||||
#include <iostream.h>
|
||||
#include "srvobject.H"
|
||||
|
||||
CMudPVVMud::CMudPVVMud(COption *option):CMud(option){
|
||||
}
|
||||
|
||||
void CMudPVVMud::createWorld(CSrvWorld * world){
|
||||
cdebug << "Create world\n";
|
||||
|
||||
world->loadWorld(getOption()->getString("world_lib_path"));
|
||||
|
||||
}
|
||||
|
||||
35
server/mudpvvmud.H
Normal file
35
server/mudpvvmud.H
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _MUDPVVMUD_H
|
||||
#define _MUDPVVMUD_H
|
||||
|
||||
#include "mud.H"
|
||||
|
||||
class CMudPVVMud : public CMud {
|
||||
|
||||
public:
|
||||
CMudPVVMud(COption *option);
|
||||
|
||||
// virtual void createOldWorld(CWorld * world);
|
||||
virtual void createWorld(CSrvWorld * world);
|
||||
|
||||
};
|
||||
|
||||
#endif // _MUDPVVMUD_H
|
||||
129
server/player.C
Normal file
129
server/player.C
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <math.h>
|
||||
#include <iostream.h>
|
||||
#include "player.H"
|
||||
#include "srvclimanager.H"
|
||||
|
||||
CPlayer::CPlayer(DWORD objectId,CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction )
|
||||
:CSrvObject(objectId,parent,geometryId,position,direction){
|
||||
|
||||
cdebug << "CPlayer::CPlayer\n";
|
||||
|
||||
m_manager = NULL;
|
||||
|
||||
// setPosition ( CPosition(0,3.5,0) );
|
||||
// setDirection ( CDirection(0.0,0.0,0.0) );
|
||||
}
|
||||
|
||||
CPlayer::~CPlayer(){
|
||||
}
|
||||
|
||||
char * CPlayer::getObjectType(){
|
||||
return "player";
|
||||
}
|
||||
|
||||
void CPlayer::setManager(CClientManager * manager){
|
||||
m_manager = manager;
|
||||
}
|
||||
|
||||
CClientManager * CPlayer::getManager(){
|
||||
return m_manager;
|
||||
}
|
||||
|
||||
void CPlayer::updatePosition( const CPosition & position ){
|
||||
CSrvObject::updatePosition(position);
|
||||
}
|
||||
|
||||
int CPlayer::moveTo( CWorldObject * parent ){
|
||||
int result = CSrvObject::moveTo(parent);
|
||||
getManager()->updateMasterCell((CSrvObject*)getMasterCell());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
double CPlayer::getPosX(){
|
||||
return getPosition().getX();
|
||||
}
|
||||
|
||||
double CPlayer::getPosY(){
|
||||
return getPosition().getY();
|
||||
}
|
||||
|
||||
double CPlayer::getPosZ(){
|
||||
return getPosition().getZ();
|
||||
}
|
||||
|
||||
double CPlayer::getAngle(){
|
||||
return getDirection().getHeading();
|
||||
}
|
||||
|
||||
void CPlayer::move(double length){
|
||||
BYTE playercollidable;
|
||||
|
||||
double angle = getAngle();
|
||||
CPosition position(getPosX()+length*sin(-angle*PI/180.0),getPosY()+length*cos(-angle*PI/180.0),getPosZ());
|
||||
|
||||
playercollidable=getCollidable();
|
||||
setCollidable(-1);
|
||||
CSrvObject * masterCell = (CSrvObject*)getMasterCell();
|
||||
if (masterCell == NULL) {
|
||||
cout << "ERROR: Cant find master cell!\n";
|
||||
return ;
|
||||
}
|
||||
CDoubleArray * distances =
|
||||
masterCell->getDistances(CBeam(position,CVector(0,0,-1)),-5.0,5.0);
|
||||
setCollidable(playercollidable);
|
||||
if (distances == NULL) return;
|
||||
|
||||
double dist = 5.0;
|
||||
cdebug << "Move : Distances :";
|
||||
|
||||
int index = distances->getNumElements();
|
||||
if (index != 0){
|
||||
while (index-- >0){
|
||||
|
||||
cdebug << " " << distances->get(index);
|
||||
|
||||
if (distances->get(index) < dist) dist = distances->get(index);
|
||||
}
|
||||
} else {
|
||||
dist = 5.0;
|
||||
}
|
||||
position.setValue(2,position.getZ()-dist);
|
||||
|
||||
cdebug << "\n";
|
||||
|
||||
delete distances;
|
||||
|
||||
updatePosition ( position );
|
||||
}
|
||||
|
||||
void CPlayer::turn(double angle){
|
||||
updateDirection ( CDirection(getAngle()+angle,0.0,0.0) );
|
||||
}
|
||||
|
||||
int CPlayer::objectReachable( CWorldObject * worldObject ){
|
||||
cdebug << "CPlayer::objectReachable: Not implemented!!! Player reach everything :)\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
59
server/player.H
Normal file
59
server/player.H
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _PLAYER_H
|
||||
#define _PLAYER_H
|
||||
|
||||
#include "srvobject.H"
|
||||
//#include "worldobject.H"
|
||||
//#include "cell.H"
|
||||
#include "position.H"
|
||||
#include "direction.H"
|
||||
|
||||
class CClientManager;
|
||||
|
||||
class CPlayer: public CSrvObject {
|
||||
|
||||
CClientManager * m_manager;
|
||||
|
||||
public:
|
||||
CPlayer(DWORD objectId, CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
virtual ~CPlayer();
|
||||
|
||||
virtual char * getObjectType();
|
||||
|
||||
void setManager(CClientManager * manager);
|
||||
CClientManager * getManager();
|
||||
|
||||
virtual void updatePosition( const CPosition & position );
|
||||
virtual int moveTo( CWorldObject * parent );
|
||||
|
||||
double getPosX();
|
||||
double getPosY();
|
||||
double getPosZ();
|
||||
double getAngle();
|
||||
|
||||
void move(double length);
|
||||
void turn(double angle);
|
||||
|
||||
int objectReachable( CWorldObject * worldObject );
|
||||
|
||||
};
|
||||
|
||||
#endif // _PLAYER_H
|
||||
87
server/pvvmudsrv.C
Normal file
87
server/pvvmudsrv.C
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "server.H"
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <iostream.h>
|
||||
#include "mudpvvmud.H"
|
||||
#include "option.H"
|
||||
|
||||
CMudPVVMud * pvvmud;
|
||||
|
||||
void sigint(int signum){
|
||||
cdebug << "Received a SIGINT shuting down the server!\n";
|
||||
pvvmud->stop();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[] ){
|
||||
COption option;
|
||||
|
||||
// port
|
||||
// The port that clients are to connect to the server
|
||||
option.setValue("port",'p',SERVER_CLIENT_PORT);
|
||||
|
||||
// gos_port
|
||||
// The port that gos server are to connect to the server
|
||||
option.setValue("gos_port",'g',SERVER_GOS_PORT);
|
||||
|
||||
// world_port
|
||||
// The port that world server are to connect to the server
|
||||
option.setValue("world_port",'w',SERVER_WORLDSRV_PORT);
|
||||
|
||||
// world_lib_path
|
||||
// The path where the server search for a world file. This world file
|
||||
// control loading of the game world.
|
||||
option.setValue("world_lib_path",'l',"../mudworld");
|
||||
|
||||
// userdb
|
||||
// The file name for the user DB
|
||||
option.setValue("userdb",'u',"userdb.dat");
|
||||
|
||||
option.loadOption("server.conf");
|
||||
option.parseArguments(argc,argv);
|
||||
|
||||
pvvmud = new CMudPVVMud(&option);
|
||||
|
||||
// Installing signal handler
|
||||
signal(SIGINT, sigint ); // Shuting down the server on sigint
|
||||
signal(SIGPIPE, SIG_IGN );
|
||||
|
||||
pvvmud->run();
|
||||
|
||||
delete pvvmud;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
server/server.html
Normal file
16
server/server.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>PVVMUD - Server</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<H1>Server</H1>
|
||||
|
||||
<H2>Status</H2>
|
||||
<P></P>
|
||||
|
||||
<H2>Work to do</H2>
|
||||
<P></P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
41
server/srvgosprotocol.C
Normal file
41
server/srvgosprotocol.C
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "srvgosprotocol.H"
|
||||
#include "srvgosmanager.H"
|
||||
#include "srvgosmessage.H"
|
||||
#include "msgsrvcli.H"
|
||||
|
||||
CSrvGOSProtocol::CSrvGOSProtocol(CSocket * socket, CTimeKeeper * timeKeeper):
|
||||
CCommunicate(socket,timeKeeper){
|
||||
addMsg((MsgCreateFunc_t)CMsgSrvGOSLogin::createMsg);
|
||||
}
|
||||
|
||||
void CSrvGOSProtocol::quit(){
|
||||
CSrvGOSManager * manager = (CSrvGOSManager*)getManager();
|
||||
|
||||
manager->quit();
|
||||
}
|
||||
|
||||
void CSrvGOSProtocol::sendHello(){
|
||||
CMsgHello * msg = new CMsgHello(PROTOCOL_VERSION);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
36
server/srvgosprotocol.H
Normal file
36
server/srvgosprotocol.H
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _SRVGOSPROTOCOL_H
|
||||
#define _SRVGOSPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
|
||||
class CSrvGOSProtocol: public CCommunicate {
|
||||
|
||||
public:
|
||||
CSrvGOSProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
|
||||
|
||||
virtual void quit();
|
||||
|
||||
void sendHello();
|
||||
|
||||
};
|
||||
|
||||
#endif // _SRVGOSPROTOCOL_H
|
||||
BIN
server/userdb/index.dat
Normal file
BIN
server/userdb/index.dat
Normal file
Binary file not shown.
Reference in New Issue
Block a user