Recovered from microbel

This commit is contained in:
rot
2025-03-05 08:35:31 +01:00
committed by h7x4
commit 88b92402a8
601 changed files with 82177 additions and 0 deletions

1
gos/.cvsignore Normal file
View File

@@ -0,0 +1 @@
gos buildgosdb

10
gos/Makefile.am Normal file
View File

@@ -0,0 +1,10 @@
INCLUDES = -I../common/include @X_CFLAGS@ @GL_CFLAGS@ @TIFF_CFLAGS@
bin_PROGRAMS = buildgosdb gos
buildgosdb_SOURCES = buildgosdb.C remapgeometry.C
gos_SOURCES = geocache.C gos.C gos_main.C goscache.C gosmanager.C gosmessage.C gosprotocol.C gossrvmanager.C gossrvmessage.C gossrvprotocol.C gossrvsocket.C gossrvsrvsocket.C matcache.C texcache.C
gos_LDADD = -L../common/lib/geometry -lgeometry -L../common/lib/texture -ltexture -L../common/lib/utils -lpvvmudutils -L../common/lib/gos -lgos -L../common/lib/srvcli -lsrvcli -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff -lm @NETLIBS@
buildgosdb_LDADD = -L../common/lib/geometry -lgeometry -L../common/lib/texture -ltexture -L../common/lib/utils -lpvvmudutils -L../common/lib/gos -lgos -L../common/lib/srvcli -lsrvcli @TIFF_LIBS@ -ltiff

361
gos/Makefile.in Normal file
View File

@@ -0,0 +1,361 @@
# 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 @X_CFLAGS@ @GL_CFLAGS@ @TIFF_CFLAGS@
bin_PROGRAMS = buildgosdb gos
buildgosdb_SOURCES = buildgosdb.C remapgeometry.C
gos_SOURCES = geocache.C gos.C gos_main.C goscache.C gosmanager.C gosmessage.C gosprotocol.C gossrvmanager.C gossrvmessage.C gossrvprotocol.C gossrvsocket.C gossrvsrvsocket.C matcache.C texcache.C
gos_LDADD = -L../common/lib/geometry -lgeometry -L../common/lib/texture -ltexture -L../common/lib/utils -lpvvmudutils -L../common/lib/gos -lgos -L../common/lib/srvcli -lsrvcli -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff -lm @NETLIBS@
buildgosdb_LDADD = -L../common/lib/geometry -lgeometry -L../common/lib/texture -ltexture -L../common/lib/utils -lpvvmudutils -L../common/lib/gos -lgos -L../common/lib/srvcli -lsrvcli @TIFF_LIBS@ -ltiff
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
buildgosdb_OBJECTS = buildgosdb.o remapgeometry.o
buildgosdb_DEPENDENCIES =
buildgosdb_LDFLAGS =
gos_OBJECTS = geocache.o gos.o gos_main.o goscache.o gosmanager.o \
gosmessage.o gosprotocol.o gossrvmanager.o gossrvmessage.o \
gossrvprotocol.o gossrvsocket.o gossrvsrvsocket.o matcache.o texcache.o
gos_DEPENDENCIES =
gos_LDFLAGS =
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in TODO
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/buildgosdb.P .deps/geocache.P .deps/gos.P \
.deps/gos_main.P .deps/goscache.P .deps/gosmanager.P .deps/gosmessage.P \
.deps/gosprotocol.P .deps/gossrvmanager.P .deps/gossrvmessage.P \
.deps/gossrvprotocol.P .deps/gossrvsocket.P .deps/gossrvsrvsocket.P \
.deps/matcache.P .deps/remapgeometry.P .deps/texcache.P
SOURCES = $(buildgosdb_SOURCES) $(gos_SOURCES)
OBJECTS = $(buildgosdb_OBJECTS) $(gos_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 gos/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
buildgosdb: $(buildgosdb_OBJECTS) $(buildgosdb_DEPENDENCIES)
@rm -f buildgosdb
$(CXXLINK) $(buildgosdb_LDFLAGS) $(buildgosdb_OBJECTS) $(buildgosdb_LDADD) $(LIBS)
gos: $(gos_OBJECTS) $(gos_DEPENDENCIES)
@rm -f gos
$(CXXLINK) $(gos_LDFLAGS) $(gos_OBJECTS) $(gos_LDADD) $(LIBS)
.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 = gos
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 gos/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-binPROGRAMS
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-binPROGRAMS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
distclean-depend distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
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:

11
gos/TODO Normal file
View File

@@ -0,0 +1,11 @@
Change file names
gosmanager.H -> gosclimanager.H
gosmanager.C -> gosclimanager.C
gosprotocol.H -> goscliprotocol.H
gosprotocol.C -> goscliprotocol.C
gossrvsocket.H -> gosclisrvsocket.H
gossrvsocket.C -> gosclisrvsocket.C
Ny quit kode! M<> f<> sent melding om at GOS slutter til pvvmudsrv. Kan ikke
bare slutte timekeeper loope i CGOS::quit(). Dette m<> gj<67>re samtidig som
samme feil rettes i worldsrv.

276
gos/buildgosdb.C Normal file
View File

@@ -0,0 +1,276 @@
/*
* 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 <sys/param.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include "pvvmud.H"
#include "geometry.H"
#include "namedb.H"
#include "crossindex.H"
#include "remapgeometry.H"
#include "exception.H"
void remapGeometry(FILE * goscfgFile,char * gosDBPath, CNameDB * gosbogndb, CNameDB * gosmatndb);
void remapMaterial(char * gosDBPath, CNameDB * gosmatndb, CNameDB * gostexndb);
void remapTexture(char * gosDBPath, CNameDB * gostexndb);
int main(int argc, char * argv[]){
char goscfgName[MAXPATHLEN];
FILE * goscfgFile;
char gosDBPath[MAXPATHLEN];
char outName[MAXPATHLEN];
CNameDB *gosbogndb,*gosmatndb,*gostexndb;
// Parse arguments
if (argc != 2) {
cerr << "usage: " << argv[0] << " <gos_cfg>\n";
exit(1);
}
strcpy(goscfgName,argv[1]);
goscfgFile = fopen(goscfgName,"r");
if (goscfgFile == NULL){
cerr << "Faild to open config file: " << goscfgName << endl;
exit(1);
}
cout << "Config file: " << goscfgName << endl;
// Load gos DB path from config file
if (fscanf(goscfgFile,"%s\n",gosDBPath)!= 1){
cerr << "Faild to locate GOS DB path" << endl;
exit(1);
}
cout << "GOS DB path: " << gosDBPath << endl;
// Prepare namedbs
gosbogndb = new CNameDB();
gosmatndb = new CNameDB();
gostexndb = new CNameDB();
// Do the stuff
cout << "Process geometries" << endl;
remapGeometry(goscfgFile,gosDBPath,gosbogndb,gosmatndb);
cout << "Process materials" << endl;
remapMaterial(gosDBPath,gosmatndb,gostexndb);
cout << "Process textures" << endl;
remapTexture(gosDBPath,gostexndb);
// Save namedbs
sprintf(outName,"%sgosbog.ndb",gosDBPath);
cout << "Writing: " << outName << endl;
gosbogndb->save(outName);
sprintf(outName,"%sgosmat.ndb",gosDBPath);
cout << "Writing: " << outName << endl;
gosmatndb->save(outName);
sprintf(outName,"%sgostex.ndb",gosDBPath);
cout << "Writing: " << outName << endl;
gostexndb->save(outName);
// Clean up files and memory
fclose(goscfgFile);
delete gosbogndb;
delete gosmatndb;
}
void remapGeometry(FILE * goscfgFile, char * gosDBPath,
CNameDB * gosbogndb, CNameDB * gosmatndb){
CNameDB *ndb;
char cfgName[MAXPATHLEN];
char bogName[MAXPATHLEN];
char ndbName[MAXPATHLEN];
char outName[MAXPATHLEN];
CCrossIndex * crossIndex;
CRemapGeometry * objgeo;
int bogid;
while (fscanf(goscfgFile,"%s\n",cfgName)==1){
bogid = gosbogndb->insert(cfgName);
// Create fileNames
strcpy(bogName,cfgName); strcat(bogName,".bog");
strcpy(ndbName,cfgName); strcat(ndbName,".ndb");
cout << "Loading: " << bogName << flush;
// Load data
try {
// Load geometry
objgeo = new CRemapGeometry(bogid);
objgeo->load(bogName);
// Load name db
cout << ", reading ndb" << flush;
ndb = new CNameDB();
ndb->load(ndbName);
} catch (CException *e){
delete e;
cout << " FAILED!" << endl;
continue; // Failed continue with next file
}
crossIndex = gosmatndb->merge(ndb);
cout << ", remapping" << flush;
objgeo->remapMaterialIDs( crossIndex );
delete crossIndex;
// Write geometry
sprintf(outName,"%s%i.bog",gosDBPath,bogid);
cout << ", saveing: " << outName << flush ;
objgeo->save( outName );
// Clean up memory
delete ndb;
delete objgeo;
cout << ", done." << endl ;
}
return;
}
void remapMaterial(char * gosDBPath, CNameDB * gosmatndb, CNameDB * gostexndb){
char matName[MAXPATHLEN];
char matndbName[MAXPATHLEN];
char outName[MAXPATHLEN];
CRemapMaterial * mat;
CNameDB * ndb;
CNameDBItem * item;
CCrossIndex * crossIndex;
item = gosmatndb->getFirst();
while (item != NULL){
// Create fileNames
strcpy(matName,item->getName()); strcat(matName,".bmat");
strcpy(matndbName,item->getName()); strcat(matndbName,".ndb");
cout << "Loading: " << matName << flush;
try {
// Load material
mat = new CRemapMaterial();
mat->load(matName);
} catch (CException *e){
delete e;
cout << " FAILED!" << endl;
item = item->getNext();
continue;
}
try {
// Load name db
cout << ", reading ndb" << flush;
ndb = new CNameDB();
ndb->load(matndbName);
} catch (CException *e){
delete e;
cout << " FAILED" << flush;
ndb = NULL;
}
// Create crossindex and remap
if (ndb != NULL){
cout << ", remapping" << flush;
crossIndex = gostexndb->merge(ndb);
mat->remapTextureIDs( crossIndex );
delete crossIndex;
}
sprintf(outName,"%s%i.bmat",gosDBPath,item->getId());
cout << ", saveing " << outName << flush;
mat->save( outName );
// Clean up memory
if (ndb != NULL) delete ndb;
delete mat;
cout << ", done" << endl ;
item = item->getNext();
}
}
void remapTexture(char * gosDBPath, CNameDB * gostexndb){
char texName[MAXPATHLEN];
char outName[MAXPATHLEN];
CTexture * tex;
CNameDBItem * item;
item = gostexndb->getFirst();
while (item != NULL){
// Create fileNames
strcpy(texName,item->getName()); strcat(texName,".tex");
cout << "Loading: " << texName << flush;
// Load texture
tex = new CTexture();
try {
tex->load(texName);
} catch (CException *e){
delete e;
cout << " FAILED!" << endl;
item = item->getNext();
delete tex;
continue;
}
sprintf(outName,"%s%i.tex",gosDBPath,item->getId());
cout << ", saveing " << outName << flush;
try {
tex->save( outName );
} catch (CException *e){
delete e;
cout << " FAILED!" << endl;
item = item->getNext();
delete tex;
continue;
}
// Clean up memory
delete tex;
cout << ", done" << endl;
item = item->getNext();
}
}

54
gos/geocache.C Normal file
View 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 "pvvmud.H"
#include <limits.h>
#include <stdio.h>
#include "geocache.H"
#include "msggos.H"
CGeoCache::CGeoCache(char * gosLibPath): CGOSCache(gosLibPath){
}
CObject * CGeoCache::failFunc(int id){
char name[PATH_MAX];
CGeometry * geometry;
//Create file name
sprintf(name,"%s/%i.bog",getGosLibPath(),id);
printf("Geometry cache failure id %i. Loading file: %s\n",id,name);
geometry = new CGeometry(id);
try {
geometry->load(name);
} catch(CException * e){
delete e;
printf("ERROR: Failed to load geometry %i\n",id);
return NULL;
}
CMsgGeometry * msg = new CMsgGeometry(*geometry);
delete geometry;
return msg;
}

34
gos/geocache.H Normal file
View 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 _GEOCACHE_H
#define _GEOCACHE_H
#include "goscache.H"
class CGeoCache : public CGOSCache {
public:
CGeoCache(char * gosLibPath);
virtual CObject * failFunc(int id);
};
#endif // _GEOCACHE_H

200
gos/gos.C Normal file
View File

@@ -0,0 +1,200 @@
/*
* 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 "socket.H"
#include "gos.H"
#include "gosmanager.H"
#include "gossrvmanager.H"
CGOS::CGOS(COption *option){
char *gosLibPath;
gosLibPath=option->getString("goslib");
printf("goslibpath:%s\n",gosLibPath);
m_timeKeeper = new CTimeKeeper();
m_cliManagerList = new CObjectList();
m_srvManager = NULL;
m_srvSocket = NULL;
m_geoCache = new CGeoCache(gosLibPath);
m_matCache = new CMatCache(gosLibPath);
m_texCache = new CTexCache(gosLibPath);
CClientSocket * socket = NULL;
try {
CInetAddress server(option->getString("server"),SERVER_GOS_PORT);
socket = new CClientSocket(server.getAddress(),server.getPort());
socket->setNonBlocking();
cout << "GOS Server manager connected\n";
addSrvManager( new CGOSSrvManager(this, new CGOSSrvProtocol(socket,m_timeKeeper)));
} catch (CSocketException * e){
cout << "Failed to connect to server!\n";
delete e;
startSrvSocket();
}
try {
m_cliSocket = new CGOSCliSrvSocket(this,option->getString("address"),
option->getInt("port"),m_timeKeeper);
} catch (CSocketException * e){
cout << "Failed to create client SrvSocket!\n";
delete e;
exit(1);
}
m_timeKeeper->addHeartBeat(4*1024,this);
}
CGOS::~CGOS(){
m_timeKeeper->rmHeartBeat(this);
m_cliManagerList->deleteAll();
delete m_cliManagerList;
if (m_srvManager != NULL) delete m_srvManager;
m_cliSocket->close();
delete m_cliSocket;
stopSrvSocket();
delete m_timeKeeper;
delete m_geoCache;
delete m_matCache;
delete m_texCache;
}
CInetAddress &CGOS::getAddress(){
return m_cliSocket->getLocalAddress();
}
int CGOS::timeKeeperHB(){
// cout << "Heart beat\n";
CObjectListItem * item = m_cliManagerList->getFirst();
while (item != NULL){
CGOSCliManager * cliManager = (CGOSCliManager*)item->getObject();
item = item->getNext();
if (cliManager->getQuit()){
cout << "Client " << cliManager->getId() << " deleted\n";
removeCliManager(cliManager);
}
}
if ((m_srvSocket != NULL) && (m_srvSocket->getQuit())){
stopSrvSocket();
}
if ((m_srvManager != NULL) && (m_srvManager->getQuit())){
cout << "GOS Server manager deleted\n";
removeSrvManager(m_srvManager);
}
return TRUE;
}
void CGOS::addCliManager(CGOSCliManager * cliManager){
m_cliManagerList->addLast((CObject*)cliManager);
}
void CGOS::removeCliManager(CGOSCliManager * cliManager){
m_cliManagerList->remove((CObject*)cliManager);
delete cliManager;
}
void CGOS::addSrvManager(CGOSSrvManager * srvManager){
if (m_srvManager != NULL){
cout << "WARNING: Multiple servers connected!!\nDeleting old server\n";
delete m_srvManager;
}
m_srvManager = srvManager;
}
void CGOS::removeSrvManager(CGOSSrvManager * srvManager){
if (srvManager != m_srvManager){
cout << "WARNING: Removing a not assigned server!\n";
delete srvManager;
} else {
delete m_srvManager;
m_srvManager = NULL;
startSrvSocket();
}
}
void CGOS::startSrvSocket(){
if (m_srvSocket != NULL){
cout << "WARNING: Server SrvSocket started!\n";
}
try {
m_srvSocket = new CGOSSrvSrvSocket(this,GOS_SERVER_PORT,m_timeKeeper);
cout << "Server SrvSocket started\n";
} catch (CSocketException * e){
cout << "Failed to create server SrvSocket!\n";
delete e;
}
}
void CGOS::stopSrvSocket(){
if (m_srvSocket != NULL){
m_srvSocket->close();
delete m_srvSocket;
m_srvSocket = NULL;
cout << "Server SrvSocket stoped\n";
}
}
void CGOS::quit(){
m_timeKeeper->stopLoop();
}
void CGOS::restart(){
m_geoCache->clear();
m_matCache->clear();
m_texCache->clear();
}
void CGOS::run(){
m_timeKeeper->mainLoop();
}
CMsgGeometry * CGOS::getGeometry(int id){
return (CMsgGeometry*)m_geoCache->get(id);
}
CMsgMaterial * CGOS::getMaterial(int id){
return (CMsgMaterial*)m_matCache->get(id);
}
CMsgTexture * CGOS::getTexture(int id){
return (CMsgTexture*)m_texCache->get(id);
}

78
gos/gos.H Normal file
View File

@@ -0,0 +1,78 @@
/*
* 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 _GOS_H
#define _GOS_H
#include "timekeeper.H"
#include "gossrvsocket.H"
#include "gossrvsrvsocket.H"
#include "geocache.H"
#include "matcache.H"
#include "texcache.H"
#include "msggos.H"
#include "objectlist.H"
#include "option.H"
class CGOSCliManager;
class CGOSSrvManager;
class CGOS : public CTimeKeeperItem {
CTimeKeeper * m_timeKeeper;
CGOSCliSrvSocket * m_cliSocket;
CGOSSrvSrvSocket * m_srvSocket;
CGeoCache * m_geoCache;
CMatCache * m_matCache;
CTexCache * m_texCache;
CObjectList * m_cliManagerList;
// Don't allow a list of servers
CGOSSrvManager * m_srvManager;
public:
CGOS(COption *option);
virtual ~CGOS();
CInetAddress &getAddress();
virtual int timeKeeperHB();
void addCliManager( CGOSCliManager * cliManager );
void removeCliManager( CGOSCliManager * cliManager );
void addSrvManager( CGOSSrvManager * srvManager );
void removeSrvManager( CGOSSrvManager * srvManager );
void startSrvSocket();
void stopSrvSocket();
void quit();
void restart();
void run();
CMsgGeometry * getGeometry(int id);
CMsgMaterial * getMaterial(int id);
CMsgTexture * getTexture(int id);
};
#endif // _GOS_H

1
gos/gos.conf Normal file
View File

@@ -0,0 +1 @@
goslib=../mudworld/libgos

70
gos/gos_main.C Normal file
View File

@@ -0,0 +1,70 @@
/*
* 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 <unistd.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <sys/utsname.h>
#include "gos.H"
#include "option.H"
CGOS * gos;
void signalhandler(int signum){
switch(signum){
case SIGINT:
printf("Recieved sigint: Closing server!\n");
gos->quit();
break;
case SIGHUP:
printf("Recieved sighup: Restarting server!\n");
gos->restart();
signal(SIGHUP, signalhandler);
break;
}
}
int main(int argc, char * argv[]){
COption option;
option.setValue("address",'a',"localhost");
option.setValue("port",'p',GOS_CLIENT_PORT);
option.setValue("server",'s',"localhost");
option.setValue("goslib",'g',"../lib/gos/");
option.loadOption("gos.conf");
option.parseArguments(argc,argv);
// Create gos and run
gos = new CGOS(&option);
// Install signal handlers
signal(SIGINT, signalhandler);
signal(SIGHUP, signalhandler);
signal(SIGPIPE, SIG_IGN);
gos->run();
delete gos;
exit(0);
}

26
gos/goscache.C Normal file
View 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 "pvvmud.H"
#include "goscache.H"
CGOSCache::CGOSCache(char * gosLibPath): CCache(){
this->gosLibPath = gosLibPath;
}

32
gos/goscache.H Normal file
View 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 _GOSCACHE_H
#define _GOSCACHE_H
#include "cache.H"
class CGOSCache : public CCache {
char * gosLibPath;
public:
CGOSCache(char * gosLibPath);
char * getGosLibPath() { return gosLibPath; }
};
#endif // _GOSCACHE_H

47
gos/gosmanager.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include <iostream.h>
#include "gosmanager.H"
static int currGOSCliManagerId = 0;
CGOSCliManager::CGOSCliManager(CGOS * gos, CGOSCliProtocol * protocol):CManager(protocol){
char name[16];
this->gos = gos;
id = ++currGOSCliManagerId;
m_quit = FALSE;
sprintf(name,"Client %i",id);
getProtocol()->setName(name);
}
void CGOSCliManager::quit(){
cout << "Client " << getId() << " marked quit\n";
m_quit = TRUE;
}
int CGOSCliManager::getQuit(){
return m_quit;
}
void CGOSCliManager::sendMsg(CMessage * msg){
getCommunicate()->sendMessage(msg,FALSE);
}

45
gos/gosmanager.H Normal file
View File

@@ -0,0 +1,45 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GOSCLIMANAGER_H
#define _GOSCLIMANAGER_H
#include "gos.H"
#include "gosprotocol.H"
#include "manager.H"
class CGOSCliManager: public CManager {
CGOS * gos;
int id;
int m_quit;
public:
CGOSCliManager(CGOS * gos, CGOSCliProtocol * protocol);
CGOS * getGOS(){ return gos; }
int getId(){ return id; }
CGOSCliProtocol * getProtocol() { return (CGOSCliProtocol*)getCommunicate();}
virtual void quit();
int getQuit();
void sendMsg(CMessage * msg);
};
#endif // _GOSCLIMANAGER_H

65
gos/gosmessage.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include <stdio.h>
#include "gosmessage.H"
#include "gos.H"
#include "gosmanager.H"
///////////////////////////////////////////////////////////////////////////////
// MsgGOSRequestGOS
CMsgGOSRequestGOS::CMsgGOSRequestGOS():CMsgGOSRequest(){
}
CMsgGOSRequestGOS * CMsgGOSRequestGOS::createMsg(){
return new CMsgGOSRequestGOS();
}
int CMsgGOSRequestGOS::executeMsg(){
static char * GOSRequestName[] = {"geometry","material","texture"};
CGOSCliManager * manager = (CGOSCliManager*)getManager();
printf("Client %i request for %s %i\n",manager->getId(),GOSRequestName[getRequestType()],getObjectId());
CGOS * gos = manager->getGOS();
CMessage * msg = NULL;
switch(getRequestType()){
case GOSREQUEST_GEOMETRY:
msg = gos->getGeometry(getObjectId());
break;
case GOSREQUEST_MATERIAL:
msg = gos->getMaterial(getObjectId());
break;
case GOSREQUEST_TEXTURE:
msg = gos->getTexture(getObjectId());
break;
}
if (msg != NULL) manager->sendMsg(msg);
else {
printf("Request FAILED!!!!!!!\n");
manager->sendMsg(new CMsgGOSError('A'));
}
return TRUE;
}

33
gos/gosmessage.H Normal file
View File

@@ -0,0 +1,33 @@
/*
* 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 _GOSMESSAGE_H
#define _GOSMESSAGE_H
#include "msggos.H"
class CMsgGOSRequestGOS : public CMsgGOSRequest {
public:
CMsgGOSRequestGOS();
static CMsgGOSRequestGOS * createMsg();
virtual int executeMsg();
};
#endif // _GOSMESSAGE_H

35
gos/gosprotocol.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include "gosprotocol.H"
#include "gosmessage.H"
#include "gosmanager.H"
CGOSCliProtocol::CGOSCliProtocol(CSocket * socket,CTimeKeeper * timeKeeper)
:CCommunicate(socket,timeKeeper) {
addMsg((MsgCreateFunc_t)CMsgGOSRequestGOS::createMsg);
}
void CGOSCliProtocol::quit(){
CGOSCliManager * manager = (CGOSCliManager*)getManager();
manager->quit();
}

35
gos/gosprotocol.H Normal file
View 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 _GOSCLIPROTOCOL_H
#define _GOSCLIPROTOCOL_H
#include "communicate.H"
#include "socket.H"
class CGOSCliProtocol: public CCommunicate {
public:
CGOSCliProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
virtual void quit();
};
#endif // _GOSCLIPROTOCOL_H

46
gos/gossrvmanager.C Normal file
View 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 "gossrvmanager.H"
#include "msgsrvgos.H"
#include "msgserver.H"
CGOSSrvManager::CGOSSrvManager(CGOS * gos, CGOSSrvProtocol * protocol):CManager(protocol){
m_gos = gos;
m_quit = FALSE;
getProtocol()->setName("Server");
}
void CGOSSrvManager::quit(){
cout << "Server marked quit\n";
m_quit = TRUE;
}
int CGOSSrvManager::getQuit(){
return m_quit;
}
void CGOSSrvManager::hello(){
cout << "Hello from server\n";
CGOSSrvProtocol * protocol = getProtocol();
protocol->sendMessage(new CMsgServerLogin( m_gos->getAddress() ),TRUE);
}

43
gos/gossrvmanager.H Normal file
View File

@@ -0,0 +1,43 @@
/*
* 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 _GOSSRVMANAGER_H
#define _GOSSRVMANAGER_H
#include "gos.H"
#include "gossrvprotocol.H"
#include "manager.H"
class CGOSSrvManager: public CManager {
CGOS * m_gos;
int m_quit;
public:
CGOSSrvManager(CGOS * gos, CGOSSrvProtocol * protocol);
CGOS * getGOS(){ return m_gos; }
CGOSSrvProtocol * getProtocol(){ return (CGOSSrvProtocol*)getCommunicate(); }
virtual void quit();
int getQuit();
void hello();
};
#endif // _GOSSRVMANAGER_H

41
gos/gossrvmessage.C Normal file
View 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 "gossrvmessage.H"
#include "gos.H"
#include "gossrvmanager.H"
///////////////////////////////////////////////////////////////////////////////
// MsgGOSSrvHello
CMsgGOSSrvHello::CMsgGOSSrvHello():CMsgHello(){
}
CMsgGOSSrvHello * CMsgGOSSrvHello::createMsg(){
return new CMsgGOSSrvHello();
}
int CMsgGOSSrvHello::executeMsg(){
CGOSSrvManager * manager = (CGOSSrvManager*)getManager();
manager->hello();
return TRUE;
}

33
gos/gossrvmessage.H Normal file
View File

@@ -0,0 +1,33 @@
/*
* 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 _GOSSRVMESSAGE_H
#define _GOSSRVMESSAGE_H
#include "msgsrvcli.H"
class CMsgGOSSrvHello : public CMsgHello {
public:
CMsgGOSSrvHello();
static CMsgGOSSrvHello * createMsg();
virtual int executeMsg();
};
#endif // _GOSSRVMESSAGE_H

35
gos/gossrvprotocol.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include "gossrvprotocol.H"
#include "gossrvmanager.H"
#include "gossrvmessage.H"
CGOSSrvProtocol::CGOSSrvProtocol(CSocket * socket,CTimeKeeper * timeKeeper)
:CCommunicate(socket,timeKeeper) {
addMsg((MsgCreateFunc_t)CMsgGOSSrvHello::createMsg);
}
void CGOSSrvProtocol::quit(){
CGOSSrvManager * manager = (CGOSSrvManager*)getManager();
manager->quit();
}

35
gos/gossrvprotocol.H Normal file
View 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 _GOSSRVPROTOCOL_H
#define _GOSSRVPROTOCOL_H
#include "communicate.H"
#include "socket.H"
class CGOSSrvProtocol: public CCommunicate {
public:
CGOSSrvProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
virtual void quit();
};
#endif // _GOSSRVPROTOCOL_H

49
gos/gossrvsocket.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include <iostream.h>
#include "gos.H"
#include "gossrvsocket.H"
#include "gosprotocol.H"
#include "gosmanager.H"
CGOSCliSrvSocket::CGOSCliSrvSocket(CGOS * gos, char *addr, int port,
CTimeKeeper * timeKeeper): CServerSocket(addr,port){
m_timeKeeper = timeKeeper;
m_gos = gos;
m_timeKeeper->addFd(getFileDescriptor(),this,TIMEKEEPER_IN);
}
int CGOSCliSrvSocket::timeKeeperFD(int event){
CSocket * socket = accept();
socket->setNonBlocking();
CGOSCliManager * manager = new CGOSCliManager(m_gos,new CGOSCliProtocol(socket,m_timeKeeper));
cout << "New client (" << manager->getId() << "): ";
try {
cout << socket->getAddress().getHostName() << "\n";
} catch (CException * e){
cout << "Error: Resolving client hostname\n";
delete e;
}
m_gos->addCliManager(manager);
return TRUE;
}

38
gos/gossrvsocket.H Normal file
View File

@@ -0,0 +1,38 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GOSCLISRVSOCKET_H
#define _GOSCLISRVSOCKET_H
#include "socket.H"
#include "timekeeper.H"
class CGOS;
class CGOSCliSrvSocket : public CServerSocket, public CTimeKeeperItem {
CGOS * m_gos;
CTimeKeeper * m_timeKeeper;
public:
CGOSCliSrvSocket(CGOS * gos, char *addr,int port,CTimeKeeper * timeKeeper);
virtual int timeKeeperFD(int event);
};
#endif // _GOSSRVSOCKET_H

54
gos/gossrvsrvsocket.C Normal file
View 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 "pvvmud.H"
#include <iostream.h>
#include "gos.H"
#include "gossrvsrvsocket.H"
#include "gossrvprotocol.H"
#include "gossrvmanager.H"
CGOSSrvSrvSocket::CGOSSrvSrvSocket(CGOS * gos, int port, CTimeKeeper * timeKeeper): CServerSocket(port){
m_timeKeeper = timeKeeper;
m_gos = gos;
m_quit = FALSE;
m_timeKeeper->addFd(getFileDescriptor(),this,TIMEKEEPER_IN);
}
int CGOSSrvSrvSocket::timeKeeperFD(int event){
CSocket * socket = accept();
socket->setNonBlocking();
CGOSSrvManager * manager = new CGOSSrvManager(m_gos,new CGOSSrvProtocol(socket,m_timeKeeper));
cout << "New server: ";
try {
cout << socket->getAddress().getHostName() << "\n";
} catch (CException * e){
cout << "Error: Resolving client hostname\n";
delete e;
}
m_gos->addSrvManager(manager);
// Close srvSocket when server accepted
close();
m_quit = TRUE;
return FALSE; // REMOVE this timeKeeperItem from timeKeeper
}

41
gos/gossrvsrvsocket.H Normal file
View File

@@ -0,0 +1,41 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GOSSRVSRVSOCKET_H
#define _GOSSRVSRVSOCKET_H
#include "socket.H"
#include "timekeeper.H"
class CGOS;
class CGOSSrvSrvSocket : public CServerSocket, public CTimeKeeperItem {
CGOS * m_gos;
CTimeKeeper * m_timeKeeper;
int m_quit;
public:
CGOSSrvSrvSocket(CGOS * gos, int port,CTimeKeeper * timeKeeper);
int getQuit(){ return m_quit; }
virtual int timeKeeperFD(int event);
};
#endif // _GOSSRVSOCKET_H

47
gos/matcache.C Normal file
View 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
*
*/
#include "pvvmud.H"
#include <limits.h>
#include <stdio.h>
#include "matcache.H"
#include "msggos.H"
CMatCache::CMatCache(char * gosLibPath):CGOSCache(gosLibPath){
}
CObject * CMatCache::failFunc(int id){
char name[PATH_MAX];
CMaterial material;
//Create file name
sprintf(name,"%s/%i.bmat",getGosLibPath(),id);
printf("Material cache failure id %i. Loading file: %s\n",id,name);
material.setId(id);
if (!material.load(name)){
printf("ERROR: Failed to load material %i\n",id);
return NULL;
}
CMsgMaterial * msg = new CMsgMaterial(material);
return msg;
}

34
gos/matcache.H Normal file
View 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 _MATCACHE_H
#define _MATCACHE_H
#include "goscache.H"
class CMatCache : public CGOSCache {
public:
CMatCache(char * gosLibPath);
virtual CObject * failFunc(int id);
};
#endif // _MATCACHE_H

52
gos/remapgeometry.C Normal file
View File

@@ -0,0 +1,52 @@
/*
* 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 "remapgeometry.H"
CRemapGeometry::CRemapGeometry(int geometryId):CGeometry(geometryId){
}
CGeometry * CRemapGeometry::newGeometry(int geometryId){
return new CRemapGeometry(geometryId);
}
void CRemapGeometry::remapMaterialIDs(CCrossIndex * crossIndex){
CPolygon * poly;
int numPoly,ii;
int type, materialId, numVertices, numNormals, numTexCoords;
numPoly = getNumPolygons();
for (ii = 0; ii < numPoly; ii++){
poly = getPolygon( ii );
poly->get( &type, &materialId, &numVertices,
&numNormals, &numTexCoords);
poly->setMaterial( crossIndex->getA(materialId));
}
CRemapGeometry * next = (CRemapGeometry*)getNext();
if (next != NULL) next->remapMaterialIDs(crossIndex);
}
void CRemapMaterial::remapTextureIDs(CCrossIndex * crossIndex){
setTextureId( crossIndex->getA( getTextureId() ) );
}

39
gos/remapgeometry.H Normal file
View 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 _REMAPGEOMETRY_H
#define _REMAPGEOMETRY_H
#include "geometry.H"
#include "material.H"
#include "crossindex.H"
class CRemapGeometry: public CGeometry {
public:
CRemapGeometry(int geometryId);
virtual CGeometry * newGeometry(int geometryId);
void remapMaterialIDs(CCrossIndex * crossIndex);
};
class CRemapMaterial: public CMaterial {
public:
void remapTextureIDs(CCrossIndex * crossIndex);
};
#endif // _REMAPOBJECTGEOMETRY_H

52
gos/texcache.C Normal file
View File

@@ -0,0 +1,52 @@
/*
* 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 <limits.h>
#include <stdio.h>
#include "texcache.H"
#include "msggos.H"
#include "exception.H"
CTexCache::CTexCache(char * gosLibPath): CGOSCache(gosLibPath){
}
CObject * CTexCache::failFunc(int id){
char name[PATH_MAX];
CTexture * texture = new CTexture(id);
//Create file name
sprintf(name,"%s/%i.tex",getGosLibPath(),id);
printf("Texture cache failure id %i. Loading file: %s\n",id,name);
try {
texture->load(name);
} catch (CException *e){
delete e;
printf("ERROR: Failed to load texture %i\n",id);
return NULL;
}
CMsgTexture * msg = new CMsgTexture(*texture);
delete texture;
return msg;
}

34
gos/texcache.H Normal file
View 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 _TEXCACHE_H
#define _TEXCACHE_H
#include "goscache.H"
class CTexCache : public CGOSCache {
public:
CTexCache(char * gosLibPath);
virtual CObject * failFunc(int id);
};
#endif // _TEXCACHE_H