Recovered from microbel
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user