Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3530 in orxonox.OLD for orxonox/branches/levelloader


Ignore:
Timestamp:
Mar 13, 2005, 10:40:25 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: Got the system to compile, the basic backbone now runs. What remains to be done is implementing all necessary functions to load all vital classes into a world

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.5 from Makefile.am.
     1# Makefile.in generated by automake 1.8.2 from Makefile.am.
    22# @configure_input@
    33
     
    3838        $(srcdir)/Makefile.in $(srcdir)/config.h.in \
    3939        $(srcdir)/doc/documentation.am $(top_srcdir)/configure AUTHORS \
    40         COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \
    41         install-sh missing mkinstalldirs
     40        COPYING ChangeLog INSTALL NEWS TODO config.guess config.sub \
     41        depcomp install-sh missing mkinstalldirs
    4242subdir = .
    4343ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    326326        tags=; \
    327327        here=`pwd`; \
    328         if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
     328        if (etags --etags-include --version) >/dev/null 2>&1; then \
    329329          include_option=--etags-include; \
    330           empty_fix=.; \
    331330        else \
    332331          include_option=--include; \
    333           empty_fix=; \
    334332        fi; \
    335333        list='$(SUBDIRS)'; for subdir in $$list; do \
    336334          if test "$$subdir" = .; then :; else \
    337             test ! -f $$subdir/TAGS || \
     335            test -f $$subdir/TAGS && \
    338336              tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
    339337          fi; \
     
    345343          $(AWK) '    { files[$$0] = 1; } \
    346344               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
    352348ctags: CTAGS
    353349CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
     
    458454          uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
    459455        *.shar.gz*) \
    460           GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
     456          GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | unshar ;;\
    461457        *.zip*) \
    462458          unzip $(distdir).zip ;;\
     
    481477          && chmod -R a-w "$$dc_install_base" \
    482478          && ({ \
    483                (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
     479               (cd ../.. && $(mkdir_p) "$$dc_destdir") \
    484480               && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
    485481               && $(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 -*-
    22
    33# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
     
    4141# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
    4242AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
    43          [AM_AUTOMAKE_VERSION([1.8.5])])
     43         [AM_AUTOMAKE_VERSION([1.8.2])])
    4444
    4545# AM_AUX_DIR_EXPAND
     
    150150fi])])
    151151
    152 # serial 7                                              -*- Autoconf -*-
     152# serial 6                                              -*- Autoconf -*-
    153153
    154154# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
     
    237237    for i in 1 2 3 4 5 6; do
    238238      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
    242240    done
    243241    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    267265       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    268266      # 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
    277270        am_cv_$1_dependencies_compiler_type=$depmode
    278271        break
     
    320313# Generate code to set up dependency tracking.   -*- Autoconf -*-
    321314
    322 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
     315# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    323316
    324317# This program is free software; you can redistribute it and/or modify
     
    359352  # Extract the definition of DEP_FILES from the Makefile without
    360353  # running `make'.
    361   DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     354  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
    362355  test -z "$DEPDIR" && continue
    363356  # 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"`
    365358  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
    366359  # We invoke sed twice because it is the simplest approach to
    367360  # changing $(DEPDIR) to its actual value in the expansion.
    368   for file in `sed -n '
     361  for file in `sed -n -e '
    369362    /^DEP_FILES = .*\\\\$/ {
    370363      s/^DEP_FILES = //
     
    725718# Do not use -m 0755 and let people choose whatever they expect by
    726719# 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 a
    730 # 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 only
    732 # one can create it and the other will error out.  Consequently we
    733 # restrict ourselves to GNU make (using the --version option ensures
    734 # this.)
    735720AC_DEFUN([AM_PROG_MKDIR_P],
    736 [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
     721[if mkdir -p -- . 2>/dev/null; then
    737722  # Keeping the `.' argument allows $(mkdir_p) to be used without
    738723  # argument.  Indeed, we sometimes output rules like
     
    747732  # directories to create, and then abort because `.' already
    748733  # exists.
    749   for d in ./-p ./--version;
     734  for d in ./-p ./--;
    750735  do
    751736    test -d $d && rmdir $d
  • orxonox/branches/levelloader/configure

    r3499 r3530  
    15991599fi
    16001600
    1601 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
     1601if mkdir -p -- . 2>/dev/null; then
    16021602  # Keeping the `.' argument allows $(mkdir_p) to be used without
    16031603  # argument.  Indeed, we sometimes output rules like
     
    16121612  # directories to create, and then abort because `.' already
    16131613  # exists.
    1614   for d in ./-p ./--version;
     1614  for d in ./-p ./--;
    16151615  do
    16161616    test -d $d && rmdir $d
     
    25182518    for i in 1 2 3 4 5 6; do
    25192519      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
    25232521    done
    25242522    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    25482546       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    25492547      # 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
    25582551        am_cv_CXX_dependencies_compiler_type=$depmode
    25592552        break
     
    33563349    for i in 1 2 3 4 5 6; do
    33573350      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
    33613352    done
    33623353    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
     
    33863377       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
    33873378      # 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
    33963382        am_cv_CC_dependencies_compiler_type=$depmode
    33973383        break
     
    95739559  # Extract the definition of DEP_FILES from the Makefile without
    95749560  # running `make'.
    9575   DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     9561  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
    95769562  test -z "$DEPDIR" && continue
    95779563  # 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"`
    95799565  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
    95809566  # We invoke sed twice because it is the simplest approach to
    95819567  # changing $(DEPDIR) to its actual value in the expansion.
    9582   for file in `sed -n '
     9568  for file in `sed -n -e '
    95839569    /^DEP_FILES = .*\\\\$/ {
    95849570      s/^DEP_FILES = //
  • orxonox/branches/levelloader/src/defs/debug.h

    r3499 r3530  
    2222#define _DEBUG_H
    2323
     24#if HAVE_CONFIG_H
     25#include <config.h>
     26#endif
     27
     28#include <stdio.h>
     29
    2430#define NO              0
    2531#define ERR             1
     
    2834#define DEBUGING        4
    2935
    30 #if HAVE_CONFIG_H
    31 #include <config.h>
    32 #endif
    33 
    34 #include <stdio.h>
    35 
    3636///////////////////////////////////////////////////
    3737/// PRINTF: prints with filename and linenumber ///
    3838///////////////////////////////////////////////////
    39 
    4039#ifdef DEBUG
    4140extern int verbose;
    4241#define PRINTF(x) \
    4342           PRINTF ## x
    44 
     43           
    4544#if DEBUG >= ERR
    4645#define PRINTF1 \
     
    9291#define PRINT(x) \
    9392  PRINT ## x
    94 
     93 
    9594#if DEBUG >= ERR
    9695#define PRINT1  \
  • orxonox/branches/levelloader/src/defs/error.h

    r3499 r3530  
    2323
    2424
    25 #ifndef _ERROR_H
    26 #define _ERROR_H
     25#ifndef _ORX_ERROR_H
     26#define _ORX_ERROR_H
    2727
    2828// these are the two undefined error nr. Don't use them ...
     
    5454*/
    5555
    56 typedef struct
     56typedef struct ErrorMessage
    5757{
    5858  int code;
  • orxonox/branches/levelloader/src/defs/stdincl.h

    r3525 r3530  
    88#ifndef _STDINCL_H
    99#define _STDINCL_H
    10 
     10               
    1111#define null 0   //!< null
    1212
     
    2222#endif
    2323
     24#include <assert.h>
    2425#include <stdlib.h>
    2526#include <string.h>
     
    2728#include "glincl.h"
    2829
     30#include "error.h"
     31#include "debug.h"
    2932
    3033// MATH //
     
    4144#include "factory.h"
    4245
    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;
    4560
    4661#endif /* _STDINCL_H */
  • orxonox/branches/levelloader/src/factory.cc

    r3525 r3530  
    1818
    1919#include "factory.h"
     20#include "game_loader.h"
    2021
    2122using namespace std;
     
    3334Factory::Factory ()
    3435{
    35         classname = "NULL"
     36        classname = "NULL";
    3637        next = NULL;
    3738}
    3839
    3940/**
    40    \brief constructor
     41   \brief destructor
    4142   
    4243   clear the Q
     
    5152   \brief generates the associated object from data
    5253*/
    53 BaseObject* ObjectFactory::fabricate( TiXmlElement* data)
     54BaseObject* Factory::fabricate( TiXmlElement* data)
    5455{
    5556        return NULL;
     
    6162void Factory::initialize()
    6263{
     64        assert( classname != NULL);
     65        PRINTF(3)("Initializing %sFactory\n", classname);
    6366        GameLoader* gl = GameLoader::getInstance();
    6467        gl->registerFactory( this);
     
    8891        while( node != NULL)
    8992        {
    90                 if( node->Type() == TEXT) return node->Value();
    91                 node = node->NextChild();
     93                if( node->ToText()) return node->Value();
     94                node = node->NextSibling();
    9295        }
    9396        return NULL;
  • orxonox/branches/levelloader/src/factory.h

    r3525 r3530  
    88
    99#include "stdincl.h"
    10 #include "world.h"
    1110
    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;
     11class BaseObject;
    2512
    2613//! The Factory is
     
    3724        void initialize();
    3825  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;}
    4230       
    4331 private:
  • orxonox/branches/levelloader/src/game_loader.cc

    r3525 r3530  
    1515   co-programmer: ...
    1616*/
    17 
    1817
    1918#include "game_loader.h"
     
    162161  if( name == NULL)
    163162  {
    164                 PRINTF(ERR)("No filename specified for loading");
     163                PRINTF(1)("No filename specified for loading");
    165164                return NULL;
    166165  }
     
    168167        TiXmlDocument* XMLDoc = new TiXmlDocument( name);
    169168        // load the campaign document
    170         if( !XMLDoc.LoadFile())
     169        if( !XMLDoc->LoadFile())
    171170        {
    172171                // 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());
    174173                delete XMLDoc;
    175174                return NULL;
     
    177176       
    178177        // check basic validity
    179         TiXmlElement* element = XMLDoc.RootElement();
     178        TiXmlElement* element = XMLDoc->RootElement();
    180179        assert( element != NULL);
    181180       
     
    185184        {
    186185                // 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");
    188187                delete XMLDoc;
    189188                return NULL;
     
    191190       
    192191        // construct campaign
    193         Campaign c = new Campaign( element);
     192        Campaign* c = new Campaign( element);
    194193       
    195194        // free the XML data
    196195        delete XMLDoc;
     196       
     197        return c;
    197198}
    198199
     
    269270void GameLoader::registerFactory( Factory* factory)
    270271{
    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);
    273278}
    274279
     
    277282   \param element a XMLElement containing all the needed info
    278283*/
    279 StoryEntity* GameLoader::fabricate( TiXmlElement* element)
     284BaseObject* GameLoader::fabricate( TiXmlElement* element)
    280285{
    281286        if( first == NULL)
    282287        {
    283                 PRINTF(ERR)("GameLoader does not know any factories, fabricate() failed\n");
     288                PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n");
    284289                return NULL;
    285290        }
  • orxonox/branches/levelloader/src/game_loader.h

    r3525 r3530  
    44#include "stdincl.h"
    55#include "story_def.h"
     6#include "factory.h"
    67
    78//-----------------------------------------------------------------------------
  • orxonox/branches/levelloader/src/lib/util/substring.cc

    r3525 r3530  
    2222#include "substring.h"
    2323
    24 SubString::SubString( char* string)
     24SubString::SubString( const char* string)
    2525{
    2626        n = 0;
     
    3232        n += 1;
    3333       
    34         strings = malloc( sizeof( char*) * n);
     34        strings = new char*[n];
    3535       
    3636        int i = 0;
    3737        int l = 0;
    3838       
    39         char* offset = string;
     39        const char* offset = string;
    4040        char* end = strchr( string, ',');
    4141        while( end != NULL)
    4242        {
    4343                l = end - offset;
    44                 strings[i] = malloc( l + 1);
     44                strings[i] = new char[l + 1];
    4545                strncpy( strings[i], offset, l);
    4646                i++;
     
    5050        }
    5151       
    52         strings[i] = malloc( l + 1);
     52        strings[i] = new char[l + 1];
    5353        strncpy( strings[i], offset, l);
    5454        l = strlen( offset);
     
    6262        for( int i = 0; i < n; i++)
    6363        {
    64                 free( strings[i]);
     64                delete strings[i];
    6565        }
    6666       
    67         free( strings);
     67        delete strings;
    6868}
    6969
  • orxonox/branches/levelloader/src/lib/util/substring.h

    r3525 r3530  
    33    \brief a small class to get the parts of a string separated by commas
    44*/
     5
     6#ifndef _SUBSTRING_H
     7#define _SUBSTRING_H
    58
    69#include "stdincl.h"
     
    1013        public:
    1114       
    12                 SubString( char* string);
     15                SubString( const char* string);
    1316                ~SubString();
    1417               
     
    2023                int n;
    2124};
     25
     26#endif /* _SUBSTRING_H */
  • orxonox/branches/levelloader/src/story_entities/campaign.cc

    r3525 r3530  
    2222#include "story_entity.h"
    2323#include "factory.h"
     24#include "game_loader.h"
    2425
    2526using namespace std;
    2627
     28CREATE_FACTORY(Campaign);
    2729
    2830Campaign::Campaign ()
     
    3739{
    3840        TiXmlElement* element;
    39         char string;
     41        const char* string;
    4042        int id;
    4143       
     
    4850  // grab all the necessary parameters
    4951        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);
    5658       
    5759  // find WorldList
     
    6365                StoryEntity* created = (StoryEntity*) loader->fabricate( element);
    6466                if( created != NULL) addEntity( created);
    65                 element = element->nextSiblingElement();
     67                element = element->NextSiblingElement();
    6668        }
    6769}
  • orxonox/branches/levelloader/src/story_entities/campaign.h

    r3525 r3530  
    4141};
    4242
    43 CREATE_FACTORY(Campaign);
    44 
    4543#endif /* _CAMPAIGN_H */
  • orxonox/branches/levelloader/src/story_entities/world.cc

    r3525 r3530  
    3030#include "fontset.h"
    3131#include "factory.h"
     32#include "game_loader.h"
    3233
    3334using namespace std;
    3435
     36CREATE_FACTORY(World);
    3537
    3638World::World( TiXmlElement* root)
    3739{
    38         char *string, *name;
     40        const char *string;
     41        char *name;
    3942        int id;
    4043
    4144        // identifier
    4245        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 setStoryId( 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);
    4952       
    5053        // path
     
    5255        if( string == NULL)
    5356        {
    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);
    5659        }
    5760        else
     
    5962                name = new char[strlen(string + 2)];
    6063                strcpy( name, string);
    61                 setPath( name);
     64                this->setPath( name);
    6265        }
    6366       
     
    105108  this->nullParent->destroy(); 
    106109  delete this->skySphere;
     110  if( this->worldName) delete this->worldName;
     111  if( this->path) delete this->path;
    107112
    108113  //delete this->trackManager;
     
    137142  if( getPath() == NULL)
    138143  {
    139                 PRINTF(ERR)("World has no path specified for loading");
     144                PRINTF(1)("World has no path specified for loading");
    140145                return (ErrorMessage){213,"Path not specified","World::load()"};
    141146  }
    142147 
    143         TiXmlDocument* XMLDoc = new TiXmlDocument( name);
     148        TiXmlDocument* XMLDoc = new TiXmlDocument( path);
    144149        // load the campaign document
    145         if( !XMLDoc.LoadFile())
     150        if( !XMLDoc->LoadFile())
    146151        {
    147152                // 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());
    149154                delete XMLDoc;
    150155                return (ErrorMessage){213,"XML File parsing error","World::load()"};
     
    152157       
    153158        // check basic validity
    154         TiXmlElement* root = XMLDoc.RootElement();
     159        TiXmlElement* root = XMLDoc->RootElement();
    155160        assert( root != NULL);
    156161       
    157         element = root->FirstChildElement( "WorldDataFile");
     162        TiXmlElement* element = root->FirstChildElement( "WorldDataFile");
    158163       
    159164        if( root == NULL )
    160165        {
    161166                // 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");
    163168                delete XMLDoc;
    164169                return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     
    167172        // load the parameters
    168173                // name
    169         TiXmlElement* element;
    170174        char* temp;
    171         char* string = grabParameter( root, "name");
     175        const char* string = grabParameter( root, "name");
    172176        if( string == NULL)
    173177        {
    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);
    176180        }
    177181        else
    178182        {
    179183                temp = new char[strlen(string + 2)];
    180                 worldName = temp;
     184                this->worldName = temp;
    181185        }
    182186       
     
    187191  if( element == NULL)
    188192  {
    189                 PRINTF(ERR)("World is missing 'WorldEntities'\n");
     193                PRINTF(1)("World is missing 'WorldEntities'\n");
    190194  }
    191195  else
     
    197201                        WorldEntity* created = (WorldEntity*) loader->fabricate( element);
    198202                        if( created != NULL) spawn( created);
    199                         element = element->nextSiblingElement();
     203                        element = element->NextSiblingElement();
    200204                }
    201205        }
     
    205209  if( element == NULL)
    206210  {
    207                 PRINTF(ERR)("World is missing a 'Track'\n");
     211                PRINTF(1)("World is missing a 'Track'\n");
    208212  }
    209213  else
     
    225229      testFont->buildFont("../data/pictures/font.tga");
    226230
    227       // initializing the TrackManager
    228       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      
    291231      /*monitor progress*/
    292232      this->glmis->step();
  • orxonox/branches/levelloader/src/story_entities/world.h

    r3525 r3530  
    88
    99#include "stdincl.h"
     10
    1011#include "story_entity.h"
    11 
    1212
    1313class TrackManager;
     
    2525   it is the main driving factor during gameplay.
    2626*/
     27//#define SUBCLASS(x,y) class x : public y {
     28
     29//SUBCLASS(World,StoryEntity)
    2730class World : public StoryEntity {
    2831
    2932 public:
    30         World (TiXmlElement* root),
     33        World (TiXmlElement* root);
    3134  World (char* name);
    3235  World (int worldID);
     
    9295};
    9396
    94 CREATE_FACTORY(World);
    95 
    9697#endif /* _WORLD_H */
  • orxonox/branches/levelloader/src/track_manager.cc

    r3525 r3530  
    112112{
    113113  // return if Found.
    114   if ( this->name != NULL && !strcmp( this->name, trackname))
     114  if ( this->name != NULL && !strcmp( this->name, trackName))
    115115    return this;
    116116  // search on.
     
    160160  PRINTF(3)("Deleting all the TrackElements\n");
    161161  delete this->firstTrackElem;
    162   delete this->namer;
     162  // delete this->name;
    163163
    164164  // we do not have a TrackManager anymore
     
    196196                if( this->findTrackElementByName( names->getString(i)))
    197197                {
    198                         PRINTF(ERR)("Track name '%s' already taken
     198                        PRINTF(1)("Track name '%s' already taken", names->getString(i));
    199199                }
    200200            }
     
    699699        while( element != NULL)
    700700        {
    701                 if( !strcmp( element->Value(), "Point")
     701                if( !strcmp( element->Value(), "Point"))
    702702                {
    703703                        container = element->FirstChild();
    704                         if( container != NULL && container->Type() == TEXT)
     704                        if( container->ToText())
    705705                        {
    706706                                assert( container->Value() != NULL);
     
    709709                                else
    710710                                {
    711                                         PRINTF(ERR)("Invalid Point in Track (skipped)\n");
     711                                        PRINTF(1)("Invalid Point in Track (skipped)\n");
    712712                                }                       
    713713                        }
    714714                }
    715                 else if( !strcmp( element->Value(), "Duration")
     715                else if( !strcmp( element->Value(), "Duration"))
    716716                {
    717717                        container = element->FirstChild();
    718                         if( container != NULL && container->Type() == TEXT)
     718                        if( container->ToText())
    719719                        {
    720720                                assert( container->Value() != NULL);
     
    723723                                else
    724724                                {
    725                                         PRINTF(ERR)("Invalid Duration in Track (skipped)\n");
     725                                        PRINTF(1)("Invalid Duration in Track (skipped)\n");
    726726                                }                       
    727727                        }
    728728                }
    729                 else if( !strcmp( element->Value(), "SavePoint")
     729                else if( !strcmp( element->Value(), "SavePoint"))
    730730                {
    731731                        setSavePoint();
    732732                }
    733                 else if( !strcmp( element->Value(), "Fork")
     733                else if( !strcmp( element->Value(), "Fork"))
    734734                {
    735735                        container = element->FirstChild();
    736                         if( container != NULL && container->Type() == TEXT)
     736                        if( container->ToText())
    737737                        {
    738738                                assert( container->Value() != NULL);
     
    740740                        }
    741741                }
    742                 else if( !strcmp( element->Value(), "Join")
     742                else if( !strcmp( element->Value(), "Join"))
    743743                {
    744744                        container = element->FirstChild();
    745                         if( container != NULL && container->Type() == TEXT)
     745                        if( container->ToText())
    746746                        {
    747747                                assert( container->Value() != NULL);
     
    749749                        }
    750750                }
    751                 else if( !strcmp( element->Value(), "WorkOn")
     751                else if( !strcmp( element->Value(), "WorkOn"))
    752752                {
    753753                        container = element->FirstChild();
    754                         if( container != NULL && container->Type() == TEXT)
     754                        if( container->ToText())
    755755                        {
    756756                                assert( container->Value() != NULL);
     
    769769   The names used have to be unique within a particular track system.
    770770*/
    771 void TrackManager::forkS( char* string)
     771void TrackManager::forkS( const char* string)
    772772{
    773773        // 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);
    775775        int *IDs;
    776776        int n = parts->getN();
     
    780780        IDs = new int[n];
    781781       
    782         forkV( n, IDs, names);
     782        forkV( n, IDs, parts);
    783783       
    784784        // IDs are irrelevant when assigning string names to tracks
    785785        delete IDs;
    786         delete names;
     786        delete parts;
    787787}
    788788
     
    791791   \param string the names of the track to be joined, separated by commas
    792792*/
    793 void TrackManager::joinS( char* string)
     793void TrackManager::joinS( const char* string)
    794794{
    795795        SubString* parts = new SubString( string);
     
    805805        t = n;
    806806       
    807         PRINTF(DEBUG)("Joining tracks:");
     807        PRINTF(4)("Joining tracks:");
    808808       
    809809        for( int i = 0; i < n; i++)
     
    812812                if( element == NULL)
    813813                {
    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));
    815815                        t--;
    816816                }
    817817                else
    818818                {
    819                         PRINTF(DEBUG)(" '%s'(%d)", parts->getString( i), element->ID);
     819                        PRINTF(4)(" '%s'(%d)", parts->getString( i), element->ID);
    820820                        IDs[d] = element->ID;
    821821                        d++;
     
    823823        }
    824824       
    825         PRINTF(DEBUG)("\n");
     825        PRINTF(4)("\n");
    826826
    827827        joinV( t, IDs);
     
    835835   \param string the name of the track to work on (must have been previosly set by forkS)
    836836*/
    837 void TrackManager::workOnS( char* string)
     837void TrackManager::workOnS( const char* string)
    838838{
    839839  TrackElement* tmpElem = findTrackElementByName( string);
     
    841841    this->currentTrackElem = tmpElem;
    842842  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  
    1414#include "stdincl.h"
    1515#include "curve.h"
     16#include "substring.h"
    1617
    1718class PNode;
     
    3839  TrackElement* findByID(unsigned int trackID);
    3940  TrackElement* findByName(const char* trackName);
    40 
     41        void setName( const char* trackName);
     42       
    4143  bool isFresh;              //!< If no Points where added until now
    4244  bool isHotPoint;           //!< If the first node is a specialPoint;
     
    112114
    113115  TrackElement* findTrackElementByID(unsigned int trackID) const;
    114   TrackElement* findTrackElementByName(char* trackName) const;
     116  TrackElement* findTrackElementByName(const char* trackName) const;
    115117 
    116118 public:
     
    133135  void joinV(unsigned int count, int* trackIDs);
    134136  void finalize(void);
    135         void forkS( char* string);
    136         void joinS( char* string);
    137         void workOnS( char* string);
     137        void forkS( const char* string);
     138        void joinS( const char* string);
     139        void workOnS( const char* string);
    138140
    139141        // Method to load track data from file
Note: See TracChangeset for help on using the changeset viewer.