Recovered from microbel
This commit is contained in:
5
common/lib/world/Makefile.am
Normal file
5
common/lib/world/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I../../include
|
||||
|
||||
noinst_LIBRARIES = libworld.a
|
||||
|
||||
libworld_a_SOURCES = cellpvs.C listener.C msgworld.C waobject.C waupdateposition.C worldanimation.C worldobject.C worldworld.C waupdatedirection.C wacreateobject.C waremoveobject.C worldhierarchy.C waupdatehierarchy.C warotate.C
|
||||
335
common/lib/world/Makefile.in
Normal file
335
common/lib/world/Makefile.in
Normal file
@@ -0,0 +1,335 @@
|
||||
# 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../../include
|
||||
|
||||
noinst_LIBRARIES = libworld.a
|
||||
|
||||
libworld_a_SOURCES = cellpvs.C listener.C msgworld.C waobject.C waupdateposition.C worldanimation.C worldobject.C worldworld.C waupdatedirection.C wacreateobject.C waremoveobject.C worldhierarchy.C waupdatehierarchy.C warotate.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@
|
||||
libworld_a_LIBADD =
|
||||
libworld_a_OBJECTS = cellpvs.o listener.o msgworld.o waobject.o \
|
||||
waupdateposition.o worldanimation.o worldobject.o worldworld.o \
|
||||
waupdatedirection.o wacreateobject.o waremoveobject.o worldhierarchy.o \
|
||||
waupdatehierarchy.o warotate.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/cellpvs.P .deps/listener.P .deps/msgworld.P \
|
||||
.deps/wacreateobject.P .deps/waobject.P .deps/waremoveobject.P \
|
||||
.deps/warotate.P .deps/waupdatedirection.P .deps/waupdatehierarchy.P \
|
||||
.deps/waupdateposition.P .deps/worldanimation.P .deps/worldhierarchy.P \
|
||||
.deps/worldobject.P .deps/worldworld.P
|
||||
SOURCES = $(libworld_a_SOURCES)
|
||||
OBJECTS = $(libworld_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 common/lib/world/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:
|
||||
|
||||
libworld.a: $(libworld_a_OBJECTS) $(libworld_a_DEPENDENCIES)
|
||||
-rm -f libworld.a
|
||||
$(AR) cru libworld.a $(libworld_a_OBJECTS) $(libworld_a_LIBADD)
|
||||
$(RANLIB) libworld.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 = common/lib/world
|
||||
|
||||
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 common/lib/world/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:
|
||||
99
common/lib/world/cellpvs.C
Normal file
99
common/lib/world/cellpvs.C
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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 "cellpvs.H"
|
||||
#include "worldworld.H"
|
||||
#include "worldobject.H"
|
||||
|
||||
|
||||
|
||||
CPVCell::CPVCell(DWORD cellId, const CPosition & position){
|
||||
m_cellId = cellId;
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
|
||||
DWORD CPVCell::getCellId(){
|
||||
return m_cellId;
|
||||
}
|
||||
|
||||
CPosition CPVCell::getPosition(){
|
||||
return m_position;
|
||||
}
|
||||
|
||||
CCellPVS::CCellPVS(CWorldWorld * world){
|
||||
m_world = world;
|
||||
}
|
||||
|
||||
CWorldWorld * CCellPVS::getWorld(){
|
||||
return m_world;
|
||||
}
|
||||
|
||||
CPVCell* CCellPVS::addPVCell(DWORD cellId, const CPosition & position){
|
||||
CPVCell * pvCell = new CPVCell(cellId,position);
|
||||
addLast((CObject*)pvCell);
|
||||
return pvCell;
|
||||
}
|
||||
|
||||
CObjectListItem * CCellPVS::getFirstPVCell(){
|
||||
return getFirst();
|
||||
}
|
||||
|
||||
CPosition CCellPVS::getPVCellPosition(CWorldObject * cell){
|
||||
CPosition position;
|
||||
CObjectListItem * item = getFirstPVCell();
|
||||
while (item != NULL){
|
||||
CPVCell * pvCell = (CPVCell*)item->getObject();
|
||||
|
||||
if (pvCell->getCellId() == cell->getObjectId()){
|
||||
return pvCell->getPosition();
|
||||
}
|
||||
|
||||
item = item->getNext();
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
CWorldObject * CCellPVS::findCell(CPosition * position){
|
||||
|
||||
cdebug << "Check if pos : " << *position << "\n";
|
||||
|
||||
CObjectListItem * item = getFirstPVCell();
|
||||
while (item != NULL){
|
||||
CPVCell * pvCell = (CPVCell*)item->getObject();
|
||||
CWorldObject * cell;
|
||||
cell = getWorld()->getObject(pvCell->getCellId());
|
||||
|
||||
CPosition newpos = *position - pvCell->getPosition();
|
||||
|
||||
cdebug << "Check " << cell->getName() << " Pos : " << newpos << "\n";
|
||||
|
||||
if (cell->checkPosition(newpos)){
|
||||
*position = newpos;
|
||||
return cell;
|
||||
}
|
||||
|
||||
item = item->getNext();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
common/lib/world/listener.C
Normal file
26
common/lib/world/listener.C
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "listener.H"
|
||||
|
||||
CListener::CListener(){
|
||||
|
||||
}
|
||||
|
||||
341
common/lib/world/msgworld.C
Normal file
341
common/lib/world/msgworld.C
Normal file
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
* 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 "msgworld.H"
|
||||
#include "position.H"
|
||||
#include "direction.H"
|
||||
|
||||
/*
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgSection
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgSection::CMsgSection():CMessage(MSG_SECTION,sizeof(DWORD)+sizeof(BYTE)){
|
||||
setName("MsgSection");
|
||||
}
|
||||
|
||||
CMsgSection::CMsgSection( DWORD sectionId, BOOL create )
|
||||
:CMessage(MSG_SECTION,sizeof(DWORD) + sizeof(BYTE)){
|
||||
|
||||
setName("MsgSection");
|
||||
writeDWord(1,sectionId);
|
||||
writeByte(5,create);
|
||||
}
|
||||
|
||||
DWORD CMsgSection::getSectionId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
BOOL CMsgSection::getCreate(){
|
||||
return readByte(5);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgCell::CMsgCell():CMessage(MSG_CELL,5*sizeof(DWORD)){
|
||||
setName("MsgCell");
|
||||
}
|
||||
|
||||
CMsgCell::CMsgCell( DWORD cellId, DWORD geometryId,
|
||||
const CPosition & position):CMessage(MSG_CELL,5*sizeof(DWORD)){
|
||||
|
||||
setName("MsgCell");
|
||||
writeDWord(1,cellId);
|
||||
writeDWord(5,geometryId);
|
||||
writePosition(9,position);
|
||||
}
|
||||
|
||||
DWORD CMsgCell::getCellId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
DWORD CMsgCell::getGeometryId(){
|
||||
return readDWord(5);
|
||||
}
|
||||
|
||||
CPosition CMsgCell::getPosition(){
|
||||
return readPosition(9);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgRemoveCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgRemoveCell::CMsgRemoveCell():CMessage(MSG_REMOVECELL,1*sizeof(DWORD)){
|
||||
setName("MsgRemoveCell");
|
||||
}
|
||||
|
||||
CMsgRemoveCell::CMsgRemoveCell( DWORD cellId )
|
||||
:CMessage(MSG_REMOVECELL,1*sizeof(DWORD)){
|
||||
|
||||
setName("MsgRemoveCell");
|
||||
writeDWord(1,cellId);
|
||||
}
|
||||
|
||||
DWORD CMsgRemoveCell::getCellId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgObject
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgObject::CMsgObject():CMessage(MSG_OBJECT,9*sizeof(DWORD)){
|
||||
setName("MsgObject");
|
||||
}
|
||||
|
||||
CMsgObject::CMsgObject( DWORD objectId, DWORD geometryId, DWORD parentId,
|
||||
const CPosition & position,
|
||||
const CDirection & direction ):CMessage(MSG_OBJECT,9*sizeof(DWORD)){
|
||||
|
||||
setName("MsgObject");
|
||||
writeDWord(1,objectId);
|
||||
writeDWord(5,geometryId);
|
||||
writeDWord(9,parentId);
|
||||
writePosition(13,position);
|
||||
writeDirection(25,direction);
|
||||
}
|
||||
|
||||
DWORD CMsgObject::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
DWORD CMsgObject::getGeometryId(){
|
||||
return readDWord(5);
|
||||
}
|
||||
|
||||
DWORD CMsgObject::getParentId(){
|
||||
return readDWord(9);
|
||||
}
|
||||
|
||||
CPosition CMsgObject::getPosition(){
|
||||
return readPosition(13);
|
||||
}
|
||||
|
||||
CDirection CMsgObject::getDirection(){
|
||||
return readDirection(25);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgRemoveObject
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgRemoveObject::CMsgRemoveObject():CMessage(MSG_REMOVEOBJECT,2*sizeof(DWORD)){
|
||||
setName("MsgRemoveObject");
|
||||
}
|
||||
|
||||
CMsgRemoveObject::CMsgRemoveObject( DWORD objectId,
|
||||
DWORD parentId ):CMessage(MSG_REMOVEOBJECT,2*sizeof(DWORD)){
|
||||
|
||||
setName("MsgRemoveObject");
|
||||
writeDWord(1,objectId);
|
||||
writeDWord(5,parentId);
|
||||
}
|
||||
|
||||
DWORD CMsgRemoveObject::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
DWORD CMsgRemoveObject::getParentId(){
|
||||
return readDWord(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgChangeMasterCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgChangeMasterCell::CMsgChangeMasterCell():CMessage(MSG_CHANGEMASTERCELL,sizeof(DWORD)){
|
||||
setName("MsgChangeMasterCell");
|
||||
}
|
||||
|
||||
CMsgChangeMasterCell::CMsgChangeMasterCell( DWORD newMasterCellId)
|
||||
:CMessage(MSG_CHANGEMASTERCELL,sizeof(DWORD)){
|
||||
|
||||
setName("MsgChangeMasterCell");
|
||||
writeDWord(1,newMasterCellId);
|
||||
}
|
||||
|
||||
DWORD CMsgChangeMasterCell::getNewMasterCellId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgPVCell
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgPVCell::CMsgPVCell():CMessage(MSG_PVCELL,5*sizeof(DWORD)){
|
||||
setName("MsgPVCell");
|
||||
}
|
||||
|
||||
CMsgPVCell::CMsgPVCell( DWORD cellId, DWORD PVCellId,
|
||||
const CPosition & position ):CMessage(MSG_PVCELL,5*sizeof(DWORD)){
|
||||
|
||||
setName("MsgPVCell");
|
||||
writeDWord(1,cellId);
|
||||
writeDWord(5,PVCellId);
|
||||
for (int ii = 0; ii < 3; ii++){
|
||||
writeDouble(9+ii*4,position.getValue(ii));
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CMsgPVCell::getCellId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
DWORD CMsgPVCell::getPVCellId(){
|
||||
return readDWord(5);
|
||||
}
|
||||
|
||||
CPosition CMsgPVCell::getPosition(){
|
||||
return CPosition(readDouble(9),readDouble(13),readDouble(17));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgUpdatePosition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgUpdatePosition::CMsgUpdatePosition()
|
||||
:CMessage(MSG_UPDATEPOSITION,4*sizeof(DWORD)){
|
||||
|
||||
setName("MsgUpdatePosition");
|
||||
}
|
||||
|
||||
CMsgUpdatePosition::CMsgUpdatePosition(DWORD objectId,const CPosition& position)
|
||||
:CMessage(MSG_UPDATEPOSITION,sizeof(DWORD)*4){
|
||||
|
||||
setName("MsgUpdatePosition");
|
||||
writeDWord(1,objectId);
|
||||
writePosition(5,position);
|
||||
}
|
||||
|
||||
DWORD CMsgUpdatePosition::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
CPosition CMsgUpdatePosition::getPosition(){
|
||||
return readPosition(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgUpdateDirection
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgUpdateDirection::CMsgUpdateDirection()
|
||||
:CMessage(MSG_UPDATEDIRECTION,4*sizeof(DWORD)){
|
||||
|
||||
setName("MsgUpdateDirection");
|
||||
}
|
||||
|
||||
CMsgUpdateDirection::CMsgUpdateDirection(DWORD objectId,const CDirection& direction):CMessage(MSG_UPDATEDIRECTION, 4*sizeof(DWORD)){
|
||||
|
||||
setName("MsgUpdateDirection");
|
||||
writeDWord(1,objectId);
|
||||
writeDirection(5,direction);
|
||||
}
|
||||
|
||||
DWORD CMsgUpdateDirection::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
CDirection CMsgUpdateDirection::getDirection(){
|
||||
return readDirection(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgUpdateHierarchy
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgUpdateHierarchy::CMsgUpdateHierarchy()
|
||||
:CMessage(MSG_UPDATEHIERARCHY,2*sizeof(DWORD)){
|
||||
|
||||
setName("MsgUpdateHierarchy");
|
||||
}
|
||||
|
||||
CMsgUpdateHierarchy::CMsgUpdateHierarchy(DWORD objectId, DWORD parentId):CMessage(MSG_UPDATEHIERARCHY, 2*sizeof(DWORD)){
|
||||
|
||||
setName("MsgUpdateHierarchy");
|
||||
writeDWord(1,objectId);
|
||||
writeDWord(5,parentId);
|
||||
}
|
||||
|
||||
DWORD CMsgUpdateHierarchy::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
DWORD CMsgUpdateHierarchy::getParentId(){
|
||||
return readDWord(5);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMsgRotate
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CMsgRotate::CMsgRotate()
|
||||
:CMessage(MSG_ROTATE,4*sizeof(DWORD)){
|
||||
|
||||
setName("MsgRotate");
|
||||
}
|
||||
|
||||
CMsgRotate::CMsgRotate(DWORD objectId, const CDirection& angleSpeed):CMessage(MSG_ROTATE, 4*sizeof(DWORD)){
|
||||
|
||||
setName("MsgRotate");
|
||||
writeDWord(1,objectId);
|
||||
writeDirection(5,angleSpeed);
|
||||
}
|
||||
|
||||
DWORD CMsgRotate::getObjectId(){
|
||||
return readDWord(1);
|
||||
}
|
||||
|
||||
CDirection CMsgRotate::getAngleSpeed(){
|
||||
return readDirection(5);
|
||||
}
|
||||
|
||||
|
||||
87
common/lib/world/wacreateobject.C
Normal file
87
common/lib/world/wacreateobject.C
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "wacreateobject.H"
|
||||
#include "worldworld.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
CWACreateObject::CWACreateObject( CWorldObject * object ) : CWAObject(object->getObjectId()){
|
||||
m_object = object;
|
||||
m_geometryId = object->getGeometryId();
|
||||
m_parentId = object->getParentId();
|
||||
m_position = object->getPosition();
|
||||
m_direction = object->getDirection();
|
||||
m_objectType = (char*)malloc(strlen(object->getObjectType())+1);
|
||||
strcpy(m_objectType,object->getObjectType());
|
||||
}
|
||||
|
||||
CWACreateObject::CWACreateObject( char * objectType, DWORD objectId , DWORD geometryId, DWORD parentId, const CPosition & position, const CDirection & direction ): CWAObject(objectId){
|
||||
m_object = NULL;
|
||||
m_geometryId = geometryId;
|
||||
m_parentId = parentId;
|
||||
m_position = position;
|
||||
m_direction = direction;
|
||||
m_objectType = (char*)malloc(strlen(objectType)+1);
|
||||
strcpy(m_objectType,objectType);
|
||||
}
|
||||
|
||||
CWACreateObject::~CWACreateObject(){
|
||||
if (m_objectType != NULL) free ( m_objectType );
|
||||
}
|
||||
|
||||
|
||||
CMessage * CWACreateObject::createMessage(){
|
||||
return new CMsgObject(getObjectId(),m_geometryId,m_parentId,m_position,m_direction);
|
||||
}
|
||||
|
||||
int CWACreateObject::animate( DWORD time ){
|
||||
cdebug << "CWAObject::animate ( " << time << " ) create object "
|
||||
<< getObjectId() << " geometry " << m_geometryId
|
||||
<< " parent ";
|
||||
(m_parentId == ID_UNKNOWN ? cdebug << "-1" : cdebug << m_parentId);
|
||||
cdebug << " position " << m_position
|
||||
<< " direction " << m_direction << endl;
|
||||
|
||||
CWorldObject * object = m_object;
|
||||
|
||||
if (m_parentId == -1){
|
||||
|
||||
if (m_object == NULL) object = getWorld()->newObject(m_objectType,getObjectId(),NULL,m_geometryId,m_position,m_direction);
|
||||
|
||||
getWorld()->_addObject( object );
|
||||
|
||||
} else {
|
||||
|
||||
CWorldObject * parent = getWorld()->getObject( m_parentId );
|
||||
if (parent == NULL) return FALSE;
|
||||
|
||||
if (object == NULL){
|
||||
|
||||
object = getWorld()->newObject( m_objectType, getObjectId(), parent, m_geometryId,m_position,m_direction);
|
||||
}
|
||||
|
||||
parent->_addObject( object );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
39
common/lib/world/waobject.C
Normal file
39
common/lib/world/waobject.C
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
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "waobject.H"
|
||||
#include "worldworld.H"
|
||||
//#include "worldlistener.H"
|
||||
|
||||
|
||||
CWAObject::CWAObject( DWORD objectId ):CWorldAnimation(objectId){
|
||||
// m_objectId = objectId;
|
||||
}
|
||||
|
||||
/*
|
||||
DWORD CWAObject::getObjectId(){
|
||||
return m_objectId;
|
||||
}
|
||||
|
||||
CWorldObject * CWAObject::getObject(){
|
||||
return getWorld()->getObject( m_objectId );
|
||||
}
|
||||
*/
|
||||
|
||||
48
common/lib/world/waremoveobject.C
Normal file
48
common/lib/world/waremoveobject.C
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "waremoveobject.H"
|
||||
#include "worldworld.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
|
||||
CWARemoveObject::CWARemoveObject( DWORD objectId , DWORD parentId): CWAObject(objectId){
|
||||
m_parentId = parentId;
|
||||
}
|
||||
|
||||
|
||||
CMessage * CWARemoveObject::createMessage(){
|
||||
return new CMsgRemoveObject(getObjectId(),m_parentId);
|
||||
}
|
||||
|
||||
int CWARemoveObject::animate( DWORD time ){
|
||||
cdebug << "CWAObject::animate ( " << time << " ) remove object " << getObjectId() << " parent " << m_parentId << endl;
|
||||
|
||||
|
||||
if (m_parentId == -1){
|
||||
getWorld()->_removeObject(getWorld()->getObject(getObjectId()));
|
||||
} else {
|
||||
CWorldObject * parent = getWorld()->getObject(m_parentId);
|
||||
parent->_removeObject(parent->getObject(getObjectId()));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
52
common/lib/world/warotate.C
Normal file
52
common/lib/world/warotate.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 "warotate.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
CWARotate::CWARotate( DWORD objectId, const CDirection & angleSpeed )
|
||||
:CWAObject(objectId){
|
||||
m_angleSpeed = angleSpeed;
|
||||
}
|
||||
|
||||
CMessage * CWARotate::createMessage(){
|
||||
return new CMsgRotate( getObjectId(), m_angleSpeed );
|
||||
}
|
||||
|
||||
int CWARotate::animate( DWORD time, DWORD deltaTime ){
|
||||
cdebug << "CWARotate::animate ( " << time << ", " << deltaTime
|
||||
<< " ) angle speed " << m_angleSpeed;
|
||||
|
||||
CWorldObject * object = getObject();
|
||||
|
||||
if (object == NULL){
|
||||
cdebug << " Failed to find object!" << endl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CDirection dir = object->getDirection();
|
||||
|
||||
dir = dir + m_angleSpeed * ((double)deltaTime/1000.0);
|
||||
|
||||
cdebug << " new direction " << dir << endl;
|
||||
|
||||
object->_updateDirection( dir );
|
||||
return TRUE; // Dont delete this animation yet!
|
||||
}
|
||||
39
common/lib/world/waupdatedirection.C
Normal file
39
common/lib/world/waupdatedirection.C
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
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "waupdatedirection.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
CWAUpdateDirection::CWAUpdateDirection( DWORD objectId, const CDirection & direction )
|
||||
:CWAObject(objectId){
|
||||
m_direction = direction;
|
||||
}
|
||||
|
||||
CMessage * CWAUpdateDirection::createMessage(){
|
||||
return new CMsgUpdateDirection( getObjectId(), m_direction );
|
||||
}
|
||||
|
||||
|
||||
int CWAUpdateDirection::animate( DWORD time ){
|
||||
cdebug << "CWAUpdateDirection::animate ( " << time << " ) set direction " << m_direction << endl;
|
||||
CWorldObject * object = getObject();
|
||||
object->_updateDirection( m_direction );
|
||||
return FALSE;
|
||||
}
|
||||
49
common/lib/world/waupdatehierarchy.C
Normal file
49
common/lib/world/waupdatehierarchy.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 "pvvmud.H"
|
||||
#include "waupdatehierarchy.H"
|
||||
#include "worldworld.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
|
||||
CWAUpdateHierarchy::CWAUpdateHierarchy( DWORD objectId , DWORD parentId): CWAObject(objectId){
|
||||
m_parentId = parentId;
|
||||
}
|
||||
|
||||
|
||||
CMessage * CWAUpdateHierarchy::createMessage(){
|
||||
return new CMsgUpdateHierarchy(getObjectId(),m_parentId);
|
||||
}
|
||||
|
||||
int CWAUpdateHierarchy::animate( DWORD time ){
|
||||
cdebug << "CWAUpdateHierarchy::animate ( " << time << " ) update hierarchy " << getObjectId() << " parent " << m_parentId << endl;
|
||||
|
||||
|
||||
if (m_parentId == -1){
|
||||
cdebug << "ERROR cant update hierarchy on cell objects" << endl;
|
||||
} else {
|
||||
CWorldObject * parent = getWorld()->getObject(m_parentId);
|
||||
CWorldObject * object = getWorld()->getObject(getObjectId());
|
||||
object->_setParent(parent);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
39
common/lib/world/waupdateposition.C
Normal file
39
common/lib/world/waupdateposition.C
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
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "waupdateposition.H"
|
||||
#include "msgworld.H"
|
||||
|
||||
CWAUpdatePosition::CWAUpdatePosition( DWORD objectId, const CPosition & position )
|
||||
:CWAObject(objectId){
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
CMessage * CWAUpdatePosition::createMessage(){
|
||||
return new CMsgUpdatePosition( getObjectId(), m_position );
|
||||
}
|
||||
|
||||
|
||||
int CWAUpdatePosition::animate( DWORD time ){
|
||||
cdebug << "CWAUpdatePosition::animate ( " << time << " ) set position " << m_position << endl;
|
||||
CWorldObject * object = getObject();
|
||||
object->_updatePosition( m_position );
|
||||
return FALSE;
|
||||
}
|
||||
138
common/lib/world/worldanimation.C
Normal file
138
common/lib/world/worldanimation.C
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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 "worldanimation.H"
|
||||
#include "worldworld.H"
|
||||
#include "worldobject.H"
|
||||
|
||||
CWorldAnimationList::CWorldAnimationList(){
|
||||
m_lastTime = 0;
|
||||
}
|
||||
|
||||
void CWorldAnimationList::add( CWorldAnimation * animation , DWORD time ){
|
||||
|
||||
DWORD deltaTime;
|
||||
|
||||
if (m_lastTime == 0)
|
||||
deltaTime = 0;
|
||||
else
|
||||
deltaTime = time - m_lastTime;
|
||||
|
||||
if (animation->animate( time, deltaTime )){
|
||||
addLast( (CObject*)animation );
|
||||
} else {
|
||||
delete animation;
|
||||
}
|
||||
}
|
||||
|
||||
void CWorldAnimationList::animate( DWORD time ){
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldAnimation * animation = (CWorldAnimation*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
// if (time >= animation->getStartTime()){
|
||||
// if (time >= animation->getStopTime()) {
|
||||
// remove( animation );
|
||||
// } else {
|
||||
|
||||
|
||||
DWORD deltaTime;
|
||||
|
||||
if (m_lastTime == 0)
|
||||
deltaTime = 0;
|
||||
else
|
||||
deltaTime = time - m_lastTime;
|
||||
|
||||
m_lastTime = time;
|
||||
|
||||
if (!animation->animate( time, deltaTime )){
|
||||
remove( animation );
|
||||
delete animation;
|
||||
}
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CWorldAnimationList::clearList(){
|
||||
deleteAll();
|
||||
}
|
||||
|
||||
void CWorldAnimationList::sendObjectAnimation( DWORD objectId,
|
||||
CListener * listener)
|
||||
{
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldAnimation * animation = (CWorldAnimation*)item->getObject();
|
||||
item = item->getNext();
|
||||
|
||||
if (animation->getObjectId() == objectId){
|
||||
listener->sendAnimation( animation );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CWorldAnimation::CWorldAnimation(DWORD objectId){
|
||||
m_world = NULL;
|
||||
m_startTime = m_stopTime = 0;
|
||||
m_objectId = objectId;
|
||||
}
|
||||
|
||||
CWorldAnimation::~CWorldAnimation(){
|
||||
}
|
||||
|
||||
CWorldWorld * CWorldAnimation::getWorld(){
|
||||
return m_world;
|
||||
}
|
||||
|
||||
void CWorldAnimation::setWorld( CWorldWorld * world ){
|
||||
m_world = world;
|
||||
}
|
||||
|
||||
DWORD CWorldAnimation::getObjectId(){
|
||||
return m_objectId;
|
||||
}
|
||||
|
||||
CWorldObject * CWorldAnimation::getObject(){
|
||||
return getWorld()->getObject( m_objectId );
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Function : animate
|
||||
// Return : TRUE if more animation to do
|
||||
// FALSE if end of animation
|
||||
//
|
||||
int CWorldAnimation::animate( DWORD time, DWORD deltaTime ){
|
||||
return animate( time );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Function : animate
|
||||
// Return : TRUE if more animation to do
|
||||
// FALSE if end of animation
|
||||
//
|
||||
int CWorldAnimation::animate( DWORD time ){
|
||||
return FALSE;
|
||||
}
|
||||
140
common/lib/world/worldhierarchy.C
Normal file
140
common/lib/world/worldhierarchy.C
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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 "worldhierarchy.H"
|
||||
#include "worldworld.H"
|
||||
#include "wacreateobject.H"
|
||||
#include "waremoveobject.H"
|
||||
#include "waupdatehierarchy.H"
|
||||
|
||||
|
||||
CWorldHierarchy::CWorldHierarchy(DWORD objectId, CWorldHierarchy * parent){
|
||||
m_objectId = objectId;
|
||||
m_parent = parent;
|
||||
if ((m_objectId != ID_UNKNOWN) && (m_parent == NULL)){
|
||||
cdebug << "ERROR: Have to have a parent!\n";
|
||||
void (*a)() = NULL;
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
CWorldHierarchy::~CWorldHierarchy(){
|
||||
if (m_parent != NULL)
|
||||
cdebug << "WARNING CWorldHierarchy::~CWorldHierarchy "
|
||||
<< "Parent not NULL!" << endl;
|
||||
|
||||
if (getNumItems() > 0)
|
||||
cdebug << "WARNING CWorldHierarchy::~CWorldHierarchy "
|
||||
<< "Subobject not removed!" << endl;
|
||||
}
|
||||
|
||||
|
||||
DWORD CWorldHierarchy::getObjectId(){
|
||||
return m_objectId;
|
||||
}
|
||||
|
||||
CWorldHierarchy * CWorldHierarchy::getParent(){
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
DWORD CWorldHierarchy::getParentId(){
|
||||
if (m_parent == NULL) return ID_UNKNOWN;
|
||||
|
||||
return m_parent->getObjectId();
|
||||
}
|
||||
|
||||
CWorldWorld * CWorldHierarchy::getWorld(){
|
||||
return m_parent->getWorld();
|
||||
}
|
||||
|
||||
void CWorldHierarchy::_addObject(CWorldObject * object){
|
||||
addLast((CObject*)object);
|
||||
}
|
||||
|
||||
void CWorldHierarchy::_removeObject(CWorldObject * object){
|
||||
remove((CObject*)object);
|
||||
}
|
||||
|
||||
void CWorldHierarchy::_setParent(CWorldHierarchy * parent){
|
||||
|
||||
// Unlink from old parent
|
||||
if (m_parent != NULL){
|
||||
m_parent->_removeObject((CWorldObject*)this);
|
||||
}
|
||||
|
||||
m_parent = parent;
|
||||
|
||||
// Link to new parent
|
||||
if (m_parent != NULL){
|
||||
m_parent->_addObject((CWorldObject*)this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CWorldHierarchy::addObject(CWorldObject * object){
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWACreateObject(object), this );
|
||||
}
|
||||
|
||||
void CWorldHierarchy::removeObject(CWorldObject * object){
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWARemoveObject(object->getObjectId(),
|
||||
object->getParentId()), this );
|
||||
}
|
||||
|
||||
void CWorldHierarchy::setParent(CWorldObject * parent){
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWAUpdateHierarchy(getObjectId(),
|
||||
parent->getObjectId()), this );
|
||||
}
|
||||
|
||||
CWorldObject * CWorldHierarchy::getObject( DWORD objectId ){
|
||||
|
||||
// Check if this is the object!
|
||||
if (objectId == getObjectId()) return (CWorldObject*)this;
|
||||
|
||||
// Check child objects
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldObject * object = (CWorldObject*)item->getObject();
|
||||
if ((object = object->getObject(objectId)) != NULL) return object;
|
||||
item = item->getNext();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CWorldObject * CWorldHierarchy::getObject( char * name ){
|
||||
|
||||
// Check if this is the object!
|
||||
if (getName() != NULL && strcmp(name,getName()) == 0) return (CWorldObject*)this;
|
||||
|
||||
// Check child objects
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldObject * object = (CWorldObject*)item->getObject();
|
||||
if ((object = object->getObject(name)) != NULL) return object;
|
||||
item = item->getNext();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
244
common/lib/world/worldobject.C
Normal file
244
common/lib/world/worldobject.C
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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 "worldobject.H"
|
||||
#include "worldworld.H"
|
||||
#include "waupdateposition.H"
|
||||
#include "waupdatedirection.H"
|
||||
#include "warotate.H"
|
||||
|
||||
CWorldObject::CWorldObject(DWORD objectId, CWorldHierarchy * parent, DWORD geometryId, const CPosition & position, const CDirection & direction):CWorldHierarchy(objectId,parent){
|
||||
m_geometryId = geometryId;
|
||||
m_bBox = NULL;
|
||||
m_BSDTree = NULL;
|
||||
m_collidable = 0;
|
||||
m_cellPVS = NULL;
|
||||
_updatePosition(position);
|
||||
_updateDirection(direction);
|
||||
}
|
||||
|
||||
CWorldObject::~CWorldObject(){
|
||||
if (m_bBox != NULL) delete m_bBox;
|
||||
if (m_BSDTree != NULL) delete m_BSDTree;
|
||||
if (m_cellPVS != NULL) delete m_cellPVS;
|
||||
}
|
||||
|
||||
DWORD CWorldObject::getGeometryId(){
|
||||
return m_geometryId;
|
||||
}
|
||||
|
||||
CPosition & CWorldObject::getPosition(){
|
||||
return m_position;
|
||||
}
|
||||
|
||||
CDirection & CWorldObject::getDirection(){
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
char * CWorldObject::getObjectType(){
|
||||
return "object";
|
||||
}
|
||||
|
||||
CWorldObject * CWorldObject::getMasterCell(){
|
||||
|
||||
if (getParentId() == ID_UNKNOWN) return this;
|
||||
|
||||
CWorldObject * parent = (CWorldObject*)getParent();
|
||||
|
||||
if (parent != NULL) return parent->getMasterCell();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CGeometry * CWorldObject::getGeometry(){
|
||||
cdebug << "CWorldObject::getGeometry: Not overloaded!\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CPVCell* CWorldObject::addPVCell(DWORD PVCellId, const CPosition & position){
|
||||
if (m_cellPVS == NULL) m_cellPVS = new CCellPVS(getWorld());
|
||||
return m_cellPVS->addPVCell(PVCellId,position);
|
||||
}
|
||||
|
||||
CCellPVS* CWorldObject::getPVS(){
|
||||
return m_cellPVS;
|
||||
}
|
||||
|
||||
|
||||
void CWorldObject::updatePosition( const CPosition & position ){
|
||||
// cdebug << "CWorldObject::updatePosition " << position << " on object " << getObjectId() << "\n";
|
||||
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWAUpdatePosition(getObjectId(),position), this );
|
||||
}
|
||||
|
||||
void CWorldObject::updateDirection( const CDirection & direction ){
|
||||
// cdebug << "CWorldObject::updateDirection " << direction << " on object " << getObjectId() << "\n";
|
||||
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWAUpdateDirection(getObjectId(),direction), this );
|
||||
}
|
||||
|
||||
void CWorldObject::rotate( const CDirection & angleSpeed ){
|
||||
// cdebug << "CWorldObject::rotate " << angleSpeed << " on object " << getObjectId() << "\n";
|
||||
|
||||
CWorldWorld * world = getWorld();
|
||||
world->addAnimation(new CWARotate(getObjectId(),angleSpeed), this );
|
||||
}
|
||||
|
||||
void CWorldObject::_updateDirection( const CDirection & direction ){
|
||||
// cdebug << "CWorldObject::_updateDirection " << direction << " on object " << getObjectId() << "\n";
|
||||
m_direction = direction;
|
||||
}
|
||||
|
||||
void CWorldObject::_updatePosition( const CPosition & position ){
|
||||
// cdebug << "CWorldObject::_updatePosition " << position << " on object " << getObjectId() << "\n";
|
||||
m_position = position;
|
||||
}
|
||||
|
||||
void CWorldObject::setBBox( CBBox * bBox ){
|
||||
m_bBox = bBox;
|
||||
}
|
||||
|
||||
CBBox * CWorldObject::getBBox( ){
|
||||
return m_bBox;
|
||||
}
|
||||
|
||||
void CWorldObject::setCollidable(BYTE coll){
|
||||
m_collidable =coll;
|
||||
}
|
||||
|
||||
BYTE CWorldObject::getCollidable(){
|
||||
return m_collidable ;
|
||||
}
|
||||
|
||||
void CWorldObject::setBSDTree( CBSDTree * BSDTree ){
|
||||
m_BSDTree = BSDTree;
|
||||
}
|
||||
|
||||
CBSDTree * CWorldObject::getBSDTree( ){
|
||||
return m_BSDTree;
|
||||
}
|
||||
|
||||
CWorldObject * CWorldObject::createObject( char * objectName, DWORD objectId,
|
||||
DWORD geometryId, const CPosition & position, const CDirection & direction ){
|
||||
|
||||
CWorldObject * object =
|
||||
getWorld()->newObject(objectName, objectId,this,geometryId,position,direction);
|
||||
addObject( object );
|
||||
return object;
|
||||
}
|
||||
|
||||
int CWorldObject::checkPosition(const CPosition & position){
|
||||
if (m_BSDTree != NULL) return m_BSDTree->inside( position );
|
||||
else if (getBBox() != NULL) return getBBox()->inside( position );
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
int CWorldObject::moveTo( CWorldObject * parent ){
|
||||
|
||||
setParent( parent );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CWorldObject::getGlobalTransform( CMatrix & transform ){
|
||||
getTransform( transform );
|
||||
|
||||
if (getParentId() != ID_UNKNOWN){
|
||||
CWorldObject * parent = (CWorldObject*)getParent();
|
||||
if (parent != NULL) parent->getGlobalTransform( transform );
|
||||
}
|
||||
}
|
||||
|
||||
void CWorldObject::getTransform( CMatrix & transform ){
|
||||
transform.translate( getPosition() );
|
||||
transform.rotate( getDirection() );
|
||||
}
|
||||
|
||||
void CWorldObject::getInvGlobalTransform( CMatrix & transform ){
|
||||
getInvTransform( transform );
|
||||
if (getParentId() != ID_UNKNOWN){
|
||||
CWorldObject * parent = (CWorldObject*)getParent();
|
||||
if (parent != NULL) parent->getInvGlobalTransform( transform );
|
||||
}
|
||||
}
|
||||
|
||||
void CWorldObject::getInvTransform( CMatrix & transform ){
|
||||
transform.rotate( -getDirection() );
|
||||
transform.translate( -getPosition() );
|
||||
}
|
||||
|
||||
void CWorldObject::distances(CDoubleArray & distArray, const CBeam & beam,
|
||||
double min, double max){
|
||||
|
||||
if (m_collidable ) return;
|
||||
|
||||
CGeometry * geometry = getGeometry();
|
||||
|
||||
CMatrix transform;
|
||||
getInvTransform(transform);
|
||||
|
||||
CBeam objBeam = beam;
|
||||
objBeam.transform(transform);
|
||||
|
||||
if (geometry != NULL){
|
||||
if ( objBeam.intersect(geometry->calculateBBox())){
|
||||
cdebug << "CWorldObject( " << getName()
|
||||
<< " )::distances: Beam " << objBeam << "\n";
|
||||
geometry->distances(distArray,objBeam,min,max);
|
||||
|
||||
// Test sub objects
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldObject * obj = (CWorldObject*)item->getObject();
|
||||
|
||||
obj->distances(distArray,objBeam,min,max);
|
||||
|
||||
item = item->getNext();
|
||||
}
|
||||
} else {
|
||||
cdebug << "CWorldObject( " << getName()
|
||||
<< " )::distances: Don't intersect!\n";
|
||||
}
|
||||
} else {
|
||||
cdebug << "CWorldObject( " << getName()
|
||||
<< " )::distances: Don't have geometry!\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CWorldObject::dump(int tab){
|
||||
int ii;
|
||||
for (ii = 0; ii < tab; ii++) cdebug << "\t";
|
||||
cdebug << "Object: Id: " << getObjectId() << " Geo: " << getGeometryId() << " Pos: " << getPosition() << " Dir: " << getDirection() << "\n";
|
||||
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldObject * object = (CWorldObject*)item->getObject();
|
||||
object->dump(tab+1);
|
||||
item = item->getNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
187
common/lib/world/worldworld.C
Normal file
187
common/lib/world/worldworld.C
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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 <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include "pvvmud.H"
|
||||
#include "worldworld.H"
|
||||
|
||||
CWorldWorld::CWorldWorld():CWorldHierarchy(ID_UNKNOWN,NULL){
|
||||
setName("World");
|
||||
m_animationList = new CWorldAnimationList();
|
||||
m_startTimeSec = time(NULL);
|
||||
m_timeOffset = 0;
|
||||
}
|
||||
|
||||
CWorldWorld::~CWorldWorld(){
|
||||
delete m_animationList;
|
||||
clearWorld();
|
||||
}
|
||||
|
||||
CWorldWorld * CWorldWorld::getWorld(){
|
||||
return this;
|
||||
}
|
||||
|
||||
CWorldAnimationList * CWorldWorld::getAnimationList(){
|
||||
return m_animationList;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// getTime
|
||||
// Return time in millisecound sins world startup
|
||||
//
|
||||
DWORD CWorldWorld::getTime(){
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
return (tv.tv_sec - m_startTimeSec)*1000 + tv.tv_usec/1000 - m_timeOffset;
|
||||
}
|
||||
|
||||
void CWorldWorld::fixTime(long deltaTime){
|
||||
|
||||
if (deltaTime < 0){
|
||||
if (labs(deltaTime) > m_timeOffset){
|
||||
DWORD sec = (-deltaTime)/1000 + 1;
|
||||
m_startTimeSec -= sec;
|
||||
deltaTime += sec*1000;
|
||||
m_timeOffset += deltaTime;
|
||||
} else m_timeOffset = m_timeOffset - (DWORD)labs(deltaTime);
|
||||
} else m_timeOffset += deltaTime;
|
||||
|
||||
while (m_timeOffset >= 1000){
|
||||
m_timeOffset -= 1000;
|
||||
m_startTimeSec++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CWorldWorld::clearWorld(){
|
||||
m_animationList->clearList();
|
||||
deleteAll();
|
||||
}
|
||||
|
||||
|
||||
CWorldObject * CWorldWorld::createObject( DWORD parentId, char * objectName,
|
||||
DWORD objectId, DWORD geometryId, const CPosition & position,
|
||||
const CDirection & direction )
|
||||
{
|
||||
|
||||
CWorldObject * object;
|
||||
|
||||
if (parentId == -1){
|
||||
object = newObject(objectName,objectId,NULL,geometryId,position,direction);
|
||||
CWorldHierarchy::addObject( object );
|
||||
} else {
|
||||
|
||||
CWorldObject * parent = getObject( parentId );
|
||||
if (parent == NULL) return NULL;
|
||||
|
||||
object = parent->createObject( objectName, objectId, geometryId, position, direction );
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
void CWorldWorld::removeObject( DWORD objectId, DWORD parentId ){
|
||||
|
||||
if (parentId == -1){
|
||||
CWorldObject * cell = getObject( objectId );
|
||||
if (cell != NULL) CWorldHierarchy::removeObject( cell );
|
||||
} else {
|
||||
|
||||
CWorldObject * parent = getObject( parentId );
|
||||
if (parent == NULL){
|
||||
cdebug << "WARNING: Failed to remove object " << objectId
|
||||
<< " Failed to find parent : " << parentId << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
CWorldObject * object = parent->getObject( objectId );
|
||||
if (object == NULL){
|
||||
cdebug << "WARNING: Failed to remove object( " << objectId << ") : Did not find object in parent : " << parentId << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
parent->removeObject(object);
|
||||
}
|
||||
}
|
||||
|
||||
CPVCell * CWorldWorld::addPVCell( DWORD cellId,
|
||||
DWORD PVCellId, const CPosition & position ){
|
||||
|
||||
CWorldObject * cell = getObject(cellId);
|
||||
if (cell == NULL) return NULL;
|
||||
|
||||
return cell->addPVCell(PVCellId,position);
|
||||
}
|
||||
|
||||
void CWorldWorld::updatePosition( DWORD objectId, const CPosition & position ){
|
||||
CWorldObject * object = getObject(objectId);
|
||||
cdebug << "CWorldWorld::updatePosition\n";
|
||||
if (object != NULL) object->updatePosition(position);
|
||||
}
|
||||
|
||||
void CWorldWorld::updateDirection( DWORD objectId,const CDirection & direction){
|
||||
CWorldObject * object = getObject(objectId);
|
||||
cdebug << "CWorldWorld::updateDirection\n";
|
||||
if (object != NULL) object->updateDirection(direction);
|
||||
}
|
||||
|
||||
void CWorldWorld::rotate( DWORD objectId, const CDirection & angleSpeed ){
|
||||
CWorldObject * object = getObject(objectId);
|
||||
cdebug << "CWorldWorld::rotate\n";
|
||||
if (object != NULL) object->rotate(angleSpeed);
|
||||
}
|
||||
|
||||
void CWorldWorld::updateHierarchy( DWORD objectId, DWORD parentId ){
|
||||
CWorldObject * object = getObject(objectId);
|
||||
CWorldObject * parent = getObject(parentId);
|
||||
if ((object != NULL) && (parent != NULL)){
|
||||
cdebug << "CWorldWorld::updateHierarchy: OK\n";
|
||||
|
||||
object->moveTo( parent );
|
||||
|
||||
} else {
|
||||
cdebug << "CWorldWorld::updateHierarchy: Failed\n";
|
||||
}
|
||||
}
|
||||
|
||||
void CWorldWorld::addAnimation( CWorldAnimation * animation, CWorldHierarchy * object ){
|
||||
animation->setWorld( this );
|
||||
CListener * listener = object->getListener();
|
||||
if (listener != NULL) listener->sendAnimation( animation );
|
||||
m_animationList->add( animation , getTime() );
|
||||
}
|
||||
|
||||
void CWorldWorld::animate(){
|
||||
// cdebug << "Animate" << endl;
|
||||
m_animationList->animate( getTime() );
|
||||
}
|
||||
|
||||
void CWorldWorld::dump(){
|
||||
cdebug << "World:\n";
|
||||
CObjectListItem * item = getFirst();
|
||||
while (item != NULL){
|
||||
CWorldObject * cell = (CWorldObject*)item->getObject();
|
||||
if (cell != NULL) cell->dump(1);
|
||||
item = item->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user