Recovered from microbel
This commit is contained in:
4
client/.cvsignore
Normal file
4
client/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
pvvmud
|
||||
goscache
|
||||
.pvvmud_history
|
||||
pvvmudscreen.tex
|
0
client/.pvvmud.rc
Normal file
0
client/.pvvmud.rc
Normal file
29
client/.pvvmud_ifm
Normal file
29
client/.pvvmud_ifm
Normal file
@@ -0,0 +1,29 @@
|
||||
playerlook_up key_z
|
||||
playerlook_down key_a
|
||||
playerlook_right key_s
|
||||
playerlook_left key_x
|
||||
playerlook_forward key_space
|
||||
playermove_stepleft key_h
|
||||
playermove_stepbackward key_j
|
||||
playermove_stepforward key_k
|
||||
playermove_stepright key_l
|
||||
usercommand_0 key_0
|
||||
usercommand_1 key_1
|
||||
usercommand_2 key_2
|
||||
usercommand_3 key_3
|
||||
usercommand_4 key_4
|
||||
usercommand_5 key_5
|
||||
usercommand_6 key_6
|
||||
usercommand_7 key_7
|
||||
usercommand_8 key_8
|
||||
usercommand_9 key_9
|
||||
quit key_escape
|
||||
toggle_inputmode key_enter
|
||||
playerlook_forward key_up
|
||||
playerlook_backward key_down
|
||||
playerlook_left key_left
|
||||
playerlook_right key_right
|
||||
playerlook_up key_page_up
|
||||
playerlook_down key_page_down
|
||||
pick mouse_left_up
|
||||
dump key_d
|
15
client/Makefile.am
Normal file
15
client/Makefile.am
Normal file
@@ -0,0 +1,15 @@
|
||||
CC = $(CXX) $(CXXFLAGS)
|
||||
|
||||
INCLUDES = -I../common/include -Icoreclient -Irenderer -Igui @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
SUBDIRS = coreclient renderer gui
|
||||
|
||||
CLEANFILES = goscache/*
|
||||
|
||||
bin_PROGRAMS = pvvmud
|
||||
|
||||
pvvmud_SOURCES = pvvmud.C pvvmudclient.C cliviewpoint.C inputfunction.C inputfunctionmap.C stdinput.C clicmdparser.C
|
||||
|
||||
pvvmud_LDADD = coreclient/libcoreclient.a gui/libgui.a renderer/librenderer.a -L../common/lib/gos -lgos -L../common/lib/texture -ltexture -L../common/lib/srvcli -lsrvcli -L../common/lib/geometry -lgeometry -L../common/lib/world -lworld -L../common/lib/utils -lpvvmudutils -lsrvcli -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff @GL_LIBS@ -lglut -lMesaGLU -lMesaGL @X_LIBS@ -lXi -lXext -lXmu -lXt @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ -lm @NETLIBS@
|
||||
|
||||
|
432
client/Makefile.in
Normal file
432
client/Makefile.in
Normal file
@@ -0,0 +1,432 @@
|
||||
# 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 = :
|
||||
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@
|
||||
|
||||
CC = $(CXX) $(CXXFLAGS)
|
||||
|
||||
INCLUDES = -I../common/include -Icoreclient -Irenderer -Igui @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
SUBDIRS = coreclient renderer gui
|
||||
|
||||
CLEANFILES = goscache/*
|
||||
|
||||
bin_PROGRAMS = pvvmud
|
||||
|
||||
pvvmud_SOURCES = pvvmud.C pvvmudclient.C cliviewpoint.C inputfunction.C inputfunctionmap.C stdinput.C clicmdparser.C
|
||||
|
||||
pvvmud_LDADD = coreclient/libcoreclient.a gui/libgui.a renderer/librenderer.a -L../common/lib/gos -lgos -L../common/lib/texture -ltexture -L../common/lib/srvcli -lsrvcli -L../common/lib/geometry -lgeometry -L../common/lib/world -lworld -L../common/lib/utils -lpvvmudutils -lsrvcli -L../common/lib/crypto -lcrypto @TIFF_LIBS@ -ltiff @GL_LIBS@ -lglut -lMesaGLU -lMesaGL @X_LIBS@ -lXi -lXext -lXmu -lXt @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ -lm @NETLIBS@
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
pvvmud_OBJECTS = pvvmud.o pvvmudclient.o cliviewpoint.o inputfunction.o \
|
||||
inputfunctionmap.o stdinput.o clicmdparser.o
|
||||
pvvmud_DEPENDENCIES = coreclient/libcoreclient.a gui/libgui.a \
|
||||
renderer/librenderer.a
|
||||
pvvmud_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
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/clicmdparser.P .deps/cliviewpoint.P \
|
||||
.deps/inputfunction.P .deps/inputfunctionmap.P .deps/pvvmud.P \
|
||||
.deps/pvvmudclient.P .deps/stdinput.P
|
||||
SOURCES = $(pvvmud_SOURCES)
|
||||
OBJECTS = $(pvvmud_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 client/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:
|
||||
|
||||
pvvmud: $(pvvmud_OBJECTS) $(pvvmud_DEPENDENCIES)
|
||||
@rm -f pvvmud
|
||||
$(CXXLINK) $(pvvmud_LDFLAGS) $(pvvmud_OBJECTS) $(pvvmud_LDADD) $(LIBS)
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" = "." && dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = client
|
||||
|
||||
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 client/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.C
|
||||
@echo '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am: install-binPROGRAMS
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am: uninstall-binPROGRAMS
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
|
||||
distclean-depend distclean-generic clean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
|
||||
maintainer-clean-am: maintainer-clean-binPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-depend maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
||||
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
|
||||
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile install-data-recursive \
|
||||
uninstall-data-recursive install-exec-recursive \
|
||||
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
|
||||
all-recursive check-recursive installcheck-recursive info-recursive \
|
||||
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
||||
mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs-am installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
100
client/clicmdparser.C
Normal file
100
client/clicmdparser.C
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 "pvvmudclient.H"
|
||||
|
||||
|
||||
CCliCmdParser::CCliCmdParser(CPvvmudClient * client):
|
||||
CCommandParser()
|
||||
{
|
||||
m_client = client;
|
||||
|
||||
setCommandPrefix('!');
|
||||
|
||||
addCommand("help",(CommandFunc_t)&commandHelp);
|
||||
addCommand("dump",(CommandFunc_t)&commandDump);
|
||||
|
||||
}
|
||||
|
||||
CCliCmdParser::~CCliCmdParser(){
|
||||
}
|
||||
|
||||
void CCliCmdParser::printMsg(const string & msg){
|
||||
m_client->getConsole()->addMsg((char*)msg.c_str());
|
||||
}
|
||||
|
||||
|
||||
void CCliCmdParser::commandUnknown(const string & commandString){
|
||||
printMsg("Unkown command: " + commandString + "\n");
|
||||
}
|
||||
|
||||
void CCliCmdParser::commandChat(const string & chatMessage){
|
||||
m_client->getManager()->sendMsg(chatMessage.c_str());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandHelp
|
||||
// Syntax: /help [command]
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CCliCmdParser::commandHelp(argv_t & argv){
|
||||
if (argv.size() == 2){
|
||||
if (argv[1] == "help"){
|
||||
printMsg(
|
||||
"help [<command>]\n"
|
||||
" Use this command to get help.\n"
|
||||
);
|
||||
} else if (argv[1] == "dump"){
|
||||
printMsg(
|
||||
"dump [ screen | world ]\n"
|
||||
" screen : Dump screen to file \"pvvmudscreen.tif\"\n"
|
||||
" world : Dump world hiearchy to stdout.\n"
|
||||
);
|
||||
} else {
|
||||
printMsg( "Unkown kommand\n" );
|
||||
}
|
||||
} else {
|
||||
printMsg(
|
||||
"Help\n"
|
||||
" Client commands start with '!'\n"
|
||||
" Commands:\n"
|
||||
" !help\n"
|
||||
" !dump\n"
|
||||
" Use !help <command> for help about a command\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// commandDump
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CCliCmdParser::commandDump(argv_t & argv){
|
||||
if (argv[1] == "screen"){
|
||||
// m_client->getInputFunction()->executeFunction("capture");
|
||||
m_client->getInputFunction()->executeFunction("key_c");
|
||||
} else if (argv[1] == "world"){
|
||||
// m_client->getInputFunction()->executeFunction("dump");
|
||||
m_client->getInputFunction()->executeFunction("key_d");
|
||||
} else {
|
||||
parseCommand("!help dump");
|
||||
}
|
||||
}
|
||||
|
45
client/clicmdparser.H
Normal file
45
client/clicmdparser.H
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLICMDPARSER_H
|
||||
#define _CLICMDPARSER_H
|
||||
|
||||
#include "commandparser.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
class CCliCmdParser : public CCommandParser {
|
||||
|
||||
CPvvmudClient * m_client;
|
||||
|
||||
public:
|
||||
CCliCmdParser(CPvvmudClient * client);
|
||||
virtual ~CCliCmdParser();
|
||||
|
||||
private:
|
||||
void printMsg(const string & msg);
|
||||
|
||||
virtual void commandUnknown(const string & commandString);
|
||||
virtual void commandChat(const string & chatMessage);
|
||||
|
||||
void commandHelp(argv_t & argv);
|
||||
void commandDump(argv_t & argv);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLICMDPARSER_H
|
34
client/client.H
Normal file
34
client/client.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 _CLIENT_H
|
||||
#define _CLIENT_H
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include "mudtypes.h"
|
||||
#include "pvvmud.H"
|
||||
|
||||
// #define TEXTURECACHE_USEFILE
|
||||
|
||||
#define USE_LOCAL_FILE_CACHE
|
||||
|
||||
void save_params();
|
||||
void mousePick(int x,int y);
|
||||
|
||||
#endif // _CLIENT_H
|
21
client/client.html
Normal file
21
client/client.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>PVVMUD - client</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1>Client</H1>
|
||||
|
||||
<P>The PVVMUD client are the user interface for playing PVVMUD.</P>
|
||||
|
||||
<H2>Status</H2>
|
||||
<P>Current version are just a viewer for bog files</P>
|
||||
|
||||
<H2>Work to do</H2>
|
||||
<UL>
|
||||
<LI>Implement som kind of <A HREF="../doc/scenefileformat.html">scene description</A> format.
|
||||
<LI>Implement communication with a server. OK Andersr
|
||||
<LI>Forward user actions to a server. OK Andersr
|
||||
</UL>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
59
client/cliviewpoint.C
Normal file
59
client/cliviewpoint.C
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "client.H"
|
||||
#include "cliviewpoint.H"
|
||||
#include "matrix.H"
|
||||
#include <GL/glut.h>
|
||||
|
||||
CCliViewpoint::CCliViewpoint(CCliWorld * world){
|
||||
m_world = world;
|
||||
}
|
||||
|
||||
|
||||
void CCliViewpoint::transform(){
|
||||
|
||||
CMatrix transform;
|
||||
CCliObject * target = (CCliObject*)m_world->getObject(getTargetId());
|
||||
|
||||
if (target != NULL){
|
||||
target->getInvGlobalTransform(transform);
|
||||
}
|
||||
|
||||
transform.rotate(-getDirection());
|
||||
transform.translate(-getPosition());
|
||||
|
||||
glMultMatrixd(transform.getVector());
|
||||
|
||||
return;
|
||||
|
||||
double * pos = getPosition().getVector();
|
||||
double * dir = getDirection().getVector();
|
||||
|
||||
glRotated(-dir[0],0.0,0.0,1.0);
|
||||
glRotated(-dir[1],0.0,1.0,0.0);
|
||||
glRotated(-dir[2],1.0,0.0,0.0);
|
||||
glTranslated(-pos[0],-pos[1],-pos[2]);
|
||||
|
||||
}
|
||||
|
||||
void CCliViewpoint::setAspectRatio( float aspectRatio ){
|
||||
this->aspectRatio = aspectRatio;
|
||||
}
|
||||
|
41
client/cliviewpoint.H
Normal file
41
client/cliviewpoint.H
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLIVIEWPOINT_H
|
||||
#define _CLIVIEWPOINT_H
|
||||
|
||||
#include "viewpoint.H"
|
||||
#include "cliworld.H"
|
||||
|
||||
class CCliViewpoint: public CViewpoint {
|
||||
|
||||
float aspectRatio;
|
||||
CCliWorld * m_world;
|
||||
|
||||
public:
|
||||
|
||||
CCliViewpoint(CCliWorld * world);
|
||||
|
||||
void transform();
|
||||
|
||||
void setAspectRatio( float aspectRatio );
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLIVIEWPOINT_H
|
8
client/coreclient/Makefile.am
Normal file
8
client/coreclient/Makefile.am
Normal file
@@ -0,0 +1,8 @@
|
||||
INCLUDES = -I.. -I../renderer -I../gui -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = libcoreclient.a
|
||||
|
||||
libcoreclient_a_SOURCES = cligos.C cliobject.C \
|
||||
clisrvmanager.C clisrvmessage.C clisrvprotocol.C \
|
||||
cliworld.C cliworldmanager.C cliworldmessage.C cliworldprotocol.C \
|
||||
clientcache.C
|
334
client/coreclient/Makefile.in
Normal file
334
client/coreclient/Makefile.in
Normal file
@@ -0,0 +1,334 @@
|
||||
# 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.. -I../renderer -I../gui -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = libcoreclient.a
|
||||
|
||||
libcoreclient_a_SOURCES = cligos.C cliobject.C clisrvmanager.C clisrvmessage.C clisrvprotocol.C cliworld.C cliworldmanager.C cliworldmessage.C cliworldprotocol.C clientcache.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@
|
||||
libcoreclient_a_LIBADD =
|
||||
libcoreclient_a_OBJECTS = cligos.o cliobject.o clisrvmanager.o \
|
||||
clisrvmessage.o clisrvprotocol.o cliworld.o cliworldmanager.o \
|
||||
cliworldmessage.o cliworldprotocol.o clientcache.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/clientcache.P .deps/cligos.P .deps/cliobject.P \
|
||||
.deps/clisrvmanager.P .deps/clisrvmessage.P .deps/clisrvprotocol.P \
|
||||
.deps/cliworld.P .deps/cliworldmanager.P .deps/cliworldmessage.P \
|
||||
.deps/cliworldprotocol.P
|
||||
SOURCES = $(libcoreclient_a_SOURCES)
|
||||
OBJECTS = $(libcoreclient_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 client/coreclient/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:
|
||||
|
||||
libcoreclient.a: $(libcoreclient_a_OBJECTS) $(libcoreclient_a_DEPENDENCIES)
|
||||
-rm -f libcoreclient.a
|
||||
$(AR) cru libcoreclient.a $(libcoreclient_a_OBJECTS) $(libcoreclient_a_LIBADD)
|
||||
$(RANLIB) libcoreclient.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 = client/coreclient
|
||||
|
||||
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 client/coreclient/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:
|
109
client/coreclient/clientcache.C
Normal file
109
client/coreclient/clientcache.C
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include "clientcache.H"
|
||||
#include "clisrvmanager.H"
|
||||
#include "msggos.H"
|
||||
|
||||
CCliGeometryCache::CCliGeometryCache(CCliSrvManager * manager){
|
||||
m_manager = manager;
|
||||
}
|
||||
|
||||
CObject * CCliGeometryCache::failFunc(int id){
|
||||
char fileName[MAXPATHLEN];
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
// Load from local cache if file exist
|
||||
sprintf(fileName,"goscache/%i.bog",id);
|
||||
FILE * file = fopen(fileName,"r");
|
||||
if (file != NULL){
|
||||
CGeometry * geo = m_manager->newGeometry(id);
|
||||
geo->readBOG(file);
|
||||
fclose(file);
|
||||
return geo;
|
||||
} else {
|
||||
m_manager->request(GOSREQUEST_GEOMETRY,id);
|
||||
CCache::add(id,NULL);
|
||||
}
|
||||
#else
|
||||
m_manager->request(GOSREQUEST_GEOMETRY,id);
|
||||
CCache::add(id,NULL);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCliMaterialCache::CCliMaterialCache(CCliSrvManager * manager){
|
||||
m_manager = manager;
|
||||
}
|
||||
|
||||
CObject * CCliMaterialCache::failFunc(int id){
|
||||
char fileName[MAXPATHLEN];
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
// Load from local cache if file exist
|
||||
sprintf(fileName,"goscache/%i.bmat",id);
|
||||
FILE * file = fopen(fileName,"r");
|
||||
if (file != NULL){
|
||||
CMaterial * mat = m_manager->newMaterial(id);
|
||||
mat->load(fileName);
|
||||
fclose(file);
|
||||
return mat;
|
||||
} else {
|
||||
m_manager->request(GOSREQUEST_MATERIAL,id);
|
||||
CCache::add(id,NULL);
|
||||
}
|
||||
#else
|
||||
m_manager->request(GOSREQUEST_MATERIAL,id);
|
||||
CCache::add(id,NULL);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCliTextureCache::CCliTextureCache(CCliSrvManager * manager){
|
||||
m_manager = manager;
|
||||
}
|
||||
|
||||
CObject * CCliTextureCache::failFunc(int id){
|
||||
char fileName[MAXPATHLEN];
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
// Load from local cache if file exist
|
||||
sprintf(fileName,"goscache/%i.tex",id);
|
||||
FILE * file = fopen(fileName,"r");
|
||||
if (file != NULL){
|
||||
CTexture * tex = m_manager->newTexture(id);
|
||||
tex->load(fileName);
|
||||
fclose(file);
|
||||
return tex;
|
||||
} else {
|
||||
m_manager->request(GOSREQUEST_TEXTURE,id);
|
||||
CCache::add(id,NULL);
|
||||
}
|
||||
#else
|
||||
m_manager->request(GOSREQUEST_TEXTURE,id);
|
||||
CCache::add(id,NULL);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
50
client/coreclient/clientcache.H
Normal file
50
client/coreclient/clientcache.H
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 _CLIENTCACHE_H
|
||||
#define _CLIENTCACHE_H
|
||||
|
||||
#include "geometry.H"
|
||||
#include "material.H"
|
||||
#include "texture.H"
|
||||
|
||||
class CCliSrvManager;
|
||||
|
||||
class CCliGeometryCache: public CGeometryCache {
|
||||
CCliSrvManager * m_manager;
|
||||
public:
|
||||
CCliGeometryCache(CCliSrvManager * manager);
|
||||
virtual CObject * failFunc(int id);
|
||||
};
|
||||
|
||||
class CCliMaterialCache: public CMaterialCache {
|
||||
CCliSrvManager * m_manager;
|
||||
public:
|
||||
CCliMaterialCache(CCliSrvManager * manager);
|
||||
virtual CObject * failFunc(int id);
|
||||
};
|
||||
|
||||
class CCliTextureCache: public CTextureCache {
|
||||
CCliSrvManager * m_manager;
|
||||
public:
|
||||
CCliTextureCache(CCliSrvManager * manager);
|
||||
virtual CObject * failFunc(int id);
|
||||
};
|
||||
|
||||
#endif // _CLIENTCACHE_H
|
67
client/coreclient/cligos.C
Normal file
67
client/coreclient/cligos.C
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 "cligos.H"
|
||||
#include "clisrvmanager.H"
|
||||
#include "glgeometry.H"
|
||||
#include "glmaterial.H"
|
||||
#include "gltexture.H"
|
||||
|
||||
CCliGOS::CCliGOS(CCliSrvManager * manager,CTimeKeeper * timeKeeper,CInetAddress *GOSAddress):CGOS(timeKeeper,GOSAddress){
|
||||
this->manager = manager;
|
||||
}
|
||||
|
||||
void CCliGOS::error(){
|
||||
}
|
||||
|
||||
void CCliGOS::geometry(CGeometry * geometry){
|
||||
manager->addGeometry(geometry);
|
||||
}
|
||||
|
||||
void CCliGOS::material(CMaterial * material){
|
||||
manager->addMaterial(material);
|
||||
}
|
||||
|
||||
void CCliGOS::texture(CTexture * texture){
|
||||
manager->addTexture(texture);
|
||||
}
|
||||
|
||||
CGeometry * CCliGOS::newGeometry(int geometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons){
|
||||
CGeometry * geo = manager->newGeometry(geometryId);
|
||||
geo->setSize(numVertices,numNormals,
|
||||
numTexCoords,numPolygons);
|
||||
return geo;
|
||||
|
||||
// return new CGLGeometry(geometryId,numVertices,numNormals,
|
||||
// numTexCoords,numPolygons);
|
||||
}
|
||||
|
||||
CMaterial * CCliGOS::newMaterial(int materialId){
|
||||
return manager->newMaterial(materialId);
|
||||
// return new CGLMaterial(materialId);
|
||||
}
|
||||
|
||||
CTexture * CCliGOS::newTexture(int textureId){
|
||||
return manager->newTexture(textureId);
|
||||
// return new CGLTexture(textureId);
|
||||
}
|
||||
|
45
client/coreclient/cligos.H
Normal file
45
client/coreclient/cligos.H
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLIGOS_H
|
||||
#define _CLIGOS_H
|
||||
|
||||
#include "gos.H"
|
||||
|
||||
class CCliSrvManager;
|
||||
|
||||
class CCliGOS : public CGOS {
|
||||
CCliSrvManager * manager;
|
||||
|
||||
public:
|
||||
CCliGOS(CCliSrvManager * manager,CTimeKeeper * timeKeeper,CInetAddress *GOSAddress);
|
||||
|
||||
virtual void error();
|
||||
virtual void geometry(CGeometry * geometry);
|
||||
virtual void material(CMaterial * material);
|
||||
virtual void texture(CTexture * texture);
|
||||
|
||||
virtual CGeometry * newGeometry(int geometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons);
|
||||
virtual CMaterial * newMaterial(int materialId);
|
||||
virtual CTexture * newTexture(int textureId);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLIGOS_H
|
69
client/coreclient/cliobject.C
Normal file
69
client/coreclient/cliobject.C
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "cliobject.H"
|
||||
#include "geometry.H"
|
||||
#include "material.H"
|
||||
#include "texture.H"
|
||||
#include "renderer.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CCliObject::CCliObject(DWORD objectId, CWorldWorld * world, DWORD geometryId,const CPosition & position, const CDirection & direction )
|
||||
:CWorldObject(objectId,world,geometryId,position,direction){
|
||||
|
||||
}
|
||||
|
||||
CCliObject::CCliObject(DWORD objectId, CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction )
|
||||
:CWorldObject(objectId,parent,geometryId,position,direction){
|
||||
|
||||
}
|
||||
|
||||
CListener * CCliObject::getListener(){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void CCliObject::draw(CRenderer * renderer){
|
||||
CGeometryCache * objGeoCache = renderer->getClient()->getGeometryCache();
|
||||
CTextureCache * materialCache = renderer->getClient()->getTextureCache();
|
||||
CMaterialCache * textureCache = renderer->getClient()->getMaterialCache();
|
||||
|
||||
CGeometry * objGeo = objGeoCache->get( getGeometryId() );
|
||||
|
||||
renderer->prepareDraw(this);
|
||||
|
||||
renderer->transform(getPosition(), getDirection());
|
||||
|
||||
if (objGeo != NULL) objGeo->draw( textureCache, materialCache);
|
||||
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CCliObject * object = (CCliObject*)item->getObject();
|
||||
item = item->getNext();
|
||||
object->draw( renderer );
|
||||
}
|
||||
|
||||
renderer->postDraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
38
client/coreclient/cliobject.H
Normal file
38
client/coreclient/cliobject.H
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLIOBJECT_H
|
||||
#define _CLIOBJECT_H
|
||||
|
||||
#include "worldobject.H"
|
||||
#include "renderer.H"
|
||||
|
||||
class CCliObject : public CWorldObject {
|
||||
|
||||
public:
|
||||
CCliObject(DWORD objectId, CWorldWorld * world, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
CCliObject(DWORD objectId, CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
|
||||
virtual CListener * getListener();
|
||||
|
||||
void draw(CRenderer * renderer);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLIOBJECT_H
|
302
client/coreclient/clisrvmanager.C
Normal file
302
client/coreclient/clisrvmanager.C
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* 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 "client.H"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <iostream.h>
|
||||
#include <netinet/in.h>
|
||||
#include "socket.H"
|
||||
#include "clisrvmanager.H"
|
||||
#include "msgsrvcli.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
#include "glgeometry.H"
|
||||
#include "glmaterial.H"
|
||||
#include "gltexture.H"
|
||||
|
||||
CCliSrvManager::CCliSrvManager(CCliSrvProtocol * protocol,CTimeKeeper * timeKeeper):CManager(protocol){
|
||||
m_timeKeeper = timeKeeper;
|
||||
getProtocol()->setName("Server");
|
||||
getProtocol()->setManager(this);
|
||||
m_world = new CCliWorld();
|
||||
m_viewpoint = new CCliViewpoint(m_world);
|
||||
m_cligos = NULL;
|
||||
m_worldsrv = NULL;
|
||||
|
||||
}
|
||||
|
||||
CCliSrvManager::~CCliSrvManager(){
|
||||
if (m_world != NULL) delete m_world;
|
||||
if (m_viewpoint != NULL) delete m_viewpoint;
|
||||
#ifndef TEXTURECACHE_USEFILE
|
||||
if (m_cligos != NULL) delete m_cligos;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CCliSrvManager::setClient(CPvvmudClient * client) {
|
||||
m_client = client;
|
||||
}
|
||||
|
||||
CPvvmudClient * CCliSrvManager::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
COption * CCliSrvManager::getOption() {
|
||||
return m_client->getOption();
|
||||
}
|
||||
|
||||
void CCliSrvManager::communicate(){
|
||||
getProtocol()->readyToRead();
|
||||
getProtocol()->readyToWrite();
|
||||
}
|
||||
|
||||
void CCliSrvManager::init(){
|
||||
cdebug << "Client manager init\n";
|
||||
// createStartFrame();
|
||||
}
|
||||
|
||||
void CCliSrvManager::hello(){
|
||||
getProtocol()->login(getOption()->getString("username"),
|
||||
getOption()->getString("passwd"),
|
||||
FALSE); // This is not a new user!
|
||||
}
|
||||
|
||||
void CCliSrvManager::serverInfo(CInetAddress * worldSrvAddress,CInetAddress * gosAddress){
|
||||
|
||||
#ifndef TEXTURECACHE_USEFILE
|
||||
try {
|
||||
|
||||
m_cligos = new CCliGOS(this,m_timeKeeper, gosAddress);
|
||||
cdebug << "Client GOS manager connected.\n";
|
||||
|
||||
} catch (CSocketException * e){
|
||||
|
||||
cdebug << "Failed to connect to GOS\n";
|
||||
m_cligos = NULL;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
try {
|
||||
|
||||
CClientSocket * socket =
|
||||
new CClientSocket(worldSrvAddress->getAddress(),worldSrvAddress->getPort());
|
||||
|
||||
socket->setNonBlocking();
|
||||
cdebug << "Client World manager connected.\n";
|
||||
|
||||
m_worldsrv =
|
||||
new CCliWorldManager(this, new CCliWorldProtocol(socket,m_timeKeeper));
|
||||
|
||||
} catch (CSocketException * e){
|
||||
|
||||
cdebug << "Failed to connect to world server\n";
|
||||
m_worldsrv = NULL;
|
||||
|
||||
}
|
||||
|
||||
if (m_cligos != NULL && m_worldsrv != NULL){
|
||||
// getProtocol()->sendGetWorld();
|
||||
// deleteStartFrame();
|
||||
|
||||
getProtocol()->sendOnline();
|
||||
|
||||
} else {
|
||||
quit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CCliSrvManager::quit(){
|
||||
getProtocol()->bye();
|
||||
}
|
||||
|
||||
void CCliSrvManager::exit(){
|
||||
::exit(0);
|
||||
}
|
||||
|
||||
void CCliSrvManager::changeMasterCellId(DWORD newMasterCellId){
|
||||
m_worldsrv->getProtocol()->sendChangeMasterCell(newMasterCellId);
|
||||
}
|
||||
|
||||
void CCliSrvManager::createStartFrame(){
|
||||
double trans[3];
|
||||
trans[0] = 0; trans[1] = 80; trans[2] = 0;
|
||||
double rot[3];
|
||||
rot[0] = 90; rot[1] = 0; rot[2] = 0;
|
||||
// world->addObject(-1,0,0,trans,rot);
|
||||
}
|
||||
|
||||
void CCliSrvManager::deleteStartFrame(){
|
||||
clearWorld();
|
||||
}
|
||||
|
||||
void CCliSrvManager::animate(){
|
||||
m_world->animate();
|
||||
}
|
||||
|
||||
void CCliSrvManager::draw(CRenderer * renderer){
|
||||
m_world->draw(renderer);
|
||||
}
|
||||
|
||||
void CCliSrvManager::updateViewpoint( const CPosition & position,
|
||||
const CDirection & direction,DWORD targetId ){
|
||||
m_viewpoint->setPosition( position );
|
||||
m_viewpoint->setDirection( direction );
|
||||
m_viewpoint->setTargetId( targetId );
|
||||
cdebug << "Viewpoint: Target: " << targetId << " Pos: " << position
|
||||
<< " Dir: " << direction << "\n";
|
||||
}
|
||||
|
||||
void CCliSrvManager::playerMove( int move ){
|
||||
getProtocol()->sendCommand( move);
|
||||
}
|
||||
|
||||
void CCliSrvManager::playerLook( int look ){
|
||||
getProtocol()->sendCommand( look);
|
||||
}
|
||||
|
||||
void CCliSrvManager::userCommand(int num){
|
||||
if ((num >= USERCOMMAND_1) && (num <= USERCOMMAND_5)){
|
||||
doAction(num - USERCOMMAND_1);
|
||||
} else {
|
||||
getProtocol()->sendCommand( num);
|
||||
}
|
||||
}
|
||||
|
||||
void CCliSrvManager::selection(int objectId){
|
||||
getProtocol()->sendSelection( objectId );
|
||||
}
|
||||
|
||||
void CCliSrvManager::sendMsg( const char * msg ){
|
||||
getProtocol()->sendMsg( msg );
|
||||
}
|
||||
|
||||
void CCliSrvManager::sendPing(){
|
||||
if (m_worldsrv != NULL) m_worldsrv->sendPing();
|
||||
}
|
||||
|
||||
void CCliSrvManager::clearWorld(){
|
||||
m_world->clearWorld();
|
||||
}
|
||||
|
||||
void CCliSrvManager::doAction(int actionNum){
|
||||
cdebug << "Do action " << actionNum+1 << " on object "
|
||||
<< actionObjectId[actionNum] << "\n";
|
||||
getProtocol()->sendAction(actionObjectId[actionNum],actionNum+1);
|
||||
}
|
||||
|
||||
void CCliSrvManager::addAction(int objectId, CAction * action){
|
||||
actionObjectId[action->getId()-1] = objectId;
|
||||
}
|
||||
|
||||
int CCliSrvManager::request(int requestType,int requestId){
|
||||
cdebug << "Request("<<requestType<<") for : " << requestId << "\n";
|
||||
if (m_cligos != NULL) {
|
||||
m_cligos->request(requestType,requestId);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CCliSrvManager::addGeometry(CGeometry * geometry){
|
||||
|
||||
CGeometry * geo = getClient()->getGeometryCache()->add(geometry);
|
||||
if (geo != NULL) delete geo;
|
||||
|
||||
cdebug << "Geometry " << geometry->getId() << " loaded\n";
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
DIR * dir = opendir("goscache");
|
||||
if (dir != NULL){
|
||||
closedir(dir);
|
||||
} else {
|
||||
mkdir("goscache",S_IRWXU);
|
||||
}
|
||||
char fileName[256];
|
||||
sprintf(fileName,"goscache/%i.bog",geometry->getId());
|
||||
geometry->save(fileName);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
}
|
||||
|
||||
void CCliSrvManager::addMaterial(CMaterial * material){
|
||||
|
||||
CMaterial * mat = getClient()->getMaterialCache()->add(material);
|
||||
if (mat != NULL) delete mat;
|
||||
|
||||
cdebug << "Material " << material->getId() << " loaded\n";
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
DIR * dir = opendir("goscache");
|
||||
if (dir != NULL){
|
||||
closedir(dir);
|
||||
} else {
|
||||
mkdir("goscache",S_IRWXU);
|
||||
}
|
||||
char fileName[256];
|
||||
sprintf(fileName,"goscache/%i.bmat",material->getId());
|
||||
material->save(fileName);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
}
|
||||
|
||||
void CCliSrvManager::addTexture(CTexture * texture){
|
||||
|
||||
CTexture * tex = getClient()->getTextureCache()->add(texture);
|
||||
if (tex != NULL) delete tex;
|
||||
|
||||
cdebug << "Texture " << texture->getId() << " loaded\n";
|
||||
|
||||
#ifdef USE_LOCAL_FILE_CACHE
|
||||
DIR * dir = opendir("goscache");
|
||||
if (dir != NULL){
|
||||
closedir(dir);
|
||||
} else {
|
||||
mkdir("goscache",S_IRWXU);
|
||||
}
|
||||
char fileName[256];
|
||||
sprintf(fileName,"goscache/%i.tex",texture->getId());
|
||||
texture->save(fileName);
|
||||
#endif // USE_LOCAL_FILE_CACHE
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCliSrvManager::dump(){
|
||||
m_world->dump();
|
||||
}
|
||||
|
||||
CGeometry * CCliSrvManager::newGeometry(int geometryId){
|
||||
return new CGLGeometry(geometryId);
|
||||
}
|
||||
|
||||
CMaterial * CCliSrvManager::newMaterial(int materialId){
|
||||
return new CGLMaterial(materialId);
|
||||
}
|
||||
|
||||
CTexture * CCliSrvManager::newTexture(int textureId){
|
||||
return new CGLTexture(textureId);
|
||||
}
|
||||
|
101
client/coreclient/clisrvmanager.H
Normal file
101
client/coreclient/clisrvmanager.H
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
|
||||
*
|
||||
*/
|
||||
#ifndef _CLISRVMANAGER_H
|
||||
#define _CLISRVMANAGER_H
|
||||
|
||||
#include "clisrvprotocol.H"
|
||||
#include "cliworld.H"
|
||||
#include "cliviewpoint.H"
|
||||
#include "action.H"
|
||||
#include "manager.H"
|
||||
#include "cligos.H"
|
||||
#include "cliworldmanager.H"
|
||||
#include "option.H"
|
||||
|
||||
|
||||
class CPvvmudClient;
|
||||
class CCliSrvManager: public CManager {
|
||||
CCliWorld * m_world;
|
||||
CCliViewpoint * m_viewpoint;
|
||||
CCliGOS * m_cligos;
|
||||
CCliWorldManager * m_worldsrv;
|
||||
CPvvmudClient * m_client;
|
||||
|
||||
// Action list
|
||||
int actionObjectId[5];
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
|
||||
public:
|
||||
CCliSrvManager(CCliSrvProtocol * protocol,CTimeKeeper * timeKeeper);
|
||||
virtual ~CCliSrvManager();
|
||||
|
||||
CCliSrvProtocol * getProtocol(){ return (CCliSrvProtocol*)CManager::getCommunicate();}
|
||||
CCliWorld* getWorld(){ return m_world; }
|
||||
|
||||
void setClient(CPvvmudClient * client);
|
||||
CPvvmudClient * getClient();
|
||||
COption * getOption();
|
||||
|
||||
void communicate();
|
||||
|
||||
void init();
|
||||
void hello();
|
||||
void serverInfo(CInetAddress * worldSrvAddress,CInetAddress * gosAddress);
|
||||
void quit();
|
||||
void exit();
|
||||
void changeMasterCellId(DWORD newMasterCellId);
|
||||
|
||||
void createStartFrame();
|
||||
void deleteStartFrame();
|
||||
|
||||
void animate();
|
||||
void draw(CRenderer * renderer);
|
||||
|
||||
void updateViewpoint( const CPosition & position,
|
||||
const CDirection & direction,
|
||||
DWORD targetId);
|
||||
|
||||
void playerMove( int move );
|
||||
void playerLook( int look );
|
||||
void userCommand(int num);
|
||||
void selection( int objectId );
|
||||
void sendMsg( const char * msg );
|
||||
void sendPing();
|
||||
|
||||
void clearWorld();
|
||||
void doAction(int actionNum);
|
||||
void addAction(int objectId,CAction * action);
|
||||
|
||||
CCliViewpoint * getViewpoint(){ return m_viewpoint; }
|
||||
int request(int requestType,int requestId);
|
||||
void addGeometry(CGeometry * geometry);
|
||||
void addMaterial(CMaterial * material);
|
||||
void addTexture(CTexture * texture);
|
||||
|
||||
void dump();
|
||||
|
||||
virtual CGeometry * newGeometry(int geometryId);
|
||||
virtual CMaterial * newMaterial(int materialId);
|
||||
virtual CTexture * newTexture(int textureId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _CLISRVMANAGER_H
|
309
client/coreclient/clisrvmessage.C
Normal file
309
client/coreclient/clisrvmessage.C
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
* 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 <stdlib.h>
|
||||
#include "client.H"
|
||||
#include "clisrvmessage.H"
|
||||
#include "clisrvmanager.H"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgHelloCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgHelloCli::CMsgHelloCli():CMsgHello(){
|
||||
}
|
||||
|
||||
CMsgHelloCli * CMsgHelloCli::createMsg(){
|
||||
return new CMsgHelloCli();
|
||||
}
|
||||
|
||||
int CMsgHelloCli::executeMsg(){
|
||||
cdebug << "Hello from server!\n";
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
if (getVersion() != PROTOCOL_VERSION){
|
||||
cdebug << "ERROR: Wrong protocol version!\n";
|
||||
exit(2);
|
||||
}
|
||||
manager->hello();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgServerInfoCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgServerInfoCli::CMsgServerInfoCli():CMsgServerInfo(){
|
||||
}
|
||||
|
||||
CMsgServerInfoCli * CMsgServerInfoCli::createMsg(){
|
||||
return new CMsgServerInfoCli();
|
||||
}
|
||||
|
||||
int CMsgServerInfoCli::executeMsg(){
|
||||
CInetAddress * worldSrvAddress, * gosAddress;
|
||||
worldSrvAddress = getWorldSrvAddress();
|
||||
gosAddress = getGOSAddress();
|
||||
cdebug << "Server info: WorldSrv" << worldSrvAddress->getAddressString() << "GOS" << worldSrvAddress->getAddressString() << " world " << gosAddress->getAddressString() << "\n";
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
manager->serverInfo(worldSrvAddress,gosAddress);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgByeCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgByeCli::CMsgByeCli():CMsgBye(){
|
||||
}
|
||||
|
||||
CMsgByeCli * CMsgByeCli::createMsg(){
|
||||
return new CMsgByeCli();
|
||||
}
|
||||
|
||||
int CMsgByeCli::executeMsg(){
|
||||
cout << "Bye from server: " << getReasonString(getReason()) << "\n";
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
manager->exit();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgGeometryObjectCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgGeometryObjectCli::CMsgGeometryObjectCli():CMsgGeometryObject(){
|
||||
}
|
||||
|
||||
CMsgGeometryObjectCli * CMsgGeometryObjectCli::createMsg(){
|
||||
return new CMsgGeometryObjectCli();
|
||||
}
|
||||
|
||||
int CMsgGeometryObjectCli::executeMsg(){
|
||||
double pos[3],dir[3];
|
||||
cdebug << "New geometryobject(" << getWorldObjectId() << ") from server with geometry(" << getGeometryId() << ") and parent(" << getParentId() << ")!\n",
|
||||
getPosition(pos);
|
||||
getDirection(dir);
|
||||
cdebug ("Pos: %f %f %f Dir: %f %f %f\n",pos[0],pos[1],pos[2],dir[0],dir[1],dir[2]);
|
||||
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
manager->addWorldObject(getParentId(),getWorldObjectId(),
|
||||
getGeometryId(),pos,dir);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgGeoObjRemoveCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgGeoObjRemoveCli::CMsgGeoObjRemoveCli():CMsgGeoObjRemove(){
|
||||
}
|
||||
|
||||
CMsgGeoObjRemoveCli * CMsgGeoObjRemoveCli::createMsg(){
|
||||
return new CMsgGeoObjRemoveCli();
|
||||
}
|
||||
|
||||
int CMsgGeoObjRemoveCli::executeMsg(){
|
||||
cdebug("Remove geometryobject(%i) from parent(%i)\n",getWorldObjectId(),
|
||||
getParentId());
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
manager->removeWorldObject(getWorldObjectId(),getParentId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgUpdatePosition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgUpdatePositionCli::CMsgUpdatePositionCli():CMsgUpdatePosition(){
|
||||
}
|
||||
|
||||
CMsgUpdatePositionCli * CMsgUpdatePositionCli::createMsg(){
|
||||
return new CMsgUpdatePositionCli();
|
||||
}
|
||||
|
||||
int CMsgUpdatePositionCli::executeMsg(){
|
||||
double pos[3];
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
getPosition(pos);
|
||||
manager->updatePosition(getWorldObjectId(),pos);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgUpdateDirection
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgUpdateDirectionCli::CMsgUpdateDirectionCli():CMsgUpdateDirection(){
|
||||
}
|
||||
|
||||
CMsgUpdateDirectionCli * CMsgUpdateDirectionCli::createMsg(){
|
||||
return new CMsgUpdateDirectionCli();
|
||||
}
|
||||
|
||||
int CMsgUpdateDirectionCli::executeMsg(){
|
||||
double dir[3];
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
getDirection(dir);
|
||||
manager->updateDirection(getWorldObjectId(),dir);
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCommand
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCommandCli::CMsgCommandCli():CMsgCommand(){
|
||||
}
|
||||
|
||||
CMsgCommandCli * CMsgCommandCli::createMsg(){
|
||||
return new CMsgCommandCli();
|
||||
}
|
||||
|
||||
int CMsgCommandCli::executeMsg(){
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
switch(getCommand()){
|
||||
case MSGCOMMAND_CLIENTCLEARWORLD:
|
||||
cdebug << "MsgCommand: Clear world\n";
|
||||
manager->clearWorld();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgViewpointCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgViewpointCli::CMsgViewpointCli():CMsgViewpoint(){
|
||||
}
|
||||
|
||||
CMsgViewpointCli * CMsgViewpointCli::createMsg(){
|
||||
return new CMsgViewpointCli();
|
||||
}
|
||||
|
||||
int CMsgViewpointCli::executeMsg(){
|
||||
CPosition pos; CDirection dir;
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
getPosition(pos); getDirection(dir);
|
||||
manager->updateViewpoint(pos,dir,getTargetId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgMsgCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgMsgCli::CMsgMsgCli():CMsgMsg(){
|
||||
}
|
||||
|
||||
CMsgMsgCli * CMsgMsgCli::createMsg(){
|
||||
return new CMsgMsgCli();
|
||||
}
|
||||
|
||||
int CMsgMsgCli::executeMsg(){
|
||||
char * msg = (char*)malloc(getMsgLength());
|
||||
getMsg(msg);
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
manager->getClient()->getConsole()->addMsg(msg);
|
||||
cdebug << "MSG: " << msg << "\n";
|
||||
free(msg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgActionListCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgActionListCli::CMsgActionListCli():CMsgActionList(){
|
||||
}
|
||||
|
||||
CMsgActionListCli * CMsgActionListCli::createMsg(){
|
||||
return new CMsgActionListCli();
|
||||
}
|
||||
|
||||
int CMsgActionListCli::executeMsg(){
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
cdebug << "Action list for object: " << getObjectId() << "\n";
|
||||
CObjectListItem * item = getActionList()->getFirst();
|
||||
while (item != NULL){
|
||||
CAction * action = (CAction*)item->getObject();
|
||||
cdebug << "Action: " << action->getId() << " " << action->getName() << "\n";
|
||||
manager->addAction(getObjectId(),action);
|
||||
item = item->getNext();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgPlayerInfoCli
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgPlayerInfoCli::CMsgPlayerInfoCli():CMsgPlayerInfo(){
|
||||
}
|
||||
|
||||
CMsgPlayerInfoCli * CMsgPlayerInfoCli::createMsg(){
|
||||
return new CMsgPlayerInfoCli();
|
||||
}
|
||||
|
||||
int CMsgPlayerInfoCli::executeMsg(){
|
||||
CCliSrvManager * manager = (CCliSrvManager*)getManager();
|
||||
cdebug << "Player info with mastercell : " << getMasterCellId() << "\n",
|
||||
manager->changeMasterCellId(getMasterCellId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
115
client/coreclient/clisrvmessage.H
Normal file
115
client/coreclient/clisrvmessage.H
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 _CLISRVMESSAGE_H
|
||||
#define _CLISRVMESSAGE_H
|
||||
|
||||
#include "msgsrvcli.H"
|
||||
#include "msgworld.H"
|
||||
#include "msgmsg.H"
|
||||
#include "msgactionlist.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
class CMsgHelloCli: public CMsgHello {
|
||||
public:
|
||||
CMsgHelloCli();
|
||||
static CMsgHelloCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgServerInfoCli: public CMsgServerInfo {
|
||||
public:
|
||||
CMsgServerInfoCli();
|
||||
static CMsgServerInfoCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgByeCli: public CMsgBye {
|
||||
public:
|
||||
CMsgByeCli();
|
||||
static CMsgByeCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
//class CMsgGeometryObjectCli: public CMsgGeometryObject {
|
||||
//public:
|
||||
// CMsgGeometryObjectCli();
|
||||
// static CMsgGeometryObjectCli * createMsg();
|
||||
// virtual int executeMsg();
|
||||
//};
|
||||
|
||||
//class CMsgGeoObjRemoveCli: public CMsgGeoObjRemove {
|
||||
//public:
|
||||
// CMsgGeoObjRemoveCli();
|
||||
// static CMsgGeoObjRemoveCli * createMsg();
|
||||
// virtual int executeMsg();
|
||||
//};
|
||||
|
||||
//class CMsgUpdatePositionCli: public CMsgUpdatePosition {
|
||||
//public:
|
||||
// CMsgUpdatePositionCli();
|
||||
// static CMsgUpdatePositionCli * createMsg();
|
||||
// virtual int executeMsg();
|
||||
//};
|
||||
|
||||
//class CMsgUpdateDirectionCli: public CMsgUpdateDirection {
|
||||
//public:
|
||||
// CMsgUpdateDirectionCli();
|
||||
// static CMsgUpdateDirectionCli * createMsg();
|
||||
// virtual int executeMsg();
|
||||
//};
|
||||
|
||||
class CMsgCommandCli: public CMsgCommand {
|
||||
public:
|
||||
CMsgCommandCli();
|
||||
static CMsgCommandCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgViewpointCli: public CMsgViewpoint {
|
||||
public:
|
||||
CMsgViewpointCli();
|
||||
static CMsgViewpointCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgMsgCli: public CMsgMsg {
|
||||
public:
|
||||
CMsgMsgCli();
|
||||
static CMsgMsgCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgActionListCli: public CMsgActionList {
|
||||
public:
|
||||
CMsgActionListCli();
|
||||
static CMsgActionListCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgPlayerInfoCli: public CMsgPlayerInfo {
|
||||
public:
|
||||
CMsgPlayerInfoCli();
|
||||
static CMsgPlayerInfoCli * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
|
||||
#endif // _CLISRVMESSAGE_H
|
||||
|
75
client/coreclient/clisrvprotocol.C
Normal file
75
client/coreclient/clisrvprotocol.C
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 "clisrvprotocol.H"
|
||||
#include "clisrvmessage.H"
|
||||
|
||||
CCliSrvProtocol::CCliSrvProtocol(CSocket * socket,CTimeKeeper * timeKeeper)
|
||||
:CCommunicate(socket,timeKeeper){
|
||||
addMsg((MsgCreateFunc_t)CMsgHelloCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgByeCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCommandCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgViewpointCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgMsgCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgActionListCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgServerInfoCli::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgPlayerInfoCli::createMsg);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::login(char * name, char * passwd,BOOL newUser){
|
||||
CMsgLogin * msg = new CMsgLogin(name,passwd,newUser);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::bye(){
|
||||
CMsgBye * msg = new CMsgBye();
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendOnline(){
|
||||
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_ONLINE);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendGetWorld(){
|
||||
CMsgGetWorld * msg = new CMsgGetWorld();
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendCommand(int command){
|
||||
CMsgCommand * msg = new CMsgCommand(command);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendSelection(int objectId){
|
||||
CMsgSelection * msg = new CMsgSelection(objectId);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendAction(int objectId,int actionId){
|
||||
CMsgAction * msg = new CMsgAction(objectId,actionId);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
||||
void CCliSrvProtocol::sendMsg(const char *msg){
|
||||
CMsgMsg * msgmsg = new CMsgMsg(msg);
|
||||
sendMessage(msgmsg,TRUE);
|
||||
}
|
||||
|
41
client/coreclient/clisrvprotocol.H
Normal file
41
client/coreclient/clisrvprotocol.H
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLISRVPROTOCOL_H
|
||||
#define _CLISRVPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
#include "socket.H"
|
||||
|
||||
class CCliSrvProtocol : public CCommunicate {
|
||||
|
||||
public:
|
||||
CCliSrvProtocol(CSocket * socket,CTimeKeeper * timeKeeper);
|
||||
|
||||
void login(char * name, char * passwd, BOOL newUser);
|
||||
void bye();
|
||||
void sendOnline();
|
||||
void sendGetWorld();
|
||||
void sendCommand(int command);
|
||||
void sendSelection(int objectId);
|
||||
void sendAction(int objectId,int actionId);
|
||||
void sendMsg(const char * msg);
|
||||
};
|
||||
|
||||
#endif // _CLISRVPROTOCOL_H
|
52
client/coreclient/cliworld.C
Normal file
52
client/coreclient/cliworld.C
Normal 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 "cliworld.H"
|
||||
|
||||
CCliWorld::CCliWorld(){
|
||||
|
||||
}
|
||||
|
||||
CListener * CCliWorld::getListener(){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCliObject * CCliWorld::newObject(char * name, DWORD objectId,
|
||||
CWorldObject * parent, DWORD geometryId,
|
||||
const CPosition & position, const CDirection & direction )
|
||||
{
|
||||
|
||||
if (parent == NULL){
|
||||
return new CCliObject(objectId,this,geometryId,position,direction);
|
||||
}
|
||||
|
||||
return new CCliObject(objectId,parent,geometryId,position,direction);
|
||||
|
||||
}
|
||||
|
||||
void CCliWorld::draw(CRenderer * renderer){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CCliObject * cell = (CCliObject*)item->getObject();
|
||||
item = item->getNext();
|
||||
cell->draw( renderer );
|
||||
}
|
||||
}
|
||||
|
39
client/coreclient/cliworld.H
Normal file
39
client/coreclient/cliworld.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 _CLIWORLD_H
|
||||
#define _CLIWORLD_H
|
||||
|
||||
#include "worldworld.H"
|
||||
#include "cliobject.H"
|
||||
#include "renderer.H"
|
||||
|
||||
class CCliWorld : public CWorldWorld {
|
||||
|
||||
public:
|
||||
CCliWorld();
|
||||
|
||||
virtual CCliObject * newObject(char * name,DWORD objectId, CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction );
|
||||
|
||||
virtual CListener * getListener();
|
||||
|
||||
void draw(CRenderer * renderer);
|
||||
};
|
||||
|
||||
#endif // _CLIWORLD_H
|
92
client/coreclient/cliworldmanager.C
Normal file
92
client/coreclient/cliworldmanager.C
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 "client.H"
|
||||
#include <iostream.h>
|
||||
#include "cliworldmanager.H"
|
||||
#include "clisrvmanager.H"
|
||||
#include "msgsrvcli.H"
|
||||
|
||||
CCliWorldManager::CCliWorldManager(CCliSrvManager * client, CCliWorldProtocol * protocol):CManager(protocol){
|
||||
m_client = client;
|
||||
getProtocol()->setName("World");
|
||||
|
||||
m_pingPong = new CPingPong(MAXPINGPONG);
|
||||
m_pingCounter = 0;
|
||||
m_pingCounterMax = 0;
|
||||
|
||||
}
|
||||
|
||||
CCliWorldManager::~CCliWorldManager(){
|
||||
delete m_pingPong;
|
||||
}
|
||||
|
||||
CCliWorldProtocol * CCliWorldManager::getProtocol(){
|
||||
return (CCliWorldProtocol*)CManager::getCommunicate();
|
||||
}
|
||||
|
||||
CCliWorld * CCliWorldManager::getWorld(){
|
||||
return m_client->getWorld();
|
||||
}
|
||||
|
||||
void CCliWorldManager::quit(){
|
||||
cdebug << "Connection to world server lost!\n";
|
||||
}
|
||||
|
||||
void CCliWorldManager::hello(){
|
||||
cdebug << "Hello from world server!\n";
|
||||
}
|
||||
|
||||
void CCliWorldManager::sendPing(){
|
||||
m_pingCounter++;
|
||||
|
||||
if (m_pingCounter > m_pingCounterMax){
|
||||
if (m_pingCounterMax < MAXPINGPONG)
|
||||
m_pingCounterMax = m_pingCounter;
|
||||
m_pingCounter = 0;
|
||||
|
||||
DWORD sendTime = getWorld()->getTime();
|
||||
|
||||
BYTE sequenceNumber = m_pingPong->sendPing(sendTime);
|
||||
|
||||
cout << "PING: " << (int)sequenceNumber
|
||||
<< " time " << sendTime << endl;
|
||||
|
||||
CCliWorldProtocol * protocol = getProtocol();
|
||||
protocol->sendMessage(new CMsgPing( sequenceNumber ),TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void CCliWorldManager::pong(BYTE sequenceNumber, DWORD serverTime){
|
||||
DWORD reciveTime = getWorld()->getTime();
|
||||
|
||||
long timediff = m_pingPong->recivePong(reciveTime,sequenceNumber,serverTime);
|
||||
|
||||
cout << "PONG: sequence number " << (int)sequenceNumber
|
||||
<< " serverTime " << serverTime
|
||||
<< " recive time " << reciveTime
|
||||
<< " time diff " << timediff << endl;
|
||||
|
||||
cout << "Ping info " << *m_pingPong << endl;
|
||||
|
||||
getWorld()->fixTime(timediff);
|
||||
|
||||
}
|
||||
|
||||
|
56
client/coreclient/cliworldmanager.H
Normal file
56
client/coreclient/cliworldmanager.H
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 _CLIWORLDMANAGER_H
|
||||
#define _CLIWORLDMANAGER_H
|
||||
|
||||
#include "manager.H"
|
||||
#include "cliworldprotocol.H"
|
||||
#include "cliworld.H"
|
||||
#include "pingpong.H"
|
||||
|
||||
|
||||
class CCliSrvManager;
|
||||
|
||||
class CCliWorldManager : public CManager {
|
||||
|
||||
CCliSrvManager * m_client;
|
||||
|
||||
CPingPong * m_pingPong;
|
||||
int m_pingCounter;
|
||||
int m_pingCounterMax;
|
||||
|
||||
|
||||
public:
|
||||
CCliWorldManager(CCliSrvManager * client, CCliWorldProtocol * protocol);
|
||||
virtual ~CCliWorldManager();
|
||||
|
||||
CCliWorldProtocol * getProtocol();
|
||||
|
||||
CCliWorld * getWorld();
|
||||
|
||||
virtual void quit();
|
||||
|
||||
void hello();
|
||||
void sendPing();
|
||||
void pong(BYTE sequenceNumber, DWORD serverTime);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLIWORLDMANAGER_H
|
234
client/coreclient/cliworldmessage.C
Normal file
234
client/coreclient/cliworldmessage.C
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 "cliworldmessage.H"
|
||||
#include "cliworldmanager.H"
|
||||
|
||||
CMsgCliWorldHello::CMsgCliWorldHello():CMsgHello(){
|
||||
}
|
||||
|
||||
CMsgCliWorldHello * CMsgCliWorldHello::createMsg(){
|
||||
return new CMsgCliWorldHello();
|
||||
}
|
||||
|
||||
|
||||
int CMsgCliWorldHello::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
if (getVersion() != PROTOCOL_VERSION){
|
||||
cdebug << "ERROR: Wrong protocol version!\n";
|
||||
exit(2);
|
||||
}
|
||||
manager->hello();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldCell::CMsgCliWorldCell():CMsgCell(){
|
||||
}
|
||||
|
||||
CMsgCliWorldCell * CMsgCliWorldCell::createMsg(){
|
||||
return new CMsgCliWorldCell();
|
||||
}
|
||||
|
||||
int CMsgCliWorldCell::executeMsg(){
|
||||
cdebug << "Cell " << getCellId() << " with geometry " << getGeometryId()
|
||||
<< " with position " << getPosition() <<"\n";
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
CWorldObject * cell = manager->getWorld()->addCell(getCellId(),getGeometryId());
|
||||
cell->setPosition(getPosition());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldRemoveCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldRemoveCell::CMsgCliWorldRemoveCell():CMsgRemoveCell(){
|
||||
}
|
||||
|
||||
CMsgCliWorldRemoveCell * CMsgCliWorldRemoveCell::createMsg(){
|
||||
return new CMsgCliWorldRemoveCell();
|
||||
}
|
||||
|
||||
int CMsgCliWorldRemoveCell::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->getWorld()->removeCell(getCellId());
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldObject
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldObject::CMsgCliWorldObject():CMsgObject(){
|
||||
}
|
||||
|
||||
CMsgCliWorldObject * CMsgCliWorldObject::createMsg(){
|
||||
return new CMsgCliWorldObject();
|
||||
}
|
||||
|
||||
int CMsgCliWorldObject::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
cdebug << "Object " << getObjectId() << " with parent " << getParentId() << " with geometry " << getGeometryId()
|
||||
<< " with position " << getPosition() <<" with direction " << getDirection() << "\n";
|
||||
if (manager->getWorld()->createObject(getParentId(),"object",getObjectId(),
|
||||
getGeometryId(),getPosition(),
|
||||
getDirection())==NULL){
|
||||
cdebug << "Failed to create object " << getObjectId() << "\n";
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldRemoveObject
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldRemoveObject::CMsgCliWorldRemoveObject():CMsgRemoveObject(){
|
||||
}
|
||||
|
||||
CMsgCliWorldRemoveObject * CMsgCliWorldRemoveObject::createMsg(){
|
||||
return new CMsgCliWorldRemoveObject();
|
||||
}
|
||||
|
||||
int CMsgCliWorldRemoveObject::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
cdebug << "REMOVE : Object: " << getObjectId() << " Parent: " << getParentId() << "\n";
|
||||
manager->getWorld()->removeObject(getObjectId(),getParentId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldUpdatePosition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldUpdatePosition::CMsgCliWorldUpdatePosition():CMsgUpdatePosition(){
|
||||
}
|
||||
|
||||
CMsgCliWorldUpdatePosition * CMsgCliWorldUpdatePosition::createMsg(){
|
||||
return new CMsgCliWorldUpdatePosition();
|
||||
}
|
||||
|
||||
int CMsgCliWorldUpdatePosition::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->getWorld()->updatePosition(getObjectId(),getPosition());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldUpdateDirection
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldUpdateDirection::CMsgCliWorldUpdateDirection():CMsgUpdateDirection(){
|
||||
}
|
||||
|
||||
CMsgCliWorldUpdateDirection * CMsgCliWorldUpdateDirection::createMsg(){
|
||||
return new CMsgCliWorldUpdateDirection();
|
||||
}
|
||||
|
||||
int CMsgCliWorldUpdateDirection::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->getWorld()->updateDirection(getObjectId(),getDirection());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldUpdateHierarchy
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldUpdateHierarchy::CMsgCliWorldUpdateHierarchy():CMsgUpdateHierarchy(){
|
||||
}
|
||||
|
||||
CMsgCliWorldUpdateHierarchy * CMsgCliWorldUpdateHierarchy::createMsg(){
|
||||
return new CMsgCliWorldUpdateHierarchy();
|
||||
}
|
||||
|
||||
int CMsgCliWorldUpdateHierarchy::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->getWorld()->updateHierarchy(getObjectId(),getParentId());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldPong
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldPong::CMsgCliWorldPong():CMsgPong(){
|
||||
}
|
||||
|
||||
CMsgCliWorldPong * CMsgCliWorldPong::createMsg(){
|
||||
return new CMsgCliWorldPong();
|
||||
}
|
||||
|
||||
int CMsgCliWorldPong::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->pong(getSequenceNumber(),getServerTime());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCliWorldRotate
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCliWorldRotate::CMsgCliWorldRotate():CMsgRotate(){
|
||||
}
|
||||
|
||||
CMsgCliWorldRotate * CMsgCliWorldRotate::createMsg(){
|
||||
return new CMsgCliWorldRotate();
|
||||
}
|
||||
|
||||
int CMsgCliWorldRotate::executeMsg(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->getWorld()->rotate(getObjectId(),getAngleSpeed());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
100
client/coreclient/cliworldmessage.H
Normal file
100
client/coreclient/cliworldmessage.H
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 _CLIWORLDMESSAGE_H
|
||||
#define _CLIWORLDMESSAGE_H
|
||||
|
||||
#include "msgsrvcli.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
class CMsgCliWorldHello : public CMsgHello {
|
||||
public:
|
||||
CMsgCliWorldHello();
|
||||
static CMsgCliWorldHello * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
/*
|
||||
class CMsgCliWorldCell : public CMsgCell {
|
||||
public:
|
||||
CMsgCliWorldCell();
|
||||
static CMsgCliWorldCell * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldRemoveCell : public CMsgRemoveCell {
|
||||
public:
|
||||
CMsgCliWorldRemoveCell();
|
||||
static CMsgCliWorldRemoveCell * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
*/
|
||||
|
||||
class CMsgCliWorldObject : public CMsgObject {
|
||||
public:
|
||||
CMsgCliWorldObject();
|
||||
static CMsgCliWorldObject * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldRemoveObject : public CMsgRemoveObject {
|
||||
public:
|
||||
CMsgCliWorldRemoveObject();
|
||||
static CMsgCliWorldRemoveObject * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldUpdatePosition: public CMsgUpdatePosition {
|
||||
public:
|
||||
CMsgCliWorldUpdatePosition();
|
||||
static CMsgCliWorldUpdatePosition * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldUpdateDirection: public CMsgUpdateDirection {
|
||||
public:
|
||||
CMsgCliWorldUpdateDirection();
|
||||
static CMsgCliWorldUpdateDirection * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldUpdateHierarchy: public CMsgUpdateHierarchy {
|
||||
public:
|
||||
CMsgCliWorldUpdateHierarchy();
|
||||
static CMsgCliWorldUpdateHierarchy * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldPong: public CMsgPong {
|
||||
public:
|
||||
CMsgCliWorldPong();
|
||||
static CMsgCliWorldPong * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
class CMsgCliWorldRotate: public CMsgRotate {
|
||||
public:
|
||||
CMsgCliWorldRotate();
|
||||
static CMsgCliWorldRotate * createMsg();
|
||||
virtual int executeMsg();
|
||||
};
|
||||
|
||||
|
||||
#endif // _CLIWORLDMESSAGE_H
|
||||
|
49
client/coreclient/cliworldprotocol.C
Normal file
49
client/coreclient/cliworldprotocol.C
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
|
||||
*
|
||||
*/
|
||||
#include "client.H"
|
||||
#include "cliworldprotocol.H"
|
||||
#include "cliworldmanager.H"
|
||||
#include "cliworldmessage.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
|
||||
CCliWorldProtocol::CCliWorldProtocol(CSocket * socket, CTimeKeeper * timeKeeper):CCommunicate(socket,timeKeeper){
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldHello::createMsg);
|
||||
// addMsg((MsgCreateFunc_t)CMsgCliWorldCell::createMsg);
|
||||
// addMsg((MsgCreateFunc_t)CMsgCliWorldRemoveCell::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldObject::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldRemoveObject::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldUpdatePosition::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldUpdateDirection::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldUpdateHierarchy::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldPong::createMsg);
|
||||
addMsg((MsgCreateFunc_t)CMsgCliWorldRotate::createMsg);
|
||||
}
|
||||
|
||||
void CCliWorldProtocol::quit(){
|
||||
CCliWorldManager * manager = (CCliWorldManager*)getManager();
|
||||
manager->quit();
|
||||
}
|
||||
|
||||
void CCliWorldProtocol::sendChangeMasterCell(DWORD newMasterCellId){
|
||||
CMsgChangeMasterCell * msg = new CMsgChangeMasterCell(newMasterCellId);
|
||||
sendMessage(msg,TRUE);
|
||||
}
|
||||
|
37
client/coreclient/cliworldprotocol.H
Normal file
37
client/coreclient/cliworldprotocol.H
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _CLIWORLDPROTOCOL_H
|
||||
#define _CLIWORLDPROTOCOL_H
|
||||
|
||||
#include "communicate.H"
|
||||
|
||||
class CCliWorldProtocol : public CCommunicate {
|
||||
|
||||
public:
|
||||
CCliWorldProtocol(CSocket * socket, CTimeKeeper * timeKeeper);
|
||||
|
||||
virtual void quit();
|
||||
|
||||
// Messages
|
||||
void sendChangeMasterCell(DWORD newMasterCellId);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CLIWORLDPROTOCOL_H
|
5
client/gui/Makefile.am
Normal file
5
client/gui/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I.. -I../renderer -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = libgui.a
|
||||
|
||||
libgui_a_SOURCES = glutgui.C gui.C
|
328
client/gui/Makefile.in
Normal file
328
client/gui/Makefile.in
Normal file
@@ -0,0 +1,328 @@
|
||||
# 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.. -I../renderer -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = libgui.a
|
||||
|
||||
libgui_a_SOURCES = glutgui.C gui.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@
|
||||
libgui_a_LIBADD =
|
||||
libgui_a_OBJECTS = glutgui.o gui.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/glutgui.P .deps/gui.P
|
||||
SOURCES = $(libgui_a_SOURCES)
|
||||
OBJECTS = $(libgui_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 client/gui/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:
|
||||
|
||||
libgui.a: $(libgui_a_OBJECTS) $(libgui_a_DEPENDENCIES)
|
||||
-rm -f libgui.a
|
||||
$(AR) cru libgui.a $(libgui_a_OBJECTS) $(libgui_a_LIBADD)
|
||||
$(RANLIB) libgui.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 = client/gui
|
||||
|
||||
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 client/gui/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:
|
103
client/gui/glutgui.C
Normal file
103
client/gui/glutgui.C
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 "glutgui.H"
|
||||
#include "glrenderer.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CGlutGUI * CGlutGUI::m_glutgui = NULL;
|
||||
|
||||
void glutgui_display(){
|
||||
CGlutGUI::m_glutgui->display();
|
||||
}
|
||||
|
||||
void glutgui_idle() {
|
||||
CGlutGUI::m_glutgui->idle();
|
||||
}
|
||||
|
||||
void glutgui_reshape(int height, int width){
|
||||
CGlutGUI::m_glutgui->reshape(height,width);
|
||||
}
|
||||
|
||||
void glutgui_visible(int vis) {
|
||||
CGlutGUI::m_glutgui->visible(vis);
|
||||
}
|
||||
|
||||
void glutgui_key(unsigned char k, int x, int y) {
|
||||
CGlutGUI::m_glutgui->getClient()->getInputFunction()->key(k, x, y);
|
||||
}
|
||||
void glutgui_special(int k, int x, int y) {
|
||||
CGlutGUI::m_glutgui->getClient()->getInputFunction()->special(k, x, y);
|
||||
}
|
||||
void glutgui_mouse(int button, int state, int x, int y) {
|
||||
CGlutGUI::m_glutgui->getClient()->getInputFunction()->mouse(button, state, x, y);
|
||||
}
|
||||
|
||||
CGlutGUI::CGlutGUI(int argc, char * argv[], CRenderer * r, CPvvmudClient * cli, int width, int height) : CGUI(r, cli, width, height) {
|
||||
|
||||
m_glutgui = this;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutInitWindowSize(width, height);
|
||||
glutCreateWindow("PVVMUD");
|
||||
glutDisplayFunc(glutgui_display);
|
||||
glutReshapeFunc(glutgui_reshape);
|
||||
glutVisibilityFunc(glutgui_visible);
|
||||
|
||||
glutKeyboardFunc(glutgui_key);
|
||||
glutSpecialFunc(glutgui_special);
|
||||
glutMouseFunc(glutgui_mouse);
|
||||
}
|
||||
|
||||
//int * CGlutGUI::getSize() {}
|
||||
|
||||
void CGlutGUI::display() {
|
||||
((COGLRenderer*)getRenderer())->setMode(GL_RENDER);
|
||||
getRenderer()->draw();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void CGlutGUI::idle() {
|
||||
// manager->communicate();
|
||||
getClient()->getTimeKeeper()->poll(0);
|
||||
getClient()->pollConsole();
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void CGlutGUI::visible(int vis) {
|
||||
if (vis == GLUT_VISIBLE)
|
||||
glutIdleFunc(glutgui_idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
}
|
||||
|
||||
void CGlutGUI::reshape(int width, int height) {
|
||||
getRenderer()->reshape(width, height);
|
||||
}
|
||||
|
||||
void CGlutGUI::run() {
|
||||
glutMainLoop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
client/gui/glutgui.H
Normal file
42
client/gui/glutgui.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 _GLUTGUI_H
|
||||
#define _GLUTGUI_H
|
||||
#include <GL/glut.h>
|
||||
#include "gui.H"
|
||||
|
||||
class CGlutGUI : public CGUI {
|
||||
public:
|
||||
static CGlutGUI * m_glutgui;
|
||||
CGlutGUI(int argc, char * argv[], CRenderer * r, CPvvmudClient * cli, int width, int height);
|
||||
~CGlutGUI() {}
|
||||
virtual void reshape(int height, int width);
|
||||
|
||||
void display();
|
||||
void idle();
|
||||
void visible(int vis);
|
||||
void key(unsigned char k, int x, int y);
|
||||
void special(int k, int x, int y);
|
||||
void mouse(int button, int state, int x, int y);
|
||||
virtual void run();
|
||||
void start();
|
||||
};
|
||||
|
||||
#endif // _GLUTGUI_H
|
66
client/gui/gui.C
Normal file
66
client/gui/gui.C
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "gui.H"
|
||||
|
||||
CGUI::CGUI(CRenderer * r, CPvvmudClient * cli, int width, int height) {
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_renderer = r;
|
||||
m_client = cli;
|
||||
}
|
||||
|
||||
CGUI::~CGUI(){
|
||||
}
|
||||
|
||||
CRenderer * CGUI::getRenderer() {
|
||||
return m_renderer;
|
||||
}
|
||||
|
||||
void CGUI::setRenderer(CRenderer * r) {
|
||||
m_renderer = r;
|
||||
}
|
||||
|
||||
CPvvmudClient *CGUI::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
int CGUI::getWidth() {
|
||||
return m_width;
|
||||
}
|
||||
|
||||
int CGUI::getHeight() {
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void CGUI::setWidth(int width) {
|
||||
m_width = width;
|
||||
}
|
||||
|
||||
void CGUI::setHeight(int height) {
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
void CGUI::run(){
|
||||
}
|
||||
|
||||
void CGUI::reshape(int height, int width) {
|
||||
}
|
49
client/gui/gui.H
Normal file
49
client/gui/gui.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 _GUI_H
|
||||
#define _GUI_H
|
||||
class CPvvmudClient;
|
||||
class CRenderer;
|
||||
class CGUI {
|
||||
int m_width;
|
||||
int m_height;
|
||||
CRenderer * m_renderer;
|
||||
CPvvmudClient * m_client;
|
||||
|
||||
public:
|
||||
CGUI(CRenderer * r, CPvvmudClient * cli, int width, int height);
|
||||
virtual ~CGUI();
|
||||
CRenderer * getRenderer();
|
||||
void setRenderer(CRenderer * r);
|
||||
CPvvmudClient * getClient();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
void setWidth(int width);
|
||||
void setHeight(int height);
|
||||
virtual void reshape(int height, int width);
|
||||
/*virtual void display();
|
||||
virtual void visible();
|
||||
virtual void key();
|
||||
virtual void special();
|
||||
virtual void mouse();*/
|
||||
virtual void run();
|
||||
};
|
||||
|
||||
#endif // _GUI_H
|
313
client/inputfunction.C
Normal file
313
client/inputfunction.C
Normal file
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* 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 "client.H"
|
||||
#include "inputfunction.H"
|
||||
#include "msgsrvcli.H"
|
||||
#include "srvcliconsole.H"
|
||||
// Commandline for creating default map
|
||||
// grep addInp inputfunction.C | tr '"' ' ' | awk '{print $4 " " $2}' > .pvvmud_ifm
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
CInputFunction::CInputFunction(CCliSrvManager * manager, CRenderer * renderer){
|
||||
|
||||
m_manager = manager;
|
||||
m_renderer = renderer;
|
||||
|
||||
addInputFunction("key_H","playermove_runleft",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_RUNLEFT);
|
||||
addInputFunction("key_J","playermove_runbackward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_RUNBACKWARD);
|
||||
addInputFunction("key_K","playermove_runforward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_RUNFORWARD);
|
||||
addInputFunction("key_L","playermove_runright",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_RUNRIGHT);
|
||||
|
||||
addInputFunction("","playermove_moveleft",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_MOVELEFT);
|
||||
addInputFunction("","playermove_movebackward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_MOVEBACKWARD);
|
||||
addInputFunction("","playermove_moveforward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_MOVEFORWARD);
|
||||
addInputFunction("","playermove_moveright",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_MOVERIGHT);
|
||||
|
||||
addInputFunction("key_h","playermove_stepleft",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_STEPLEFT);
|
||||
addInputFunction("key_j","playermove_stepbackward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_STEPBACKWARD);
|
||||
addInputFunction("key_k","playermove_stepforward",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_STEPFORWARD);
|
||||
addInputFunction("key_l","playermove_stepright",
|
||||
(InputFunction_t)&playerMove,PLAYERMOVE_STEPRIGHT);
|
||||
|
||||
addInputFunction("key_0","usercommand_0",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_0);
|
||||
addInputFunction("key_1","usercommand_1",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_1);
|
||||
addInputFunction("key_2","usercommand_2",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_2);
|
||||
addInputFunction("key_3","usercommand_3",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_3);
|
||||
addInputFunction("key_4","usercommand_4",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_4);
|
||||
addInputFunction("key_5","usercommand_5",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_5);
|
||||
addInputFunction("key_6","usercommand_6",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_6);
|
||||
addInputFunction("key_7","usercommand_7",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_7);
|
||||
addInputFunction("key_8","usercommand_8",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_8);
|
||||
addInputFunction("key_9","usercommand_9",
|
||||
(InputFunction_t)&userCommand,USERCOMMAND_9);
|
||||
|
||||
addInputFunction("key_escape","quit",
|
||||
(InputFunction_t)&quitFunction,-1);
|
||||
|
||||
addInputFunction("key_space","playerlook_default",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_DEFAULT);
|
||||
|
||||
addInputFunction("key_enter", "toggle_inputmode",
|
||||
(InputFunction_t)&consoleFunction, TOGGLE_CONSOLE_MODE);
|
||||
|
||||
addInputFunction("key_tab", "show_hide_console",
|
||||
(InputFunction_t)&consoleFunction, CONSOLE_SHOW_HIDE);
|
||||
|
||||
addInputFunction("key_up","playerlook_forward",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_FORWARD);
|
||||
addInputFunction("key_down","playerlook_backward",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_BACKWARD);
|
||||
addInputFunction("key_left","playerlook_left",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_LEFT);
|
||||
addInputFunction("key_right","playerlook_right",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_RIGHT);
|
||||
addInputFunction("key_page_up","playerlook_up",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_UP);
|
||||
addInputFunction("key_page_down","playerlook_down",
|
||||
(InputFunction_t)&playerlook,PLAYERLOOK_DOWN);
|
||||
|
||||
addInputFunction("mouse_left_up","pick",
|
||||
(InputFunction_t)&pickFunction,-1);
|
||||
|
||||
addInputFunction("key_d","dump",
|
||||
(InputFunction_t)&dumpFunc,DUMP_WORLD);
|
||||
addInputFunction("key_c","capture",
|
||||
(InputFunction_t)&dumpFunc,DUMP_SCREEN);
|
||||
|
||||
loadMap(".pvvmud_ifm");
|
||||
}
|
||||
|
||||
void CInputFunction::setRenderer(CRenderer * renderer) {
|
||||
m_renderer = renderer;
|
||||
}
|
||||
|
||||
CRenderer * CInputFunction::getRenderer() {
|
||||
return m_renderer;
|
||||
}
|
||||
|
||||
void CInputFunction::setConsole(CConsole * console) {
|
||||
m_console = console;
|
||||
}
|
||||
|
||||
CConsole * CInputFunction::getConsole() {
|
||||
return m_console;
|
||||
}
|
||||
|
||||
void CInputFunction::processHits(int hits, unsigned int buffer[]){
|
||||
int i;
|
||||
unsigned int selection, zvalue;
|
||||
unsigned int names,z2,z1,*ptr,j;
|
||||
cdebug << "hits = " << hits;
|
||||
|
||||
selection = 0; zvalue = 0xFFFFFFFF;
|
||||
|
||||
ptr = buffer;
|
||||
for (i = 0; i < hits; i++){
|
||||
names = *ptr; ptr++;
|
||||
z1 = *ptr; ptr++;
|
||||
z2 = *ptr; ptr++;
|
||||
if (z2 < zvalue){
|
||||
selection = *ptr;
|
||||
zvalue = z2;
|
||||
}
|
||||
for (j=0; j < names; j++){
|
||||
cdebug << ptr;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
cdebug << "Selection = " << selection << "\n";
|
||||
m_manager->selection(selection);
|
||||
}
|
||||
|
||||
|
||||
int CInputFunction::playerlook(int argument){
|
||||
m_manager->playerLook(argument);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::playerMove(int argument){
|
||||
m_manager->playerMove(argument);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::userCommand(int argument){
|
||||
m_manager->userCommand(argument);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::quitFunction(int argument){
|
||||
|
||||
CSrvCliConsole * c = (CSrvCliConsole *)getConsole();
|
||||
c->saveHistory();
|
||||
// save_params();
|
||||
m_manager->quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::consoleFunction(int argument) {
|
||||
switch (argument) {
|
||||
case TOGGLE_CONSOLE_MODE:
|
||||
cout << "Input" << getConsole()->getInputMode() << " -> ";
|
||||
getConsole()->changeInputMode();
|
||||
cout << getConsole()->getInputMode() << '\n';
|
||||
break;
|
||||
case CONSOLE_SHOW_HIDE:
|
||||
cout << "Visible" << getConsole()->isVisible() << " -> ";
|
||||
getConsole()->setVisible();
|
||||
cout << getConsole()->isVisible() << '\n';
|
||||
break;
|
||||
default:
|
||||
cout << "Error\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::pickFunction(int argument){
|
||||
m_renderer->mousePick(m_xx, m_yy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CInputFunction::dumpFunc(int argument){
|
||||
switch (argument){
|
||||
case DUMP_WORLD:
|
||||
m_manager->dump();
|
||||
break;
|
||||
case DUMP_SCREEN:
|
||||
m_renderer->dumpScreen("pvvmudscreen.tex");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CInputFunction::key(unsigned char k, int x, int y){
|
||||
m_xx = x; m_yy = y; // Save position i global variables
|
||||
if (getConsole()->getInputMode()) {
|
||||
getConsole()->keyboardInput(k);
|
||||
}
|
||||
else {
|
||||
switch (k){
|
||||
case ' ':
|
||||
executeFunction("key_space");
|
||||
break;
|
||||
case 27: /* Escape */
|
||||
executeFunction("key_escape");
|
||||
break;
|
||||
case '\r':
|
||||
executeFunction("key_enter");
|
||||
break;
|
||||
case '\t':
|
||||
executeFunction("key_tab");
|
||||
break;
|
||||
default:
|
||||
char keybuf[6];
|
||||
strcpy(keybuf,"key_?");
|
||||
keybuf[4] = k;
|
||||
executeFunction(keybuf);
|
||||
}
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void CInputFunction::special(int k, int x, int y) {
|
||||
m_xx = x; m_yy = y; // Save position i global variables
|
||||
if (getConsole()->getInputMode()) {
|
||||
switch (k) {
|
||||
case GLUT_KEY_UP:
|
||||
getConsole()->keyboardInput(KEY_UP);
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
getConsole()->keyboardInput(KEY_DOWN);
|
||||
break;
|
||||
} // swich
|
||||
} // if
|
||||
switch (k) {
|
||||
case GLUT_KEY_UP:
|
||||
executeFunction("key_up");
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
executeFunction("key_down");
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
executeFunction("key_left");
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
executeFunction("key_right");
|
||||
break;
|
||||
case GLUT_KEY_PAGE_UP:
|
||||
executeFunction("key_page_up");
|
||||
break;
|
||||
case GLUT_KEY_PAGE_DOWN:
|
||||
executeFunction("key_page_down");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void CInputFunction::mouse(int button, int state, int x, int y){
|
||||
m_xx = x; m_yy = y; // Save position i global variables
|
||||
switch(button){
|
||||
case GLUT_LEFT_BUTTON:
|
||||
if (state == GLUT_UP)
|
||||
executeFunction("mouse_left_up");
|
||||
else
|
||||
executeFunction("mouse_left_down");
|
||||
break;
|
||||
case GLUT_MIDDLE_BUTTON:
|
||||
if (state == GLUT_UP)
|
||||
executeFunction("mouse_middle_up");
|
||||
else
|
||||
executeFunction("mouse_middle_down");
|
||||
break;
|
||||
case GLUT_RIGHT_BUTTON:
|
||||
if (state == GLUT_UP)
|
||||
executeFunction("mouse_right_up");
|
||||
else
|
||||
executeFunction("mouse_right_down");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
67
client/inputfunction.H
Normal file
67
client/inputfunction.H
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 _INPUTFUNCTION_H
|
||||
#define _INPUTFUNCTION_H
|
||||
|
||||
#include "inputfunctionmap.H"
|
||||
#include "clisrvmanager.H"
|
||||
|
||||
#define TOGGLE_CONSOLE_MODE 0
|
||||
#define CONSOLE_SHOW_HIDE 1
|
||||
|
||||
#define DUMP_SCREEN 0
|
||||
#define DUMP_WORLD 1
|
||||
|
||||
class CRenderer;
|
||||
class CInputFunction: public CInputFunctionMap {
|
||||
int m_xx,m_yy;
|
||||
CCliSrvManager * m_manager;
|
||||
CRenderer * m_renderer;
|
||||
CConsole * m_console;
|
||||
|
||||
int playerlook(int argument);
|
||||
int playerMove(int argument);
|
||||
int userCommand(int argument);
|
||||
int quitFunction(int argument);
|
||||
int consoleFunction(int argument);
|
||||
int pickFunction(int argument);
|
||||
int dumpFunc(int argument);
|
||||
|
||||
public:
|
||||
CInputFunction(CCliSrvManager * manager, CRenderer * renderer);
|
||||
void setRenderer(CRenderer * renderer);
|
||||
CRenderer * getRenderer();
|
||||
void setConsole(CConsole * console);
|
||||
CConsole * getConsole();
|
||||
|
||||
void processHits(int hits, unsigned int buffer[]);
|
||||
|
||||
void key(unsigned char k, int x, int y);
|
||||
void special(int k, int x, int y);
|
||||
void mouse(int button, int state, int x, int y);
|
||||
};
|
||||
|
||||
#endif // _INPUTFUNCTION_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
117
client/inputfunctionmap.C
Normal file
117
client/inputfunctionmap.C
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
#include "client.H"
|
||||
#include "inputfunctionmap.H"
|
||||
|
||||
CInputFunctionMapItem::CInputFunctionMapItem(CInputFunctionMap * inputFunctionMap, char * functionIdString, InputFunction_t inputFunction){
|
||||
this->inputIdStr = NULL;
|
||||
this->functionIdStr = functionIdString;
|
||||
this->inputFunction = inputFunction;
|
||||
argument = -1;
|
||||
m_inputFunctionMap = inputFunctionMap;
|
||||
}
|
||||
|
||||
CInputFunctionMapItem::CInputFunctionMapItem(CInputFunctionMap * inputFunctionMap, char * inputIdString, char * functionIdString, InputFunction_t inputFunction,int argument){
|
||||
this->inputIdStr = inputIdString;
|
||||
this->functionIdStr = functionIdString;
|
||||
this->inputFunction = inputFunction;
|
||||
this->argument = argument;
|
||||
m_inputFunctionMap = inputFunctionMap;
|
||||
}
|
||||
|
||||
void CInputFunctionMapItem::setInputIdStr(char * inputIdString){
|
||||
this->inputIdStr = (char*)malloc(strlen(inputIdString)+1);
|
||||
strcpy(this->inputIdStr,inputIdString);
|
||||
}
|
||||
|
||||
int CInputFunctionMapItem::executeFunction(int argument){
|
||||
return (m_inputFunctionMap->*inputFunction)(argument);
|
||||
}
|
||||
|
||||
int CInputFunctionMapItem::executeFunction(){
|
||||
return executeFunction(argument);
|
||||
}
|
||||
|
||||
|
||||
CInputFunctionMap::CInputFunctionMap(){
|
||||
inputFunctionMap = new CObjectList();
|
||||
}
|
||||
|
||||
void CInputFunctionMap::addInputFunction(char * functionIdString, InputFunction_t inputFunction){
|
||||
inputFunctionMap->addLast(new CInputFunctionMapItem(this,functionIdString,inputFunction));
|
||||
}
|
||||
|
||||
void CInputFunctionMap::addInputFunction(char * inputIdString, char * functionIdString, InputFunction_t inputFunction, int argument){
|
||||
inputFunctionMap->addLast(new CInputFunctionMapItem(this,inputIdString,functionIdString,inputFunction,argument));
|
||||
}
|
||||
|
||||
void CInputFunctionMap::loadMap(char * fileName){
|
||||
char inputIdString[256];
|
||||
char functionIdString[256];
|
||||
FILE * mapFile = fopen(fileName,"r");
|
||||
if (mapFile == NULL){
|
||||
cdebug << "Failed to open input function map file " << fileName << "\n";
|
||||
return;
|
||||
}
|
||||
while (fscanf(mapFile,"%s %s\n",functionIdString,inputIdString)==2){
|
||||
setFunctionInputId(functionIdString,inputIdString);
|
||||
}
|
||||
fclose(mapFile);
|
||||
}
|
||||
|
||||
void CInputFunctionMap::setFunctionInputId(char * functionIdString,char * inputIdString){
|
||||
CObjectListItem * item = inputFunctionMap->getFirst();
|
||||
while (item != NULL){
|
||||
CInputFunctionMapItem * IFMItem = (CInputFunctionMapItem*)item->getObject();
|
||||
if (strcmp(functionIdString,IFMItem->getFunctionIdStr())==0){
|
||||
return IFMItem->setInputIdStr(inputIdString);
|
||||
}
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
int CInputFunctionMap::executeFunction(char * inputIdStr, int argument ){
|
||||
CObjectListItem * item = inputFunctionMap->getFirst();
|
||||
while (item != NULL){
|
||||
CInputFunctionMapItem * IFMItem = (CInputFunctionMapItem*)item->getObject();
|
||||
if (strcmp(inputIdStr,IFMItem->getInputIdStr())==0){
|
||||
return IFMItem->executeFunction(argument);
|
||||
}
|
||||
item = item->getNext();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CInputFunctionMap::executeFunction(char * inputIdStr ){
|
||||
CObjectListItem * item = inputFunctionMap->getFirst();
|
||||
while (item != NULL){
|
||||
CInputFunctionMapItem * IFMItem = (CInputFunctionMapItem*)item->getObject();
|
||||
if (strcmp(inputIdStr,IFMItem->getInputIdStr())==0){
|
||||
return IFMItem->executeFunction();
|
||||
}
|
||||
item = item->getNext();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
56
client/inputfunctionmap.H
Normal file
56
client/inputfunctionmap.H
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 _INPUTFUNCTIONMAP_H
|
||||
#define _INPUTFUNCTIONMAP_H
|
||||
|
||||
#include "objectlist.H"
|
||||
|
||||
class CInputFunctionMap;
|
||||
|
||||
typedef int (CInputFunctionMap::*InputFunction_t)(int argument);
|
||||
|
||||
class CInputFunctionMapItem : public CObject {
|
||||
char *inputIdStr,*functionIdStr;
|
||||
InputFunction_t inputFunction;
|
||||
int argument;
|
||||
CInputFunctionMap * m_inputFunctionMap;
|
||||
public:
|
||||
CInputFunctionMapItem(CInputFunctionMap * inputFunctionMap, char * functionIdString, InputFunction_t inputFunction);
|
||||
CInputFunctionMapItem(CInputFunctionMap * inputFunctionMap, char * inputIdString, char * functionIdString, InputFunction_t inputFunction, int argument);
|
||||
void setInputIdStr(char * inputIdString);
|
||||
char *getInputIdStr(){ return inputIdStr; }
|
||||
char *getFunctionIdStr(){ return functionIdStr; }
|
||||
int executeFunction(int argument);
|
||||
int executeFunction();
|
||||
};
|
||||
|
||||
class CInputFunctionMap {
|
||||
CObjectList * inputFunctionMap;
|
||||
public:
|
||||
CInputFunctionMap();
|
||||
void addInputFunction(char * functionIdString, InputFunction_t inputFunction);
|
||||
void addInputFunction(char * inputIdString, char * functionIdString, InputFunction_t inputFunction, int argument);
|
||||
void loadMap(char * fileName);
|
||||
void setFunctionInputId(char * functionIdString,char * inputIdString);
|
||||
int executeFunction(char * inputIdStr, int argument );
|
||||
int executeFunction(char * inputIdStr);
|
||||
};
|
||||
|
||||
#endif // _INPUTFUNCTIONMAP_H
|
25
client/inputfunctions.H
Normal file
25
client/inputfunctions.H
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
int initInputFunctions();
|
||||
void key(unsigned char k, int x, int y);
|
||||
void special(int k, int x, int y);
|
||||
void mouse(int button, int state, int x, int y);
|
||||
|
25
client/pvvmud.C
Normal file
25
client/pvvmud.C
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 "pvvmudclient.H"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
CPvvmudClient * client = new CPvvmudClient(argc, argv);
|
||||
client->run();
|
||||
}
|
146
client/pvvmudclient.C
Normal file
146
client/pvvmudclient.C
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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 "pvvmudclient.H"
|
||||
|
||||
#include "glrenderer.H"
|
||||
#include "gltexture.H"
|
||||
#include "glsrvcliconsole.H"
|
||||
|
||||
CPvvmudClient::CPvvmudClient(int argc,char * argv[]) {
|
||||
m_option = new COption;
|
||||
//m_stdInput = new CStdInput();
|
||||
m_option->setValue("server",'s',"localhost");
|
||||
m_option->setValue("username",'u',"Guest");
|
||||
m_option->setValue("passwd",'p',"pvv");
|
||||
|
||||
m_option->loadOption("pvvmud.conf");
|
||||
m_option->parseArguments(argc,argv);
|
||||
|
||||
initGlobalData(m_option);
|
||||
m_gui = new CGlutGUI(argc,argv,m_renderer, this, 400, 300);
|
||||
m_renderer = new COGLRenderer(this);
|
||||
m_console = new CGLSrvCliConsole(this, 40, 20);
|
||||
m_console->setColor(0.8, 0.8, 0.8);
|
||||
m_commandParser = new CCliCmdParser(this);
|
||||
m_gui->setRenderer(m_renderer);
|
||||
m_inputFunction->setRenderer(m_renderer);
|
||||
m_inputFunction->setConsole(m_console);
|
||||
m_renderer->setConsole(m_console);
|
||||
GLTexture_Init();
|
||||
m_geometryCache = new CCliGeometryCache(getManager());
|
||||
m_materialCache = new CCliMaterialCache(getManager());
|
||||
m_textureCache = new CCliTextureCache(getManager());
|
||||
m_lastTime.getTime();
|
||||
|
||||
cdebug << "GeoCache at addr: " << m_geometryCache << "\n";
|
||||
|
||||
m_manager->init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CPvvmudClient::run() {
|
||||
m_gui->run();
|
||||
}
|
||||
|
||||
void CPvvmudClient::initGlobalData(COption * option) {
|
||||
CClientSocket * socket;
|
||||
|
||||
if ((m_option->getString("server"))==NULL) {
|
||||
cdebug << "Error : Argument error in -server\n";
|
||||
exit(1);
|
||||
}
|
||||
try {
|
||||
CInetAddress addr(m_option->getString("server"), SERVER_CLIENT_PORT);
|
||||
socket = new CClientSocket(addr.getAddress(), addr.getPort() );
|
||||
} catch (CSocketException * e){
|
||||
delete e;
|
||||
cdebug << "Failed to connect to server!\n";
|
||||
exit(1);
|
||||
}
|
||||
socket->setNonBlocking();
|
||||
m_timeKeeper = new CTimeKeeper();
|
||||
m_manager = new CCliSrvManager( new CCliSrvProtocol( socket,m_timeKeeper ), m_timeKeeper);
|
||||
m_manager->setClient(this);
|
||||
|
||||
m_inputFunction = new CInputFunction(m_manager, m_renderer);
|
||||
if (m_inputFunction == NULL){
|
||||
cdebug << "Out of memory!!!\n";
|
||||
exit(23);
|
||||
}
|
||||
|
||||
m_timeKeeper->addHeartBeat(512,this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CGeometryCache * CPvvmudClient::getGeometryCache() {
|
||||
return m_geometryCache;
|
||||
}
|
||||
|
||||
CTextureCache * CPvvmudClient::getTextureCache() {
|
||||
return m_textureCache;
|
||||
}
|
||||
|
||||
CMaterialCache * CPvvmudClient::getMaterialCache() {
|
||||
return m_materialCache;
|
||||
}
|
||||
|
||||
CConsole * CPvvmudClient::getConsole() {
|
||||
return m_console;
|
||||
}
|
||||
|
||||
CCliSrvManager * CPvvmudClient::getManager() {
|
||||
return m_manager;
|
||||
}
|
||||
|
||||
CTimeKeeper * CPvvmudClient::getTimeKeeper() {
|
||||
return m_timeKeeper;
|
||||
}
|
||||
|
||||
CGUI * CPvvmudClient::getGUI() {
|
||||
return m_gui;
|
||||
}
|
||||
|
||||
CInputFunction * CPvvmudClient::getInputFunction() {
|
||||
return m_inputFunction;
|
||||
}
|
||||
|
||||
CStdInput * CPvvmudClient::getStdInput() {
|
||||
return m_stdInput;
|
||||
}
|
||||
|
||||
COption * CPvvmudClient::getOption() {
|
||||
return m_option;
|
||||
}
|
||||
|
||||
int CPvvmudClient::timeKeeperHB(){
|
||||
m_manager->sendPing();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPvvmudClient::pollConsole(){
|
||||
const char * msg = getConsole()->getLine();
|
||||
if (msg != NULL) {
|
||||
m_commandParser->parseCommand(msg);
|
||||
}
|
||||
}
|
||||
|
87
client/pvvmudclient.H
Normal file
87
client/pvvmudclient.H
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _PVVMUDCLIENT_H
|
||||
#define _PVVMUDCLIENT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include "gui.H"
|
||||
#include "glutgui.H"
|
||||
#include "renderer.H"
|
||||
#include "console.H"
|
||||
#include "inputfunction.H"
|
||||
#include "time.H"
|
||||
#include "clisrvmanager.H"
|
||||
#include "timekeeper.H"
|
||||
#include "option.H"
|
||||
#include "clientcache.H"
|
||||
#include "stdinput.H"
|
||||
#include "clicmdparser.H"
|
||||
|
||||
class CPvvmudClient : public CTimeKeeperItem {
|
||||
public:
|
||||
CGUI * m_gui;
|
||||
CRenderer * m_renderer;
|
||||
CConsole * m_console;
|
||||
CCliCmdParser * m_commandParser;
|
||||
|
||||
CCliSrvManager * m_manager;
|
||||
CTimeKeeper * m_timeKeeper;
|
||||
CInputFunction * m_inputFunction;
|
||||
CStdInput * m_stdInput;
|
||||
COption * m_option;
|
||||
CTime m_lastTime, m_currTime;
|
||||
|
||||
// Cache-objects
|
||||
CCliGeometryCache * m_geometryCache;
|
||||
CCliTextureCache * m_textureCache;
|
||||
CCliMaterialCache * m_materialCache;
|
||||
|
||||
CPvvmudClient(int argc,char *argv[]);
|
||||
void run();
|
||||
void initGlobalData(COption * option);
|
||||
CGeometryCache * getGeometryCache();
|
||||
CTextureCache * getTextureCache();
|
||||
CMaterialCache * getMaterialCache();
|
||||
|
||||
CConsole * getConsole();
|
||||
CGUI * getGUI();
|
||||
CCliSrvManager * getManager();
|
||||
CTimeKeeper * getTimeKeeper();
|
||||
CInputFunction * getInputFunction();
|
||||
CStdInput * getStdInput();
|
||||
COption * getOption();
|
||||
|
||||
virtual int timeKeeperHB();
|
||||
|
||||
virtual void pollConsole();
|
||||
|
||||
};
|
||||
|
||||
#endif // _PVVMUDCLIENT_H
|
||||
|
||||
|
||||
|
||||
|
5
client/renderer/Makefile.am
Normal file
5
client/renderer/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I.. -I../gui -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = librenderer.a
|
||||
|
||||
librenderer_a_SOURCES = renderer.C glgeometry.C glmaterial.C glrenderer.C gltexture.C console.C glconsole.C srvcliconsole.C glsrvcliconsole.C
|
332
client/renderer/Makefile.in
Normal file
332
client/renderer/Makefile.in
Normal file
@@ -0,0 +1,332 @@
|
||||
# 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.. -I../gui -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = librenderer.a
|
||||
|
||||
librenderer_a_SOURCES = renderer.C glgeometry.C glmaterial.C glrenderer.C gltexture.C console.C glconsole.C srvcliconsole.C glsrvcliconsole.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@
|
||||
librenderer_a_LIBADD =
|
||||
librenderer_a_OBJECTS = renderer.o glgeometry.o glmaterial.o \
|
||||
glrenderer.o gltexture.o console.o glconsole.o srvcliconsole.o \
|
||||
glsrvcliconsole.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/console.P .deps/glconsole.P .deps/glgeometry.P \
|
||||
.deps/glmaterial.P .deps/glrenderer.P .deps/glsrvcliconsole.P \
|
||||
.deps/gltexture.P .deps/renderer.P .deps/srvcliconsole.P
|
||||
SOURCES = $(librenderer_a_SOURCES)
|
||||
OBJECTS = $(librenderer_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 client/renderer/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:
|
||||
|
||||
librenderer.a: $(librenderer_a_OBJECTS) $(librenderer_a_DEPENDENCIES)
|
||||
-rm -f librenderer.a
|
||||
$(AR) cru librenderer.a $(librenderer_a_OBJECTS) $(librenderer_a_LIBADD)
|
||||
$(RANLIB) librenderer.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 = client/renderer
|
||||
|
||||
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 client/renderer/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:
|
264
client/renderer/console.C
Normal file
264
client/renderer/console.C
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* 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 <iostream.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "pvvmud.H"
|
||||
#include "console.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CConsole::CConsole(CPvvmudClient * cli) {
|
||||
CConsole(cli, 40, 20);
|
||||
}
|
||||
|
||||
CConsole::CConsole(CPvvmudClient * cli, int rows, int cols) {
|
||||
m_client = cli;
|
||||
m_cols = cols;
|
||||
m_rows = rows;
|
||||
m_print_x = m_print_y = 0;
|
||||
m_visible = FALSE;
|
||||
m_state = FALSE;
|
||||
m_echo = TRUE;
|
||||
m_dataReady = FALSE;
|
||||
// Calculate start point for drawing (assumes 8-by-13 font)
|
||||
int cons_width = 8 * rows;
|
||||
int cons_height = 13 * cols;
|
||||
m_screen_x = (getClient()->getGUI()->getWidth() - cons_width) / 2;
|
||||
m_screen_y = getClient()->getGUI()->getHeight() - (getClient()->getGUI()->getHeight() - cons_height) / 2;
|
||||
m_input_x = 0;
|
||||
m_input_y = m_cols - 1;
|
||||
m_charColor = (double*)malloc(sizeof(double) * 3);
|
||||
m_numInputChars = 0;
|
||||
m_bufStart = 0;
|
||||
// Allocate space for console data (one extra char for newline)
|
||||
m_console =(char*)malloc(sizeof(char) * (m_cols+1)*m_rows);
|
||||
memset(m_console, 0, (m_cols+1)*m_rows);
|
||||
} // CConsole()
|
||||
|
||||
CConsole::~CConsole() {
|
||||
free(m_console);
|
||||
free(m_charColor);
|
||||
}
|
||||
|
||||
void CConsole::drawText() {
|
||||
}
|
||||
|
||||
void CConsole::addMsg(char * msg) {
|
||||
}
|
||||
|
||||
int CConsole::printLine(char * string) {
|
||||
int i = print(string);
|
||||
if (i) {
|
||||
// Add newline
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
if (m_print_y < m_cols) {
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // if
|
||||
else {
|
||||
m_print_y = m_print_x = 0; //Reached end of console, return to top.
|
||||
} // else
|
||||
} // if
|
||||
return i;
|
||||
} // printLine()
|
||||
|
||||
int CConsole::print(char * string) {
|
||||
char c;
|
||||
int i = 0;
|
||||
while ((c=string[i++])) {
|
||||
if (m_print_y >= m_cols-2) {
|
||||
scroll(1);
|
||||
m_print_y--;
|
||||
}
|
||||
if (m_print_x == m_rows-1) { // Check if the cursor is at the end of a line
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
if (m_print_y >= (m_cols-2)) { // check if the cursor is at the bottom
|
||||
scroll(1);
|
||||
m_print_x = 0;
|
||||
m_print_y--;
|
||||
} // if
|
||||
else {
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // else
|
||||
i--;
|
||||
} // if
|
||||
else if (m_print_x < m_rows) {
|
||||
m_console[m_print_y*m_rows+m_print_x] = c;
|
||||
m_print_x++;
|
||||
} // else if
|
||||
else { // m_print> m_rows => error condition (never supposed to happen)
|
||||
return 0;
|
||||
}
|
||||
if (c == '\n') {
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // if
|
||||
} // while
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CConsole::printChar(char c) {
|
||||
char * tmp = (char*)malloc(sizeof(char)*2);
|
||||
tmp[0] = c;
|
||||
tmp[1] = 0;
|
||||
print(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
void CConsole::echoChar(char c) {
|
||||
if (m_input_x < m_rows) {
|
||||
m_console[m_input_y * m_rows + m_input_x] = c;
|
||||
m_input_x++;
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::clear() {
|
||||
memset(m_console, 0, getRows()*(getCols()+1));
|
||||
setCursorPos(0, 0);
|
||||
}
|
||||
|
||||
void CConsole::scroll(int lines) {
|
||||
for (int i=lines;i<m_cols;i++) {
|
||||
memcpy(&m_console[(i-lines)*(m_rows)], &m_console[i*(m_rows)], m_rows+1);
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::keyboardInput(char k) {
|
||||
switch (k) {
|
||||
case '\r':
|
||||
changeInputMode();
|
||||
if (m_inputBuffer != "") {
|
||||
setDataReady();
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
if (m_numInputChars != 0) {
|
||||
m_numInputChars--;
|
||||
m_input_x--;
|
||||
m_console[m_input_y * m_rows + m_input_x] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (m_echo) {
|
||||
echoChar(k);
|
||||
}
|
||||
m_inputBuffer += k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * CConsole::getLine() {
|
||||
if (getDataReady()) {
|
||||
const char * s = m_inputBuffer.c_str();
|
||||
cout << s << '\n';
|
||||
m_inputBuffer = "";
|
||||
setDataReady(FALSE);
|
||||
return s;
|
||||
}
|
||||
else {
|
||||
return NULL; // No data ready
|
||||
}
|
||||
}
|
||||
|
||||
/*char CConsole::getChar() {
|
||||
if (m_numInputChars) {
|
||||
char c = m_inputBuffer[m_bufStart++];
|
||||
if (m_bufStart >= INPUTSIZE) {
|
||||
m_bufStart = 0;
|
||||
m_numInputChars--;
|
||||
} // if
|
||||
} // if
|
||||
} // getChar()*/
|
||||
|
||||
void CConsole::setCursorPos(int x, int y) {
|
||||
m_print_x = x;
|
||||
m_print_y = y;
|
||||
}
|
||||
|
||||
int CConsole::getRows() {
|
||||
return m_rows;
|
||||
}
|
||||
|
||||
int CConsole::getCols() {
|
||||
return m_cols;
|
||||
}
|
||||
|
||||
double * CConsole::getColor() {
|
||||
return m_charColor;
|
||||
}
|
||||
|
||||
void CConsole::setColor(double red, double green, double blue) {
|
||||
m_charColor[0] = red;
|
||||
m_charColor[1] = green;
|
||||
m_charColor[2] = blue;
|
||||
}
|
||||
|
||||
CPvvmudClient * CConsole::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
int CConsole::changeInputMode() {
|
||||
if(m_state)
|
||||
m_state = 0;
|
||||
else {
|
||||
m_visible = TRUE;
|
||||
m_state = 1;
|
||||
m_input_x = 0;
|
||||
m_input_y = m_cols - 1;
|
||||
} // else
|
||||
for(int i=0;i<getRows();i++) {
|
||||
m_console[m_input_y*getRows()+i]=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CConsole::getInputMode() {
|
||||
return m_state;
|
||||
}
|
||||
|
||||
int CConsole::setVisible() {
|
||||
m_visible = (m_visible) ? 0 : 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CConsole::isVisible() {
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
void CConsole::setEcho(BOOL e) {
|
||||
m_echo = e;
|
||||
}
|
||||
|
||||
BOOL CConsole::getEcho() {
|
||||
return m_echo;
|
||||
}
|
||||
|
||||
void CConsole::setDataReady(BOOL d) {
|
||||
m_dataReady = d;
|
||||
}
|
||||
|
||||
BOOL CConsole::getDataReady() {
|
||||
return m_dataReady;
|
||||
}
|
||||
|
||||
|
||||
|
95
client/renderer/console.H
Normal file
95
client/renderer/console.H
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef CCONSOLE_H
|
||||
#define CCONSOLE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class CPvvmudClient;
|
||||
|
||||
//class CConsoleCursor {
|
||||
|
||||
|
||||
class CConsole {
|
||||
int m_cols; // Number of columns
|
||||
int m_rows; // Number of rows
|
||||
int m_state; // State variable
|
||||
int m_visible;
|
||||
int num_msgs; // Number of messages printed on console
|
||||
BOOL m_echo;
|
||||
BOOL m_dataReady;
|
||||
CPvvmudClient * m_client;
|
||||
|
||||
protected:
|
||||
char * m_console;
|
||||
string m_inputBuffer;
|
||||
int m_numInputChars;
|
||||
int m_bufStart;
|
||||
double * m_charColor;
|
||||
int m_screen_x; // Startpoint (in screen coordinates)
|
||||
int m_screen_y;
|
||||
int m_print_x; // Position for writing
|
||||
int m_print_y;
|
||||
int m_input_x; // Position for echo
|
||||
int m_input_y;
|
||||
void setDataReady(BOOL d=TRUE);
|
||||
void scrollMsgs();
|
||||
|
||||
public:
|
||||
const int INPUTSIZE = 80;
|
||||
CConsole(CPvvmudClient * cli);
|
||||
CConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
virtual ~CConsole();
|
||||
|
||||
|
||||
virtual void drawText();
|
||||
virtual void addMsg(char * msg);
|
||||
int printLine(char * string);
|
||||
int print(char * string);
|
||||
int printChar(char c);
|
||||
void printMsg(char * msg);
|
||||
void echoChar(char c);
|
||||
void clear();
|
||||
void scroll(int lines);
|
||||
virtual void keyboardInput(char k);
|
||||
|
||||
const char * getLine();
|
||||
void setCursorPos(int x, int y);
|
||||
int getRows();
|
||||
int getCols();
|
||||
double * getColor();
|
||||
void setColor(double red, double green, double blue);
|
||||
CPvvmudClient * getClient();
|
||||
int changeInputMode();
|
||||
int getInputMode();
|
||||
int setVisible();
|
||||
int isVisible();
|
||||
void setEcho(BOOL e);
|
||||
BOOL getEcho();
|
||||
BOOL getDataReady();
|
||||
};
|
||||
|
||||
#endif // CCONSOLE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
115
client/renderer/glconsole.C
Normal file
115
client/renderer/glconsole.C
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glconsole.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
GLubyte CGLConsole::m_cursor[13] = {
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff,
|
||||
0xff};
|
||||
|
||||
|
||||
|
||||
CGLConsole::CGLConsole(CPvvmudClient * cli) : CConsole(cli) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
}
|
||||
|
||||
CGLConsole::CGLConsole(CPvvmudClient * cli, int rows, int cols) : CConsole(cli, rows, cols) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
setCursorPos(1, 10);
|
||||
}
|
||||
CGLConsole::~CGLConsole() {
|
||||
}
|
||||
|
||||
CGLConsole::drawString(char *string) {
|
||||
int len,t;
|
||||
t = 0;
|
||||
len = getRows();
|
||||
while (t < len && string[t] != '\n') {
|
||||
if (string[t] != 0) {
|
||||
glutBitmapCharacter(m_font,string[t]);
|
||||
}
|
||||
t++;
|
||||
} // while
|
||||
//cout << '\n';
|
||||
}
|
||||
|
||||
void CGLConsole::drawText() {
|
||||
int x, y;
|
||||
// Kode for <20> tegna opp tekstkonsoll
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
// Darken background
|
||||
|
||||
glLoadIdentity();
|
||||
GLdouble dark[4] = {0.0, 0.0, 0.0, 0.5};
|
||||
//glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0);
|
||||
//CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
//viewpoint->transform();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4dv(dark);
|
||||
glVertex3f(-300, -300, 0.5);
|
||||
glVertex3f(-300, 300, 0.5);
|
||||
glVertex3f(300, 300, 0.5);
|
||||
glVertex3f(300, -300, 0.5);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-0.5,getClient()->getGUI()->getWidth() ,-0.5,getClient()->getGUI()->getHeight(),-1.0,1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glColor3dv(m_charColor);
|
||||
x = m_screen_x;
|
||||
y = m_screen_y;
|
||||
for (int i=0;i<getCols();i++) {
|
||||
glRasterPos2i(x, y);
|
||||
drawString(&m_console[i*getRows()]);
|
||||
y-=13;
|
||||
} // for
|
||||
// Draw cursor
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (getInputMode()) {
|
||||
glRasterPos2i(m_screen_x + (8*m_input_x), m_screen_y - (13*(m_input_y+1)));
|
||||
glBitmap(8, 13, 0.0, 0.0, 0.0, 0.0, m_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
client/renderer/glconsole.H
Normal file
39
client/renderer/glconsole.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 CGLCONSOLE_H
|
||||
#define CGLCONSOLE_H
|
||||
#include <GL/glut.h>
|
||||
#include "console.H"
|
||||
|
||||
class CGLConsole : public CConsole {
|
||||
|
||||
void *m_font;
|
||||
drawString(char *string);
|
||||
public:
|
||||
static GLubyte m_cursor[13];
|
||||
|
||||
CGLConsole(CPvvmudClient * cli);
|
||||
CGLConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
~CGLConsole();
|
||||
|
||||
virtual void drawText();
|
||||
};
|
||||
|
||||
#endif // CGLCONSOLE_H
|
219
client/renderer/glgeometry.C
Normal file
219
client/renderer/glgeometry.C
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* 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 "glgeometry.H"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Constructor for ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CGLGeometry::CGLGeometry( int objectGeometryId )
|
||||
:CGeometry( objectGeometryId )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CGLGeometry::CGLGeometry( int objectGeometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons )
|
||||
:CGeometry( objectGeometryId, numVertices, numNormals,
|
||||
numTexCoords, numPolygons)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Destructor for ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
CGLGeometry::~CGLGeometry(){
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Draw ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int CGLGeometry::draw( CMaterialCache * matCache,
|
||||
CTextureCache * texCache ){
|
||||
|
||||
int pp,ii;
|
||||
CPolygon * polygon;
|
||||
CIntArray *normalIndex,*vertexIndex,*texCoordIndex;
|
||||
int numVertex, numNormal, numTexCoord;
|
||||
// CNormal * normal;
|
||||
// CVertex * vertex;
|
||||
// CTexCoord * texCoord;
|
||||
CMaterial * mat;
|
||||
|
||||
for (pp = 0; pp < this->polygonList->getNumElements(); pp ++){
|
||||
|
||||
polygon = this->polygonList->get( pp );
|
||||
numVertex = polygon->getVertexIList()->getNumElements();
|
||||
numNormal = polygon->getNormalIList()->getNumElements();
|
||||
numTexCoord = polygon->getTexCoordIList()->getNumElements();
|
||||
mat = matCache->get( polygon->getMaterial() );
|
||||
if (mat == NULL){
|
||||
mat = matCache->get( 0 );
|
||||
// cdebug(stderr,"Using default material %i for object %i\n",polygon->getMaterial(),id);
|
||||
}
|
||||
if (mat != NULL) mat->exec( texCache );
|
||||
// else cdebug(stderr,"Failed to find material!\n");
|
||||
|
||||
vertexIndex = polygon->getVertexIList();//->getIndex();
|
||||
normalIndex = polygon->getNormalIList();//->getIndex();
|
||||
texCoordIndex = polygon->getTexCoordIList();//->getIndex();
|
||||
//vertex = this->vertexList->getVertex();
|
||||
//normal = this->normalList->getNormal();
|
||||
//texCoord = this->texCoordList->getTexCoord();
|
||||
|
||||
glBegin( (GLenum)polygon->getType() );
|
||||
|
||||
switch ( polygon->getType() ){
|
||||
case POLYGON_POLYGON:
|
||||
case POLYGON_QUAD_STRIP:
|
||||
case POLYGON_TRIANGLE_STRIP:
|
||||
case POLYGON_TRIANGLE_FAN:
|
||||
|
||||
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
// No texture coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for object
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
glNormal3dv(normalList->get(0));
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
// No texture coordinates
|
||||
glNormal3dv(normalList->get(0));
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON_QUADS:
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numNormal == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for each quad
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%4 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/4)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%4 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/4)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON_TRIANGLES:
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for each triangle
|
||||
if (numVertex == numNormal){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%3 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/3)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%3 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/3)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
glEnd( );
|
||||
|
||||
}
|
||||
|
||||
if (next != NULL) {
|
||||
next->draw( matCache, texCache );
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
37
client/renderer/glgeometry.H
Normal file
37
client/renderer/glgeometry.H
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLGEOMETRY_H
|
||||
#define _GLGEOMETRY_H
|
||||
|
||||
#include "geometry.H"
|
||||
|
||||
|
||||
class CGLGeometry : public CGeometry{
|
||||
|
||||
public:
|
||||
CGLGeometry(int objectGeometryId);
|
||||
CGLGeometry(int objectGeometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons);
|
||||
virtual ~CGLGeometry();
|
||||
virtual int draw( CMaterialCache * matCache, CTextureCache * texCache );
|
||||
|
||||
};
|
||||
|
||||
#endif /* _GLGEOMETRY_H */
|
63
client/renderer/glmaterial.C
Normal file
63
client/renderer/glmaterial.C
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GL/gl.h>
|
||||
#include <iostream.h>
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "glmaterial.H"
|
||||
|
||||
|
||||
CGLMaterial::CGLMaterial():CMaterial(){
|
||||
}
|
||||
|
||||
CGLMaterial::CGLMaterial(int materialId):CMaterial(materialId){
|
||||
}
|
||||
|
||||
int CGLMaterial::exec(CTextureCache * texCache){
|
||||
CTexture * tex;
|
||||
if (getTextureId() != -1){
|
||||
if ((tex = texCache->get(getTextureId()))== NULL){
|
||||
if ((tex = texCache->get(0)) == NULL){
|
||||
cdebug << "Failed to find texture!\n";
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
cdebug << "Using default texture for id " << getTextureId() << "\n";
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
tex->exec();
|
||||
}
|
||||
} else {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
tex->exec();
|
||||
}
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, m_ambient );
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, m_diffuse );
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, m_specular );
|
||||
glMaterialfv(GL_FRONT, GL_SHININESS, m_shininess );
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, m_emission );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
38
client/renderer/glmaterial.H
Normal file
38
client/renderer/glmaterial.H
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLMATERIAL_H
|
||||
#define _GLMATERIAL_H
|
||||
|
||||
#include "material.H"
|
||||
|
||||
#define MAT_NOTEXTURE -1
|
||||
|
||||
|
||||
class CGLMaterial : public CMaterial {
|
||||
public:
|
||||
CGLMaterial();
|
||||
CGLMaterial(int materialId);
|
||||
|
||||
virtual ~CGLMaterial() {}
|
||||
|
||||
virtual int exec(CTextureCache * texCache);
|
||||
};
|
||||
|
||||
#endif /* _GLMATERIAL_H */
|
188
client/renderer/glrenderer.C
Normal file
188
client/renderer/glrenderer.C
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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 <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glrenderer.H"
|
||||
#include "cliviewpoint.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
COGLRenderer::COGLRenderer(CPvvmudClient * cli) : CRenderer(cli) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
{
|
||||
GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
|
||||
GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
GLfloat ambient[4] = {0.4, 0.4, 0.4, 1.0};
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, gray);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient);
|
||||
}
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
// glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
COGLRenderer::~COGLRenderer(){
|
||||
}
|
||||
|
||||
void COGLRenderer::prepareDraw(CWorldObject * object) {
|
||||
if (m_mode == GL_SELECT) {
|
||||
glLoadName(object->getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
void COGLRenderer::draw() {
|
||||
GLfloat light_position[4] = { 0.0, 0.5, 1.0, 0.0 };
|
||||
|
||||
glLoadIdentity();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
glClearColor(0.5,0.5,0.9,1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
viewpoint->transform();
|
||||
|
||||
|
||||
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
|
||||
|
||||
getClient()->getManager()->animate();
|
||||
getClient()->getManager()->draw(this);
|
||||
|
||||
glPopMatrix();
|
||||
if (getConsole()->isVisible()) {
|
||||
getConsole()->drawText();
|
||||
}
|
||||
glFlush();
|
||||
|
||||
// Moved to pvvmudclient->pollConsole()
|
||||
// const char * s = getConsole()->getLine();
|
||||
// if (s != NULL) {
|
||||
// getClient()->getManager()->sendMsg(s);
|
||||
// }
|
||||
|
||||
getClient()->getGUI()->reshape(getClient()->getGUI()->getWidth(), getClient()->getGUI()->getHeight());
|
||||
|
||||
}
|
||||
|
||||
void COGLRenderer::transform(CPosition &pos, CDirection &dir) {
|
||||
const double * position = pos.getVector();
|
||||
const double * direction = dir.getVector();
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslated(position[0],position[1],position[2]);
|
||||
glRotated(direction[2],1,0,0);
|
||||
glRotated(direction[1],0,1,0);
|
||||
glRotated(direction[0],0,0,1);
|
||||
}
|
||||
|
||||
void COGLRenderer::reshape(int width, int height) {
|
||||
getClient()->getGUI()->setWidth(width);
|
||||
getClient()->getGUI()->setHeight(height);
|
||||
GLfloat aspectViewport = (GLfloat) height / (GLfloat) width;
|
||||
setAspectViewport(aspectViewport);
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-0.1, 0.1, -0.1*aspectViewport, 0.1*aspectViewport, 0.2, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void COGLRenderer::postDraw() {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
#define SELECTBUFSIZE 1024
|
||||
|
||||
void COGLRenderer::mousePick(int x, int y) {
|
||||
cdebug << "Mouse pick " << x << " " << y << "\n";
|
||||
|
||||
GLuint selectBuf[SELECTBUFSIZE];
|
||||
GLint hits;
|
||||
GLint viewport[4];
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
glSelectBuffer(SELECTBUFSIZE, selectBuf);
|
||||
glRenderMode(GL_SELECT);
|
||||
|
||||
glInitNames();
|
||||
glPushName((GLuint)(-1));
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluPickMatrix(x,viewport[3]-y,1.0,1.0,viewport);
|
||||
glFrustum(-0.1, 0.1, -0.1*m_aspectViewport, 0.1*m_aspectViewport, 0.2, 1000.0);
|
||||
setMode(GL_SELECT);
|
||||
draw();
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glFlush();
|
||||
|
||||
hits = glRenderMode(GL_RENDER);
|
||||
getClient()->getInputFunction()->processHits(hits, selectBuf);
|
||||
}
|
||||
|
||||
GLfloat COGLRenderer::getAspectViewport() {
|
||||
return m_aspectViewport;
|
||||
}
|
||||
|
||||
void COGLRenderer::setAspectViewport(GLfloat av) {
|
||||
m_aspectViewport = av;
|
||||
}
|
||||
|
||||
void COGLRenderer::setMode(GLenum mode) {
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
void COGLRenderer::dumpScreen(char * texFileName){
|
||||
GLint viewport[4];
|
||||
int width,height;
|
||||
|
||||
BYTE *data;
|
||||
CTexture * texture = new CTexture();
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT,viewport);
|
||||
|
||||
width = viewport[2];
|
||||
height = viewport[3];
|
||||
|
||||
data = (BYTE*)malloc(width*height*4*sizeof(BYTE));
|
||||
|
||||
glReadPixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)data);
|
||||
|
||||
texture->setTextureMap(new CTextureMap(width,height,data));
|
||||
texture->save(texFileName);
|
||||
delete texture;
|
||||
}
|
||||
|
||||
|
46
client/renderer/glrenderer.H
Normal file
46
client/renderer/glrenderer.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 _GLRENDERER_H
|
||||
#define _GLRENDERER_H
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include "renderer.H"
|
||||
class COGLRenderer : public CRenderer {
|
||||
GLenum m_mode;
|
||||
GLfloat m_aspectViewport;
|
||||
|
||||
public:
|
||||
COGLRenderer(CPvvmudClient * cli);
|
||||
virtual ~COGLRenderer();
|
||||
virtual void prepareDraw(CWorldObject * object);
|
||||
virtual void transform(CPosition &pos, CDirection &dir);
|
||||
virtual void draw();
|
||||
virtual void postDraw();
|
||||
virtual void mousePick(int x, int y);
|
||||
virtual void reshape(int width, int height);
|
||||
GLfloat getAspectViewport();
|
||||
void setAspectViewport(GLfloat av);
|
||||
void setMode(GLenum mode);
|
||||
|
||||
virtual void dumpScreen(char * texFileName);
|
||||
|
||||
};
|
||||
|
||||
#endif // _GLRENDERER_H
|
116
client/renderer/glsrvcliconsole.C
Normal file
116
client/renderer/glsrvcliconsole.C
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glsrvcliconsole.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
GLubyte CGLSrvCliConsole::m_cursor[13] = {
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff,
|
||||
0xff};
|
||||
|
||||
|
||||
|
||||
CGLSrvCliConsole::CGLSrvCliConsole(CPvvmudClient * cli) : CSrvCliConsole(cli) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
}
|
||||
|
||||
CGLSrvCliConsole::CGLSrvCliConsole(CPvvmudClient * cli, int rows, int cols) : CSrvCliConsole(cli, rows, cols) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
setCursorPos(1, 10);
|
||||
}
|
||||
CGLSrvCliConsole::~CGLSrvCliConsole() {
|
||||
}
|
||||
|
||||
CGLSrvCliConsole::drawString(char *string) {
|
||||
int len,t;
|
||||
t = 0;
|
||||
len = getRows();
|
||||
while (t < len && string[t] != '\n') {
|
||||
if (string[t] != 0) {
|
||||
glutBitmapCharacter(m_font,string[t]);
|
||||
}
|
||||
t++;
|
||||
} // while
|
||||
//cout << '\n';
|
||||
}
|
||||
|
||||
void CGLSrvCliConsole::drawText() {
|
||||
int x, y;
|
||||
//printMsgs();
|
||||
// Kode for <20> tegna opp tekstkonsoll
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
// Darken background
|
||||
|
||||
glLoadIdentity();
|
||||
GLdouble dark[4] = {0.0, 0.0, 0.0, 0.5};
|
||||
//glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0);
|
||||
//CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
//viewpoint->transform();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4dv(dark);
|
||||
glVertex3f(-300, -300, 0.5);
|
||||
glVertex3f(-300, 300, 0.5);
|
||||
glVertex3f(300, 300, 0.5);
|
||||
glVertex3f(300, -300, 0.5);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-0.5,getClient()->getGUI()->getWidth() ,-0.5,getClient()->getGUI()->getHeight(),-1.0,1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glColor3dv(m_charColor);
|
||||
x = m_screen_x;
|
||||
y = m_screen_y;
|
||||
for (int i=0;i<getCols();i++) {
|
||||
glRasterPos2i(x, y);
|
||||
drawString(&m_console[i*getRows()]);
|
||||
y-=13;
|
||||
} // for
|
||||
// Draw cursor
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (getInputMode()) {
|
||||
glRasterPos2i(m_screen_x + (8*m_input_x), m_screen_y - (13*(m_input_y+1)));
|
||||
glBitmap(8, 13, 0.0, 0.0, 0.0, 0.0, m_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
client/renderer/glsrvcliconsole.H
Normal file
39
client/renderer/glsrvcliconsole.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 CGLSRVCLICONSOLE_H
|
||||
#define CGLSRVCLICONSOLE_H
|
||||
#include <GL/glut.h>
|
||||
#include "srvcliconsole.H"
|
||||
|
||||
class CGLSrvCliConsole : public CSrvCliConsole {
|
||||
|
||||
void *m_font;
|
||||
drawString(char *string);
|
||||
public:
|
||||
static GLubyte m_cursor[13];
|
||||
|
||||
CGLSrvCliConsole(CPvvmudClient * cli);
|
||||
CGLSrvCliConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
~CGLSrvCliConsole();
|
||||
|
||||
virtual void drawText();
|
||||
};
|
||||
|
||||
#endif // CGLSRVCLICONSOLE_H
|
146
client/renderer/gltexture.C
Normal file
146
client/renderer/gltexture.C
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "gltexture.H"
|
||||
|
||||
#ifdef HAVE_GL_GLUT_H
|
||||
#include <GL/glut.h>
|
||||
#endif /* HAVE_GL_GLUT_H */
|
||||
|
||||
static GLboolean HaveTexObj = GL_FALSE;
|
||||
|
||||
#if defined(GL_VERSION_1_1)
|
||||
# define TEXTURE_OBJECT 1
|
||||
#elif defined(GL_EXT_texture_object)
|
||||
# define TEXTURE_OBJECT 1
|
||||
# define glBindTexture(A,B) glBindTextureEXT(A,B)
|
||||
# define glGenTextures(A,B) glGenTexturesEXT(A,B)
|
||||
# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B)
|
||||
#endif
|
||||
|
||||
void GLTexture_Init(){
|
||||
/* check that renderer has the GL_EXT_texture_object extension
|
||||
* or supports OpenGL 1.1
|
||||
*/
|
||||
#ifdef TEXTURE_OBJECT
|
||||
char *exten = (char *) glGetString( GL_EXTENSIONS );
|
||||
char *version = (char *) glGetString( GL_VERSION );
|
||||
if ( strstr( exten, "GL_EXT_texture_object" )
|
||||
|| strncmp( version, "1.1", 3 )==0 ) {
|
||||
HaveTexObj = GL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Construct texture with given id
|
||||
*
|
||||
*****************************************************************************/
|
||||
CGLTexture::CGLTexture(int textureId):CTexture(textureId){
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Destruct texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CGLTexture::~CGLTexture(){
|
||||
|
||||
#ifdef TEXTURE_OBJECT
|
||||
if (loaded())
|
||||
glDeleteTextures( 1, &texObj );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Set texturemap to use with texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void CGLTexture::setTextureMap(CTextureMap * textureMap){
|
||||
|
||||
/* generate texture object IDs */
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glGenTextures( 1, &texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
texObj = glGenLists(1);
|
||||
}
|
||||
/* setup texture object */
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glBindTexture( GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glNewList( texObj, GL_COMPILE );
|
||||
}
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, 4, textureMap->getWidth(),
|
||||
textureMap->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
textureMap->getData() );
|
||||
if (!HaveTexObj) {
|
||||
glEndList();
|
||||
}
|
||||
/* end of texture object */
|
||||
|
||||
CTexture::setTextureMap(textureMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Exec texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int CGLTexture::exec(){
|
||||
|
||||
if (!loaded()) return FALSE;
|
||||
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glBindTexture( GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glCallList( texObj );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
56
client/renderer/gltexture.H
Normal file
56
client/renderer/gltexture.H
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 _GLTEXTURE_H
|
||||
#define _GLTEXTURE_H
|
||||
|
||||
#include "mudtypes.h"
|
||||
#include "texture.H"
|
||||
|
||||
#ifdef HAVE_GL_GL_H
|
||||
#include <GL/glut.h>
|
||||
typedef GLuint TexObj_t;
|
||||
#else /* HAVE_GL_GL_H */
|
||||
typedef unsigned int TexObj_t;
|
||||
#endif /* HAVE_GL_GL_H */
|
||||
|
||||
#define TEX_STATE_LOADED 0x0001
|
||||
|
||||
void GLTexture_Init();
|
||||
|
||||
class CGLTexture : public CTexture {
|
||||
TexObj_t texObj;
|
||||
|
||||
public:
|
||||
CGLTexture();
|
||||
CGLTexture(int id);
|
||||
~CGLTexture();
|
||||
virtual void setTextureMap(CTextureMap * textureMap);
|
||||
virtual int exec();
|
||||
};
|
||||
|
||||
#endif /* _GLTEXTURE_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
65
client/renderer/renderer.C
Normal file
65
client/renderer/renderer.C
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
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "renderer.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CRenderer::CRenderer(CPvvmudClient * c) {
|
||||
m_client = c;
|
||||
}
|
||||
|
||||
CRenderer::~CRenderer(){
|
||||
}
|
||||
|
||||
CPvvmudClient * CRenderer::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CConsole * CRenderer::getConsole() {
|
||||
return m_console;
|
||||
}
|
||||
|
||||
void CRenderer::setConsole(CConsole * console) {
|
||||
m_console = console;
|
||||
}
|
||||
|
||||
void CRenderer::prepareDraw(CWorldObject * object){
|
||||
}
|
||||
|
||||
void CRenderer::transform(CPosition &pos, CDirection &dir){
|
||||
}
|
||||
|
||||
void CRenderer::draw(){
|
||||
}
|
||||
|
||||
void CRenderer::postDraw(){
|
||||
}
|
||||
|
||||
void CRenderer::mousePick(int x, int y){
|
||||
}
|
||||
|
||||
void CRenderer::reshape(int width, int height) {
|
||||
}
|
||||
|
||||
void CRenderer::dumpScreen(char * texFileName){
|
||||
}
|
||||
|
||||
|
||||
|
45
client/renderer/renderer.H
Normal file
45
client/renderer/renderer.H
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _RENDERER_H
|
||||
#define _RENDERER_H
|
||||
#include "worldobject.H"
|
||||
#include "console.H"
|
||||
|
||||
class CPvvmudClient;
|
||||
class CRenderer {
|
||||
CPvvmudClient * m_client;
|
||||
CConsole * m_console;
|
||||
|
||||
public:
|
||||
CRenderer(CPvvmudClient * c);
|
||||
virtual ~CRenderer();
|
||||
CPvvmudClient * getClient();
|
||||
CConsole * getConsole();
|
||||
void setConsole(CConsole * console);
|
||||
virtual void prepareDraw(CWorldObject * object);
|
||||
virtual void transform(CPosition &pos, CDirection &dir);
|
||||
virtual void draw();
|
||||
virtual void postDraw();
|
||||
virtual void mousePick(int x, int y);
|
||||
virtual void reshape(int width, int height);
|
||||
virtual void dumpScreen(char * texFileName);
|
||||
};
|
||||
|
||||
#endif // _RENDERER_H
|
185
client/renderer/srvcliconsole.C
Normal file
185
client/renderer/srvcliconsole.C
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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 <fstream>
|
||||
#include <malloc.h>
|
||||
#include "pvvmud.H"
|
||||
#include "srvcliconsole.H"
|
||||
#include "string.h"
|
||||
|
||||
const char * CSrvCliConsole::HISTORY_FILE = ".pvvmud_history";
|
||||
|
||||
|
||||
CSrvCliConsole::CSrvCliConsole(CPvvmudClient * cli) : CConsole(cli) {
|
||||
m_numMsgs = 0;
|
||||
m_historyPos = 0;
|
||||
m_consSize = getCols()-1;
|
||||
loadHistory();
|
||||
}
|
||||
|
||||
CSrvCliConsole::CSrvCliConsole(CPvvmudClient * cli, int cols, int rows) : CConsole(cli, cols, rows) {
|
||||
m_numMsgs = 0;
|
||||
m_historyPos = 0;
|
||||
m_consSize = getCols()-1;
|
||||
loadHistory();
|
||||
}
|
||||
|
||||
void CSrvCliConsole::drawText() {
|
||||
}
|
||||
|
||||
int CSrvCliConsole::getNumMsgs() {
|
||||
return m_numMsgs;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::setNumMsgs(int num) {
|
||||
m_numMsgs = num;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::addMsg(char * msg) {
|
||||
string s = msg;
|
||||
if (m_numMsgs >= m_consSize) {
|
||||
m_messages.erase(m_messages.begin());
|
||||
}
|
||||
m_messages.push_back(msg);
|
||||
m_numMsgs++;
|
||||
printMsgs();
|
||||
}
|
||||
|
||||
void CSrvCliConsole::printMsgs() {
|
||||
const char * c;
|
||||
clear();
|
||||
for (int i=0;i<m_messages.size();i++) {
|
||||
c = m_messages[i].c_str();
|
||||
print((char *)c);
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvCliConsole::loadHistory() {
|
||||
ifstream * file = new ifstream(HISTORY_FILE);
|
||||
if (!file) {
|
||||
cout << "Error\n";
|
||||
exit(0);
|
||||
} // if
|
||||
filebuf * fb = file->rdbuf();
|
||||
char * buf = (char*)malloc(80);
|
||||
char c = 0;
|
||||
int i = 0;
|
||||
while(file->get(c)) {
|
||||
if (i >= 80 || c == '\n') {
|
||||
string s = string(buf);
|
||||
//cout << s;
|
||||
m_history.push_back(s);
|
||||
m_historyPos++;
|
||||
i = 0;
|
||||
memset(buf, 0, 80);
|
||||
} // if
|
||||
else {
|
||||
buf[i++] = c;
|
||||
} // else
|
||||
} // while
|
||||
file->close();
|
||||
free(buf);
|
||||
delete file;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::saveHistory() {
|
||||
ofstream * file = new ofstream(HISTORY_FILE);
|
||||
filebuf * fb = file->rdbuf();
|
||||
for (int i=0;i<m_history.size();i++) {
|
||||
fb->sputn(m_history[i].c_str(), m_history[i].size());
|
||||
fb->sputc('\n');
|
||||
} // for
|
||||
file->close();
|
||||
delete file;
|
||||
}
|
||||
void CSrvCliConsole::keyboardInput(char k) {
|
||||
switch (k) {
|
||||
case KEY_UP:
|
||||
m_input_x = 0;
|
||||
m_inputBuffer = "";
|
||||
clear();
|
||||
printMsgs();
|
||||
if (m_historyPos > -1) {
|
||||
m_historyPos--;
|
||||
if (m_historyPos > -1) {
|
||||
m_inputBuffer = m_history[m_historyPos];
|
||||
if (getEcho()) {
|
||||
char c;
|
||||
int i = 0;
|
||||
const char * cstr = m_inputBuffer.c_str();
|
||||
while (c = cstr[i]) {
|
||||
echoChar(c);
|
||||
i++;
|
||||
} // while
|
||||
} // if
|
||||
} // if
|
||||
} // if
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
m_input_x = 0;
|
||||
m_inputBuffer = "";
|
||||
clear();
|
||||
printMsgs();
|
||||
if (m_historyPos == -1 || m_historyPos < m_history.size()) { // Stygt hack
|
||||
m_historyPos++;
|
||||
if (m_historyPos < m_history.size()) {
|
||||
m_inputBuffer = m_history[m_historyPos];
|
||||
if (getEcho()) {
|
||||
char c;
|
||||
int i = 0;
|
||||
const char * cstr = m_inputBuffer.c_str();
|
||||
while (c = cstr[i]) {
|
||||
echoChar(c);
|
||||
i++;
|
||||
} // while
|
||||
} // if
|
||||
} // if
|
||||
else {
|
||||
m_inputBuffer = "";
|
||||
m_input_x = 0;
|
||||
} // else
|
||||
}
|
||||
break;
|
||||
case '\r':
|
||||
changeInputMode();
|
||||
m_historyPos = m_history.size();
|
||||
if (m_inputBuffer != "") {
|
||||
setDataReady();
|
||||
m_history.push_back(m_inputBuffer);
|
||||
m_historyPos++;
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
if (m_inputBuffer != "") {
|
||||
m_inputBuffer.erase(m_inputBuffer.end()-1);
|
||||
if (getEcho()) {
|
||||
m_input_x--;
|
||||
m_console[m_input_y * getRows() + m_input_x] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (getEcho()) {
|
||||
echoChar(k);
|
||||
}
|
||||
m_inputBuffer += k;
|
||||
}
|
||||
}
|
||||
|
||||
|
52
client/renderer/srvcliconsole.H
Normal file
52
client/renderer/srvcliconsole.H
Normal 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
|
||||
*
|
||||
*/
|
||||
#ifndef SRVCLICONSOLE_H
|
||||
#define SRVCLICONSOLE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "console.H"
|
||||
|
||||
// Subclass of CConsole for printing messages recieved from server and other clients
|
||||
class CSrvCliConsole : public CConsole {
|
||||
static const char * HISTORY_FILE;
|
||||
int m_consSize;
|
||||
int m_numMsgs;
|
||||
typedef vector<string> msg_t;
|
||||
msg_t m_messages;
|
||||
msg_t m_history;
|
||||
int m_historyPos;
|
||||
public:
|
||||
CSrvCliConsole(CPvvmudClient * cli);
|
||||
CSrvCliConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
|
||||
virtual void drawText();
|
||||
virtual void addMsg(char * msg);
|
||||
int getNumMsgs();
|
||||
void setNumMsgs(int num);
|
||||
void updateConsole();
|
||||
void printMsgs();
|
||||
void loadHistory();
|
||||
void saveHistory();
|
||||
virtual void keyboardInput(char k);
|
||||
|
||||
};
|
||||
|
||||
#endif // SRVCLICONSOLE_H
|
70
client/stdinput.C
Normal file
70
client/stdinput.C
Normal 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 "stdinput.H"
|
||||
#include <malloc.h>
|
||||
#include <iostream.h>
|
||||
// Setter standard bufferst<73>rrelse
|
||||
CStdInput::CStdInput() {
|
||||
m_bufsize = m_BUFFERSIZE = 20; // Standard bufferst<73>rrelse er 20 tegn
|
||||
m_buffer = (char*)malloc(m_BUFFERSIZE);
|
||||
m_sysbuffer = (char*)malloc(10);
|
||||
//cin.rdbuf()->setbuf(m_sysbuffer, 10);
|
||||
}
|
||||
|
||||
// Angir bufferst<73>rrelse eksplisitt
|
||||
CStdInput::CStdInput(int bufsize) {
|
||||
m_bufsize = m_BUFFERSIZE = bufsize;
|
||||
m_buffer = (char*)malloc(m_BUFFERSIZE);
|
||||
m_sysbuffer = (char*)malloc(10);
|
||||
//cin.rdbuf()->setbuf(m_sysbuffer, 10);
|
||||
}
|
||||
|
||||
CStdInput::~CStdInput() {
|
||||
if (m_buffer != NULL) {
|
||||
free(m_buffer);
|
||||
}
|
||||
free (m_sysbuffer);
|
||||
}
|
||||
|
||||
// Sjekker standard input
|
||||
CStdInput::poll() {
|
||||
}
|
||||
|
||||
CStdInput::addChar(char c) {
|
||||
if (m_numchars < m_bufsize) {
|
||||
// More room in buffer, add char
|
||||
m_buffer[m_numchars++] = c;
|
||||
}
|
||||
else {
|
||||
// Increase buffer size
|
||||
m_buffer = (char*)realloc(m_buffer, m_bufsize+m_BUFFERSIZE);
|
||||
m_buffer[m_numchars++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
CStdInput::sendMsg() {
|
||||
cout << m_buffer;
|
||||
free(m_buffer);
|
||||
m_buffer = (char*)malloc(m_BUFFERSIZE);
|
||||
m_bufsize = m_BUFFERSIZE;
|
||||
m_numchars = 0;
|
||||
}
|
||||
|
||||
|
41
client/stdinput.H
Normal file
41
client/stdinput.H
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _STDINPUT_H_
|
||||
#define _STDINPUT_H_
|
||||
// Class to read from standard input (i.e. an xterm) and send the information
|
||||
// to the server
|
||||
class CStdInput {
|
||||
int m_BUFFERSIZE; // initiell bufferst<73>rrelse, og ant. bytest bufferet skal auke med kvar gong det blir fullt
|
||||
char * m_buffer;
|
||||
char * m_sysbuffer;
|
||||
int m_bufsize;
|
||||
int m_numchars;
|
||||
|
||||
public:
|
||||
CStdInput(int bufsize);
|
||||
CStdInput();
|
||||
~CStdInput();
|
||||
|
||||
poll();
|
||||
addChar(char c);
|
||||
sendMsg();
|
||||
};
|
||||
|
||||
#endif // _STDINPUT_H_
|
Reference in New Issue
Block a user