Changeset 3530 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 13, 2005, 10:40:25 PM (20 years ago)
- Location:
- orxonox/branches/levelloader
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/Makefile.in
r3499 r3530 1 # Makefile.in generated by automake 1.8. 5from Makefile.am.1 # Makefile.in generated by automake 1.8.2 from Makefile.am. 2 2 # @configure_input@ 3 3 … … 38 38 $(srcdir)/Makefile.in $(srcdir)/config.h.in \ 39 39 $(srcdir)/doc/documentation.am $(top_srcdir)/configure AUTHORS \ 40 COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp\41 install-sh missing mkinstalldirs40 COPYING ChangeLog INSTALL NEWS TODO config.guess config.sub \ 41 depcomp install-sh missing mkinstalldirs 42 42 subdir = . 43 43 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 326 326 tags=; \ 327 327 here=`pwd`; \ 328 if ( $(ETAGS)--etags-include --version) >/dev/null 2>&1; then \328 if (etags --etags-include --version) >/dev/null 2>&1; then \ 329 329 include_option=--etags-include; \ 330 empty_fix=.; \331 330 else \ 332 331 include_option=--include; \ 333 empty_fix=; \334 332 fi; \ 335 333 list='$(SUBDIRS)'; for subdir in $$list; do \ 336 334 if test "$$subdir" = .; then :; else \ 337 test ! -f $$subdir/TAGS ||\335 test -f $$subdir/TAGS && \ 338 336 tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ 339 337 fi; \ … … 345 343 $(AWK) ' { files[$$0] = 1; } \ 346 344 END { for (i in files) print i; }'`; \ 347 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 348 test -n "$$unique" || unique=$$empty_fix; \ 349 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 350 $$tags $$unique; \ 351 fi 345 test -z "$(ETAGS_ARGS)$$tags$$unique" \ 346 || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 347 $$tags $$unique 352 348 ctags: CTAGS 353 349 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ … … 458 454 uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\ 459 455 *.shar.gz*) \ 460 GZIP=$(GZIP_ENV) gunzip -c $(distdir). shar.gz | unshar ;;\456 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | unshar ;;\ 461 457 *.zip*) \ 462 458 unzip $(distdir).zip ;;\ … … 481 477 && chmod -R a-w "$$dc_install_base" \ 482 478 && ({ \ 483 (cd ../.. && umask 077 && mkdir"$$dc_destdir") \479 (cd ../.. && $(mkdir_p) "$$dc_destdir") \ 484 480 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 485 481 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ -
orxonox/branches/levelloader/aclocal.m4
r3099 r3530 1 # generated automatically by aclocal 1.8. 5-*- Autoconf -*-1 # generated automatically by aclocal 1.8.2 -*- Autoconf -*- 2 2 3 3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 … … 41 41 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. 42 42 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], 43 [AM_AUTOMAKE_VERSION([1.8. 5])])43 [AM_AUTOMAKE_VERSION([1.8.2])]) 44 44 45 45 # AM_AUX_DIR_EXPAND … … 150 150 fi])]) 151 151 152 # serial 7-*- Autoconf -*-152 # serial 6 -*- Autoconf -*- 153 153 154 154 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 … … 237 237 for i in 1 2 3 4 5 6; do 238 238 echo '#include "conftst'$i'.h"' >> sub/conftest.c 239 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with 240 # Solaris 8's {/usr,}/bin/sh. 241 touch sub/conftst$i.h 239 : > sub/conftst$i.h 242 240 done 243 241 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf … … 267 265 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then 268 266 # icc doesn't choke on unknown options, it will just issue warnings 269 # or remarks (even with -Werror). So we grep stderr for any message 270 # that says an option was ignored or not supported. 271 # When given -MP, icc 7.0 and 7.1 complain thusly: 272 # icc: Command line warning: ignoring option '-M'; no argument required 273 # The diagnosis changed in icc 8.0: 274 # icc: Command line remark: option '-MP' not supported 275 if (grep 'ignoring option' conftest.err || 276 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else 267 # (even with -Werror). So we grep stderr for any message 268 # that says an option was ignored. 269 if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else 277 270 am_cv_$1_dependencies_compiler_type=$depmode 278 271 break … … 320 313 # Generate code to set up dependency tracking. -*- Autoconf -*- 321 314 322 # Copyright (C) 1999, 2000, 2001, 2002, 2003 , 2004Free Software Foundation, Inc.315 # Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 323 316 324 317 # This program is free software; you can redistribute it and/or modify … … 359 352 # Extract the definition of DEP_FILES from the Makefile without 360 353 # running `make'. 361 DEPDIR=`sed -n 's/^DEPDIR =//p' < "$mf"`354 DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` 362 355 test -z "$DEPDIR" && continue 363 356 # When using ansi2knr, U may be empty or an underscore; expand it 364 U=`sed -n 's/^U =//p' < "$mf"`357 U=`sed -n -e '/^U = / s///p' < "$mf"` 365 358 test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" 366 359 # We invoke sed twice because it is the simplest approach to 367 360 # changing $(DEPDIR) to its actual value in the expansion. 368 for file in `sed -n '361 for file in `sed -n -e ' 369 362 /^DEP_FILES = .*\\\\$/ { 370 363 s/^DEP_FILES = // … … 725 718 # Do not use -m 0755 and let people choose whatever they expect by 726 719 # setting umask. 727 #728 # We cannot accept any implementation of `mkdir' that recognizes `-p'.729 # Some implementations (such as Solaris 8's) are not thread-safe: if a730 # parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'731 # concurrently, both version can detect that a/ is missing, but only732 # one can create it and the other will error out. Consequently we733 # restrict ourselves to GNU make (using the --version option ensures734 # this.)735 720 AC_DEFUN([AM_PROG_MKDIR_P], 736 [if mkdir -p -- version . >/dev/null 2>&1 && test ! -d ./--version; then721 [if mkdir -p -- . 2>/dev/null; then 737 722 # Keeping the `.' argument allows $(mkdir_p) to be used without 738 723 # argument. Indeed, we sometimes output rules like … … 747 732 # directories to create, and then abort because `.' already 748 733 # exists. 749 for d in ./-p ./-- version;734 for d in ./-p ./--; 750 735 do 751 736 test -d $d && rmdir $d -
orxonox/branches/levelloader/configure
r3499 r3530 1599 1599 fi 1600 1600 1601 if mkdir -p -- version . >/dev/null 2>&1 && test ! -d ./--version; then1601 if mkdir -p -- . 2>/dev/null; then 1602 1602 # Keeping the `.' argument allows $(mkdir_p) to be used without 1603 1603 # argument. Indeed, we sometimes output rules like … … 1612 1612 # directories to create, and then abort because `.' already 1613 1613 # exists. 1614 for d in ./-p ./-- version;1614 for d in ./-p ./--; 1615 1615 do 1616 1616 test -d $d && rmdir $d … … 2518 2518 for i in 1 2 3 4 5 6; do 2519 2519 echo '#include "conftst'$i'.h"' >> sub/conftest.c 2520 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with 2521 # Solaris 8's {/usr,}/bin/sh. 2522 touch sub/conftst$i.h 2520 : > sub/conftst$i.h 2523 2521 done 2524 2522 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf … … 2548 2546 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then 2549 2547 # icc doesn't choke on unknown options, it will just issue warnings 2550 # or remarks (even with -Werror). So we grep stderr for any message 2551 # that says an option was ignored or not supported. 2552 # When given -MP, icc 7.0 and 7.1 complain thusly: 2553 # icc: Command line warning: ignoring option '-M'; no argument required 2554 # The diagnosis changed in icc 8.0: 2555 # icc: Command line remark: option '-MP' not supported 2556 if (grep 'ignoring option' conftest.err || 2557 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else 2548 # (even with -Werror). So we grep stderr for any message 2549 # that says an option was ignored. 2550 if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else 2558 2551 am_cv_CXX_dependencies_compiler_type=$depmode 2559 2552 break … … 3356 3349 for i in 1 2 3 4 5 6; do 3357 3350 echo '#include "conftst'$i'.h"' >> sub/conftest.c 3358 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with 3359 # Solaris 8's {/usr,}/bin/sh. 3360 touch sub/conftst$i.h 3351 : > sub/conftst$i.h 3361 3352 done 3362 3353 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf … … 3386 3377 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then 3387 3378 # icc doesn't choke on unknown options, it will just issue warnings 3388 # or remarks (even with -Werror). So we grep stderr for any message 3389 # that says an option was ignored or not supported. 3390 # When given -MP, icc 7.0 and 7.1 complain thusly: 3391 # icc: Command line warning: ignoring option '-M'; no argument required 3392 # The diagnosis changed in icc 8.0: 3393 # icc: Command line remark: option '-MP' not supported 3394 if (grep 'ignoring option' conftest.err || 3395 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else 3379 # (even with -Werror). So we grep stderr for any message 3380 # that says an option was ignored. 3381 if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else 3396 3382 am_cv_CC_dependencies_compiler_type=$depmode 3397 3383 break … … 9573 9559 # Extract the definition of DEP_FILES from the Makefile without 9574 9560 # running `make'. 9575 DEPDIR=`sed -n 's/^DEPDIR =//p' < "$mf"`9561 DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` 9576 9562 test -z "$DEPDIR" && continue 9577 9563 # When using ansi2knr, U may be empty or an underscore; expand it 9578 U=`sed -n 's/^U =//p' < "$mf"`9564 U=`sed -n -e '/^U = / s///p' < "$mf"` 9579 9565 test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" 9580 9566 # We invoke sed twice because it is the simplest approach to 9581 9567 # changing $(DEPDIR) to its actual value in the expansion. 9582 for file in `sed -n '9568 for file in `sed -n -e ' 9583 9569 /^DEP_FILES = .*\\\\$/ { 9584 9570 s/^DEP_FILES = // -
orxonox/branches/levelloader/src/defs/debug.h
r3499 r3530 22 22 #define _DEBUG_H 23 23 24 #if HAVE_CONFIG_H 25 #include <config.h> 26 #endif 27 28 #include <stdio.h> 29 24 30 #define NO 0 25 31 #define ERR 1 … … 28 34 #define DEBUGING 4 29 35 30 #if HAVE_CONFIG_H31 #include <config.h>32 #endif33 34 #include <stdio.h>35 36 36 /////////////////////////////////////////////////// 37 37 /// PRINTF: prints with filename and linenumber /// 38 38 /////////////////////////////////////////////////// 39 40 39 #ifdef DEBUG 41 40 extern int verbose; 42 41 #define PRINTF(x) \ 43 42 PRINTF ## x 44 43 45 44 #if DEBUG >= ERR 46 45 #define PRINTF1 \ … … 92 91 #define PRINT(x) \ 93 92 PRINT ## x 94 93 95 94 #if DEBUG >= ERR 96 95 #define PRINT1 \ -
orxonox/branches/levelloader/src/defs/error.h
r3499 r3530 23 23 24 24 25 #ifndef _ ERROR_H26 #define _ ERROR_H25 #ifndef _ORX_ERROR_H 26 #define _ORX_ERROR_H 27 27 28 28 // these are the two undefined error nr. Don't use them ... … … 54 54 */ 55 55 56 typedef struct 56 typedef struct ErrorMessage 57 57 { 58 58 int code; -
orxonox/branches/levelloader/src/defs/stdincl.h
r3525 r3530 8 8 #ifndef _STDINCL_H 9 9 #define _STDINCL_H 10 10 11 11 #define null 0 //!< null 12 12 … … 22 22 #endif 23 23 24 #include <assert.h> 24 25 #include <stdlib.h> 25 26 #include <string.h> … … 27 28 #include "glincl.h" 28 29 30 #include "error.h" 31 #include "debug.h" 29 32 30 33 // MATH // … … 41 44 #include "factory.h" 42 45 43 #include "error.h" 44 #include "debug.h" 46 #define CREATE_FACTORY(x) \ 47 class x ## Factory : public Factory { \ 48 public: \ 49 x ## Factory (){setNext( NULL); setClassname( #x ); initialize();} \ 50 ~x ## Factory () {}; \ 51 private: \ 52 BaseObject* fabricate( TiXmlElement* root) \ 53 { \ 54 if(!strcmp(root->Value(), getClassname())) return new x ( root); \ 55 else if( getNext() != NULL) return getNext()->fabricate( root); \ 56 else return NULL; \ 57 } \ 58 }; \ 59 x ## Factory global_ ## x ## Factory; 45 60 46 61 #endif /* _STDINCL_H */ -
orxonox/branches/levelloader/src/factory.cc
r3525 r3530 18 18 19 19 #include "factory.h" 20 #include "game_loader.h" 20 21 21 22 using namespace std; … … 33 34 Factory::Factory () 34 35 { 35 classname = "NULL" 36 classname = "NULL"; 36 37 next = NULL; 37 38 } 38 39 39 40 /** 40 \brief constructor41 \brief destructor 41 42 42 43 clear the Q … … 51 52 \brief generates the associated object from data 52 53 */ 53 BaseObject* ObjectFactory::fabricate( TiXmlElement* data)54 BaseObject* Factory::fabricate( TiXmlElement* data) 54 55 { 55 56 return NULL; … … 61 62 void Factory::initialize() 62 63 { 64 assert( classname != NULL); 65 PRINTF(3)("Initializing %sFactory\n", classname); 63 66 GameLoader* gl = GameLoader::getInstance(); 64 67 gl->registerFactory( this); … … 88 91 while( node != NULL) 89 92 { 90 if( node->T ype() == TEXT) return node->Value();91 node = node->Next Child();93 if( node->ToText()) return node->Value(); 94 node = node->NextSibling(); 92 95 } 93 96 return NULL; -
orxonox/branches/levelloader/src/factory.h
r3525 r3530 8 8 9 9 #include "stdincl.h" 10 #include "world.h"11 10 12 #define CREATE_FACTORY(CLASS) class CLASSFactory : public Factory { \ 13 public: \ 14 CLASSFactory (){setNext( NULL); setClassname = "CLASS"; initialize();} \ 15 ~CLASSFactory (); \ 16 private: \ 17 BaseObject* fabricate( TiXmlElement* root) \ 18 { \ 19 if(!strcmp(root->Value(), getClassname())) return new CLASS( root); \ 20 else if( next != NULL) return next->fabricate( root); \ 21 else return NULL; \ 22 } \ 23 }; \ 24 CLASSFactory global_CLASSFactory; 11 class BaseObject; 25 12 26 13 //! The Factory is … … 37 24 void initialize(); 38 25 void registerFactory( Factory* factory); 39 void setClassname(char* name) {classname = name}; 40 char* getClassname() {return classname}; 41 void setNext( ObjectFactory* factory) {next = factory}; 26 void setClassname(char* name) {classname = name;} 27 char* getClassname() {return classname;}; 28 void setNext( Factory* factory) {next = factory;} 29 Factory* getNext() {return next;} 42 30 43 31 private: -
orxonox/branches/levelloader/src/game_loader.cc
r3525 r3530 15 15 co-programmer: ... 16 16 */ 17 18 17 19 18 #include "game_loader.h" … … 162 161 if( name == NULL) 163 162 { 164 PRINTF( ERR)("No filename specified for loading");163 PRINTF(1)("No filename specified for loading"); 165 164 return NULL; 166 165 } … … 168 167 TiXmlDocument* XMLDoc = new TiXmlDocument( name); 169 168 // load the campaign document 170 if( !XMLDoc .LoadFile())169 if( !XMLDoc->LoadFile()) 171 170 { 172 171 // report an error 173 PRINTF( ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());172 PRINTF(1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 174 173 delete XMLDoc; 175 174 return NULL; … … 177 176 178 177 // check basic validity 179 TiXmlElement* element = XMLDoc .RootElement();178 TiXmlElement* element = XMLDoc->RootElement(); 180 179 assert( element != NULL); 181 180 … … 185 184 { 186 185 // report an error 187 PRINTF( ERR)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");186 PRINTF(1)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 188 187 delete XMLDoc; 189 188 return NULL; … … 191 190 192 191 // construct campaign 193 Campaign c = new Campaign( element);192 Campaign* c = new Campaign( element); 194 193 195 194 // free the XML data 196 195 delete XMLDoc; 196 197 return c; 197 198 } 198 199 … … 269 270 void GameLoader::registerFactory( Factory* factory) 270 271 { 271 if( next == NULL) next = factory; 272 else next->registerFactory( factory); 272 assert( factory != NULL); 273 274 printf("Registered factory for '%s'\n", factory->getClassname()); 275 276 if( first == NULL) first = factory; 277 else first->registerFactory( factory); 273 278 } 274 279 … … 277 282 \param element a XMLElement containing all the needed info 278 283 */ 279 StoryEntity* GameLoader::fabricate( TiXmlElement* element)284 BaseObject* GameLoader::fabricate( TiXmlElement* element) 280 285 { 281 286 if( first == NULL) 282 287 { 283 PRINTF( ERR)("GameLoader does not know any factories, fabricate() failed\n");288 PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n"); 284 289 return NULL; 285 290 } -
orxonox/branches/levelloader/src/game_loader.h
r3525 r3530 4 4 #include "stdincl.h" 5 5 #include "story_def.h" 6 #include "factory.h" 6 7 7 8 //----------------------------------------------------------------------------- -
orxonox/branches/levelloader/src/lib/util/substring.cc
r3525 r3530 22 22 #include "substring.h" 23 23 24 SubString::SubString( c har* string)24 SubString::SubString( const char* string) 25 25 { 26 26 n = 0; … … 32 32 n += 1; 33 33 34 strings = malloc( sizeof( char*) * n);34 strings = new char*[n]; 35 35 36 36 int i = 0; 37 37 int l = 0; 38 38 39 c har* offset = string;39 const char* offset = string; 40 40 char* end = strchr( string, ','); 41 41 while( end != NULL) 42 42 { 43 43 l = end - offset; 44 strings[i] = malloc( l + 1);44 strings[i] = new char[l + 1]; 45 45 strncpy( strings[i], offset, l); 46 46 i++; … … 50 50 } 51 51 52 strings[i] = malloc( l + 1);52 strings[i] = new char[l + 1]; 53 53 strncpy( strings[i], offset, l); 54 54 l = strlen( offset); … … 62 62 for( int i = 0; i < n; i++) 63 63 { 64 free( strings[i]);64 delete strings[i]; 65 65 } 66 66 67 free( strings);67 delete strings; 68 68 } 69 69 -
orxonox/branches/levelloader/src/lib/util/substring.h
r3525 r3530 3 3 \brief a small class to get the parts of a string separated by commas 4 4 */ 5 6 #ifndef _SUBSTRING_H 7 #define _SUBSTRING_H 5 8 6 9 #include "stdincl.h" … … 10 13 public: 11 14 12 SubString( c har* string);15 SubString( const char* string); 13 16 ~SubString(); 14 17 … … 20 23 int n; 21 24 }; 25 26 #endif /* _SUBSTRING_H */ -
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3525 r3530 22 22 #include "story_entity.h" 23 23 #include "factory.h" 24 #include "game_loader.h" 24 25 25 26 using namespace std; 26 27 28 CREATE_FACTORY(Campaign); 27 29 28 30 Campaign::Campaign () … … 37 39 { 38 40 TiXmlElement* element; 39 c harstring;41 const char* string; 40 42 int id; 41 43 … … 48 50 // grab all the necessary parameters 49 51 string = grabParameter( root, "identifier"); 50 if( string == NULL || if( sscanf(string, "%d", &id) != 1))51 { 52 PRINTF( ERR)("Campaign is missing a proper 'identifier'\n");53 setStoryId( -1);54 } 55 else setStoryId( id);52 if( string == NULL || sscanf(string, "%d", &id) != 1) 53 { 54 PRINTF(1)("Campaign is missing a proper 'identifier'\n"); 55 this->setStoryID( -1); 56 } 57 else this->setStoryID( id); 56 58 57 59 // find WorldList … … 63 65 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 64 66 if( created != NULL) addEntity( created); 65 element = element-> nextSiblingElement();67 element = element->NextSiblingElement(); 66 68 } 67 69 } -
orxonox/branches/levelloader/src/story_entities/campaign.h
r3525 r3530 41 41 }; 42 42 43 CREATE_FACTORY(Campaign);44 45 43 #endif /* _CAMPAIGN_H */ -
orxonox/branches/levelloader/src/story_entities/world.cc
r3525 r3530 30 30 #include "fontset.h" 31 31 #include "factory.h" 32 #include "game_loader.h" 32 33 33 34 using namespace std; 34 35 36 CREATE_FACTORY(World); 35 37 36 38 World::World( TiXmlElement* root) 37 39 { 38 char *string, *name; 40 const char *string; 41 char *name; 39 42 int id; 40 43 41 44 // identifier 42 45 string = grabParameter( root, "identifier"); 43 if( string == NULL || if( sscanf(string, "%d", &id) != 1))44 { 45 PRINTF( ERR)("World is missing a proper 'identifier'\n");46 setStoryId( -1);47 } 48 else setStoryI d( id);46 if( string == NULL || sscanf(string, "%d", &id) != 1) 47 { 48 PRINTF(1)("World is missing a proper 'identifier'\n"); 49 this->setStoryID( -1); 50 } 51 else setStoryID( id); 49 52 50 53 // path … … 52 55 if( string == NULL) 53 56 { 54 PRINTF( ERR)("World is missing a proper 'path'\n");55 setPath( NULL);57 PRINTF(1)("World is missing a proper 'path'\n"); 58 this->setPath( NULL); 56 59 } 57 60 else … … 59 62 name = new char[strlen(string + 2)]; 60 63 strcpy( name, string); 61 setPath( name);64 this->setPath( name); 62 65 } 63 66 … … 105 108 this->nullParent->destroy(); 106 109 delete this->skySphere; 110 if( this->worldName) delete this->worldName; 111 if( this->path) delete this->path; 107 112 108 113 //delete this->trackManager; … … 137 142 if( getPath() == NULL) 138 143 { 139 PRINTF( ERR)("World has no path specified for loading");144 PRINTF(1)("World has no path specified for loading"); 140 145 return (ErrorMessage){213,"Path not specified","World::load()"}; 141 146 } 142 147 143 TiXmlDocument* XMLDoc = new TiXmlDocument( name);148 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 144 149 // load the campaign document 145 if( !XMLDoc .LoadFile())150 if( !XMLDoc->LoadFile()) 146 151 { 147 152 // report an error 148 PRINTF( ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());153 PRINTF(1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 149 154 delete XMLDoc; 150 155 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 152 157 153 158 // check basic validity 154 TiXmlElement* root = XMLDoc .RootElement();159 TiXmlElement* root = XMLDoc->RootElement(); 155 160 assert( root != NULL); 156 161 157 element = root->FirstChildElement( "WorldDataFile");162 TiXmlElement* element = root->FirstChildElement( "WorldDataFile"); 158 163 159 164 if( root == NULL ) 160 165 { 161 166 // report an error 162 PRINTF( ERR)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");167 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 163 168 delete XMLDoc; 164 169 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; … … 167 172 // load the parameters 168 173 // name 169 TiXmlElement* element;170 174 char* temp; 171 c har* string = grabParameter( root, "name");175 const char* string = grabParameter( root, "name"); 172 176 if( string == NULL) 173 177 { 174 PRINTF( ERR)("World is missing a proper 'name'\n");175 setStoryId( -1);178 PRINTF(1)("World is missing a proper 'name'\n"); 179 this->setStoryID( -1); 176 180 } 177 181 else 178 182 { 179 183 temp = new char[strlen(string + 2)]; 180 worldName = temp;184 this->worldName = temp; 181 185 } 182 186 … … 187 191 if( element == NULL) 188 192 { 189 PRINTF( ERR)("World is missing 'WorldEntities'\n");193 PRINTF(1)("World is missing 'WorldEntities'\n"); 190 194 } 191 195 else … … 197 201 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 198 202 if( created != NULL) spawn( created); 199 element = element-> nextSiblingElement();203 element = element->NextSiblingElement(); 200 204 } 201 205 } … … 205 209 if( element == NULL) 206 210 { 207 PRINTF( ERR)("World is missing a 'Track'\n");211 PRINTF(1)("World is missing a 'Track'\n"); 208 212 } 209 213 else … … 225 229 testFont->buildFont("../data/pictures/font.tga"); 226 230 227 // initializing the TrackManager228 trackManager = TrackManager::getInstance();229 trackManager->addPoint(Vector(0,-5,0));230 trackManager->addPoint(Vector(10,0,5));231 trackManager->addPoint(Vector(20,0,-5));232 trackManager->addPoint(Vector(30,0,5));233 trackManager->addPoint(Vector(40,0,5));234 trackManager->setDuration(2);235 trackManager->setSavePoint();236 trackManager->addPoint(Vector(50,10,10));237 trackManager->addPoint(Vector(60,0, 10));238 trackManager->addPoint(Vector(70,0, 10));239 trackManager->addPoint(Vector(80,0,-10));240 trackManager->addPoint(Vector(90,0,-10));241 trackManager->setDuration(5);242 trackManager->setSavePoint();243 trackManager->addPoint(Vector(110,0,5));244 trackManager->addPoint(Vector(120,0, 10));245 trackManager->addPoint(Vector(130,0, 10));246 trackManager->addPoint(Vector(140,0,-10));247 trackManager->addPoint(Vector(150,0,-10));248 trackManager->setDuration(3);249 int fork11, fork12, fork13, fork14;250 trackManager->fork(4, &fork11, &fork12, &fork13, &fork14);251 trackManager->workOn(fork11);252 trackManager->addPoint(Vector(170, 0, -15));253 trackManager->addPoint(Vector(180, 0, -15));254 trackManager->setDuration(3);255 trackManager->workOn(fork12);256 trackManager->addPoint(Vector(170, 0, 10));257 trackManager->addPoint(Vector(180, 0, 10));258 trackManager->addPoint(Vector(190,2,5));259 trackManager->addPoint(Vector(200,2,5));260 trackManager->setDuration(7);261 int fork21, fork22;262 trackManager->fork(2, &fork21, &fork22);263 trackManager->workOn(fork21);264 trackManager->addPoint(Vector(220, 10,-10));265 trackManager->addPoint(Vector(230, 0,-10));266 trackManager->addPoint(Vector(240, 0, 2));267 trackManager->addPoint(Vector(250, 0, 0));268 trackManager->addPoint(Vector(260, 0, 5));269 trackManager->setDuration(3);270 trackManager->join(2, fork12, fork11);271 trackManager->workOn(fork22);272 trackManager->addPoint(Vector(220, -10,10));273 trackManager->addPoint(Vector(230, 0, 10));274 trackManager->addPoint(Vector(240, 0, 10));275 trackManager->addPoint(Vector(250, 0, 5));276 trackManager->setDuration(6);277 trackManager->workOn(fork13);278 trackManager->addPoint(Vector(200,-10,5));279 trackManager->addPoint(Vector(250,-10,5));280 trackManager->setDuration(3);281 trackManager->workOn(fork14);282 trackManager->addPoint(Vector(200,15,0));283 trackManager->addPoint(Vector(210,0,10));284 trackManager->setDuration(1);285 trackManager->join(4, fork21, fork22, fork13, fork14);286 trackManager->workOn(10);287 trackManager->addPoint(Vector(250,-10,5));288 trackManager->addPoint(Vector(260,-10,5));289 trackManager->finalize();290 291 231 /*monitor progress*/ 292 232 this->glmis->step(); -
orxonox/branches/levelloader/src/story_entities/world.h
r3525 r3530 8 8 9 9 #include "stdincl.h" 10 10 11 #include "story_entity.h" 11 12 12 13 13 class TrackManager; … … 25 25 it is the main driving factor during gameplay. 26 26 */ 27 //#define SUBCLASS(x,y) class x : public y { 28 29 //SUBCLASS(World,StoryEntity) 27 30 class World : public StoryEntity { 28 31 29 32 public: 30 World (TiXmlElement* root) ,33 World (TiXmlElement* root); 31 34 World (char* name); 32 35 World (int worldID); … … 92 95 }; 93 96 94 CREATE_FACTORY(World);95 96 97 #endif /* _WORLD_H */ -
orxonox/branches/levelloader/src/track_manager.cc
r3525 r3530 112 112 { 113 113 // return if Found. 114 if ( this->name != NULL && !strcmp( this->name, track name))114 if ( this->name != NULL && !strcmp( this->name, trackName)) 115 115 return this; 116 116 // search on. … … 160 160 PRINTF(3)("Deleting all the TrackElements\n"); 161 161 delete this->firstTrackElem; 162 delete this->namer;162 // delete this->name; 163 163 164 164 // we do not have a TrackManager anymore … … 196 196 if( this->findTrackElementByName( names->getString(i))) 197 197 { 198 PRINTF( ERR)("Track name '%s' already taken198 PRINTF(1)("Track name '%s' already taken", names->getString(i)); 199 199 } 200 200 } … … 699 699 while( element != NULL) 700 700 { 701 if( !strcmp( element->Value(), "Point") 701 if( !strcmp( element->Value(), "Point")) 702 702 { 703 703 container = element->FirstChild(); 704 if( container != NULL && container->Type() == TEXT)704 if( container->ToText()) 705 705 { 706 706 assert( container->Value() != NULL); … … 709 709 else 710 710 { 711 PRINTF( ERR)("Invalid Point in Track (skipped)\n");711 PRINTF(1)("Invalid Point in Track (skipped)\n"); 712 712 } 713 713 } 714 714 } 715 else if( !strcmp( element->Value(), "Duration") 715 else if( !strcmp( element->Value(), "Duration")) 716 716 { 717 717 container = element->FirstChild(); 718 if( container != NULL && container->Type() == TEXT)718 if( container->ToText()) 719 719 { 720 720 assert( container->Value() != NULL); … … 723 723 else 724 724 { 725 PRINTF( ERR)("Invalid Duration in Track (skipped)\n");725 PRINTF(1)("Invalid Duration in Track (skipped)\n"); 726 726 } 727 727 } 728 728 } 729 else if( !strcmp( element->Value(), "SavePoint") 729 else if( !strcmp( element->Value(), "SavePoint")) 730 730 { 731 731 setSavePoint(); 732 732 } 733 else if( !strcmp( element->Value(), "Fork") 733 else if( !strcmp( element->Value(), "Fork")) 734 734 { 735 735 container = element->FirstChild(); 736 if( container != NULL && container->Type() == TEXT)736 if( container->ToText()) 737 737 { 738 738 assert( container->Value() != NULL); … … 740 740 } 741 741 } 742 else if( !strcmp( element->Value(), "Join") 742 else if( !strcmp( element->Value(), "Join")) 743 743 { 744 744 container = element->FirstChild(); 745 if( container != NULL && container->Type() == TEXT)745 if( container->ToText()) 746 746 { 747 747 assert( container->Value() != NULL); … … 749 749 } 750 750 } 751 else if( !strcmp( element->Value(), "WorkOn") 751 else if( !strcmp( element->Value(), "WorkOn")) 752 752 { 753 753 container = element->FirstChild(); 754 if( container != NULL && container->Type() == TEXT)754 if( container->ToText()) 755 755 { 756 756 assert( container->Value() != NULL); … … 769 769 The names used have to be unique within a particular track system. 770 770 */ 771 void TrackManager::forkS( c har* string)771 void TrackManager::forkS( const char* string) 772 772 { 773 773 // get the names for the tracks and therefore the amount of new tracks 774 SubString* names = new SubString( string);774 SubString* parts = new SubString( string); 775 775 int *IDs; 776 776 int n = parts->getN(); … … 780 780 IDs = new int[n]; 781 781 782 forkV( n, IDs, names);782 forkV( n, IDs, parts); 783 783 784 784 // IDs are irrelevant when assigning string names to tracks 785 785 delete IDs; 786 delete names;786 delete parts; 787 787 } 788 788 … … 791 791 \param string the names of the track to be joined, separated by commas 792 792 */ 793 void TrackManager::joinS( c har* string)793 void TrackManager::joinS( const char* string) 794 794 { 795 795 SubString* parts = new SubString( string); … … 805 805 t = n; 806 806 807 PRINTF( DEBUG)("Joining tracks:");807 PRINTF(4)("Joining tracks:"); 808 808 809 809 for( int i = 0; i < n; i++) … … 812 812 if( element == NULL) 813 813 { 814 PRINTF( ERR)("Track name '%s' unknown, could not join\n", parts->getString( i));814 PRINTF(1)("Track name '%s' unknown, could not join\n", parts->getString( i)); 815 815 t--; 816 816 } 817 817 else 818 818 { 819 PRINTF( DEBUG)(" '%s'(%d)", parts->getString( i), element->ID);819 PRINTF(4)(" '%s'(%d)", parts->getString( i), element->ID); 820 820 IDs[d] = element->ID; 821 821 d++; … … 823 823 } 824 824 825 PRINTF( DEBUG)("\n");825 PRINTF(4)("\n"); 826 826 827 827 joinV( t, IDs); … … 835 835 \param string the name of the track to work on (must have been previosly set by forkS) 836 836 */ 837 void TrackManager::workOnS( c har* string)837 void TrackManager::workOnS( const char* string) 838 838 { 839 839 TrackElement* tmpElem = findTrackElementByName( string); … … 841 841 this->currentTrackElem = tmpElem; 842 842 else 843 PRINTF( ERR)("TrackElement not Found, leaving unchanged\n");844 PRINTF( DEBUG)("now Working on %d\n", this->currentTrackElem->ID);845 } 843 PRINTF(1)("TrackElement not Found, leaving unchanged\n"); 844 PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID); 845 } -
orxonox/branches/levelloader/src/track_manager.h
r3525 r3530 14 14 #include "stdincl.h" 15 15 #include "curve.h" 16 #include "substring.h" 16 17 17 18 class PNode; … … 38 39 TrackElement* findByID(unsigned int trackID); 39 40 TrackElement* findByName(const char* trackName); 40 41 void setName( const char* trackName); 42 41 43 bool isFresh; //!< If no Points where added until now 42 44 bool isHotPoint; //!< If the first node is a specialPoint; … … 112 114 113 115 TrackElement* findTrackElementByID(unsigned int trackID) const; 114 TrackElement* findTrackElementByName(c har* trackName) const;116 TrackElement* findTrackElementByName(const char* trackName) const; 115 117 116 118 public: … … 133 135 void joinV(unsigned int count, int* trackIDs); 134 136 void finalize(void); 135 void forkS( c har* string);136 void joinS( c har* string);137 void workOnS( c har* string);137 void forkS( const char* string); 138 void joinS( const char* string); 139 void workOnS( const char* string); 138 140 139 141 // Method to load track data from file
Note: See TracChangeset
for help on using the changeset viewer.