Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2087 for code/trunk


Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
37 deleted
207 edited
95 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/TODO

    r1907 r2087  
    11todo:
     2
     3        bidirectional
     4
     5        minimize synchronisableHeader
     6
     7
    28        !!! check that enet does not cause a packet traffic jam when a reliable packet gets missed !!!
    3         [implemented] new gamestate concept
    4 
    59        !!! ensure that objects get synched, when newly created, even if not their tick
    610
     
    1216
    1317REMARKS:
    14         try to allocate sort the bytestream before copy (putt all 0's in one place)
     18        try to sort the bytestream before copy (putt all 0's in one place)
  • code/trunk/bin/def_keybindings.ini

    r1887 r2087  
    11[Keys]
    2 KeyA="scale -1 moveLateral"
     2KeyA="scale -1 moveRightLeft"
    33KeyABNT_C1=
    44KeyABNT_C2=
     
    1010KeyBack=
    1111KeyBackslash=
    12 KeyC=
     12KeyC=switchCamera
    1313KeyCalculator=
    1414KeyCapsLock=
     
    1616KeyComma=
    1717KeyConvert=
    18 KeyD="scale 1 moveLateral"
     18KeyD="scale 1 moveRightLeft"
    1919KeyDelete=
    2020KeyDivide=
    2121KeyDown=
    22 KeyE="scale -1 moveRoll"
     22KeyE="scale -1 rotateRoll"
    2323KeyEnd=
    2424KeyEquals=
    2525KeyEscape="exit"
    26 KeyF=
     26KeyF="scale -1 moveUpDown"
    2727KeyF1="OverlayGroup toggleVisibility Debug"
    2828KeyF10=
     
    4040KeyF8=
    4141KeyF9=
    42 KeyG=
     42KeyG=greet
    4343KeyGrave="openConsole"
    4444KeyH=
     
    105105KeyPower=
    106106KeyPreviousTrack=
    107 KeyQ="scale 1 moveRoll"
    108 KeyR=
     107KeyQ="scale 1 rotateRoll"
     108KeyR="scale 1 moveUpDown"
    109109KeyReturn=
    110110KeyRight=
     
    114114KeyRightShift=
    115115KeyRightWindows=
    116 KeyS="scale -1 moveLongitudinal"
     116KeyS="scale -1 moveFrontBack"
    117117KeyScrollLock=
    118118KeySemicolon=
     
    132132KeyVolumeDown=
    133133KeyVolumeUp=
    134 KeyW="scale 1 moveLongitudinal"
     134KeyW="scale 1 moveFrontBack"
    135135KeyWake=
    136136KeyWebBack=
     
    254254
    255255[MouseAxes]
    256 MouseXNeg="scale 1 moveYaw"
    257 MouseXPos="scale -1 moveYaw"
    258 MouseYNeg="scale 1 movePitch"
    259 MouseYPos="scale -1 movePitch"
     256MouseXNeg="scale -1 rotateYaw"
     257MouseXPos="scale 1 rotateYaw"
     258MouseYNeg="scale 1 rotatePitch"
     259MouseYPos="scale -1 rotatePitch"
    260260
  • code/trunk/init/common/def_keybindings.ini

    r1897 r2087  
    11[Keys]
    2 KeyA="scale -1 moveLateral"
     2KeyA="scale -1 moveRightLeft"
    33KeyABNT_C1=
    44KeyABNT_C2=
     
    1616KeyComma=
    1717KeyConvert=
    18 KeyD="scale 1 moveLateral"
     18KeyD="scale 1 moveRightLeft"
    1919KeyDelete=
    2020KeyDivide=
    2121KeyDown=
    22 KeyE="scale -1 moveRoll"
     22KeyE="scale -1 rotateRoll"
    2323KeyEnd=
    2424KeyEquals=
    2525KeyEscape="exit"
    26 KeyF=
     26KeyF="scale -1 moveUpDown"
    2727KeyF1="OverlayGroup toggleVisibility Debug"
    2828KeyF10=
     
    4040KeyF8=
    4141KeyF9=
    42 KeyG=
     42KeyG=greet
    4343KeyGrave="openConsole"
    4444KeyH=
     
    105105KeyPower=
    106106KeyPreviousTrack=
    107 KeyQ="scale 1 moveRoll"
    108 KeyR=
     107KeyQ="scale 1 rotateRoll"
     108KeyR="scale 1 moveUpDown"
    109109KeyReturn=
    110110KeyRight=
     
    114114KeyRightShift=
    115115KeyRightWindows=
    116 KeyS="scale -1 moveLongitudinal"
     116KeyS="scale -1 moveFrontBack"
    117117KeyScrollLock=
    118118KeySemicolon=
     
    132132KeyVolumeDown=
    133133KeyVolumeUp=
    134 KeyW="scale 1 moveLongitudinal"
     134KeyW="scale 1 moveFrontBack"
    135135KeyWake=
    136136KeyWebBack=
     
    254254
    255255[MouseAxes]
    256 MouseXNeg="scale 1 moveYaw"
    257 MouseXPos="scale -1 moveYaw"
    258 MouseYNeg="scale 1 movePitch"
    259 MouseYPos="scale -1 movePitch"
     256MouseXNeg="scale -1 rotateYaw"
     257MouseXPos="scale 1 rotateYaw"
     258MouseYNeg="scale 1 rotatePitch"
     259MouseYPos="scale -1 rotatePitch"
    260260
  • code/trunk/src/core/ArgumentCompletionFunctions.cc

    r1505 r2087  
    3030#include <map>
    3131
    32 #include "boost/filesystem.hpp"
     32#include <boost/filesystem.hpp>
    3333
    3434#include "ArgumentCompletionFunctions.h"
  • code/trunk/src/core/BaseObject.cc

    r1625 r2087  
    3535#include "tinyxml/tinyxml.h"
    3636#include "CoreIncludes.h"
     37#include "EventIncludes.h"
    3738#include "XMLPort.h"
    38 #include "Level.h"
     39#include "XMLFile.h"
     40#include "XMLNameListener.h"
     41#include "Template.h"
     42#include "util/String.h"
    3943
    4044namespace orxonox
     
    4549        @brief Constructor: Registers the object in the BaseObject-list.
    4650    */
    47     BaseObject::BaseObject() : bInitialized_(false)
     51    BaseObject::BaseObject(BaseObject* creator) : bInitialized_(false)
    4852    {
    4953        RegisterRootObject(BaseObject);
     
    5357        this->bActive_ = true;
    5458        this->bVisible_ = true;
    55 
    56         this->level_ = 0;
    57         this->namespace_ = 0;
     59        this->oldGametype_ = 0;
     60
     61        this->setCreator(creator);
     62        if (this->creator_)
     63        {
     64            this->setFile(this->creator_->getFile());
     65            this->setNamespace(this->creator_->getNamespace());
     66            this->setScene(this->creator_->getScene());
     67            this->setGametype(this->creator_->getGametype());
     68        }
     69        else
     70        {
     71            this->file_ = 0;
     72            this->namespace_ = 0;
     73            this->scene_ = 0;
     74            this->gametype_ = 0;
     75        }
    5876    }
    5977
     
    6381    BaseObject::~BaseObject()
    6482    {
     83        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
     84            (*it)->unregisterEventListener(this);
     85
     86        for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     87            it->first->removeEvent(this);
    6588    }
    6689
     
    7396    void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7497    {
    75         XMLPortParam(BaseObject, "name", setName, getName, xmlelement, mode);
     98        XMLPortParam(BaseObject, "name", setXMLName, getName, xmlelement, mode);
    7699        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
    77100        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
     101
     102        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
     103
     104        Element* events = xmlelement.FirstChildElement("events", false);
     105
     106        if (events)
     107        {
     108            std::list<std::string> eventnames;
     109
     110            if (mode == XMLPort::LoadObject)
     111            {
     112                for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
     113                    eventnames.push_back(child->Value());
     114            }
     115            else if (mode == XMLPort::SaveObject)
     116            {
     117                for (std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->getIdentifier()->getXMLPortEventMapBegin(); it != this->getIdentifier()->getXMLPortEventMapEnd(); ++it)
     118                    eventnames.push_back(it->first);
     119            }
     120
     121            for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
     122            {
     123                std::string sectionname = (*it);
     124                ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEvent), std::string( "BaseObject" ) + "::" + "addEvent");
     125                ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEvent), std::string( "BaseObject" ) + "::" + "getEvent");
     126                loadexecutor->setDefaultValue(1, sectionname);
     127
     128                XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;
     129                container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(this->getIdentifier()->getXMLPortEventContainer(sectionname));
     130                if (!container)
     131                {
     132                    container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(sectionname, this->getIdentifier(), loadexecutor, saveexecutor, false, true);
     133                    this->getIdentifier()->addXMLPortEventContainer(sectionname, container);
     134                }
     135                container->port(this, *events, mode);
     136            }
     137        }
     138    }
     139
     140    /**
     141        @brief Loads the name of the object through XML and calls all XMLNameListener.
     142        @param name The name of the object
     143    */
     144    void BaseObject::setXMLName(const std::string& name)
     145    {
     146        this->setName(name);
     147
     148        for (ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it)
     149            it->loadedNewXMLName(this);
    78150    }
    79151
     
    82154        @return The levelfile
    83155    */
    84     const std::string& BaseObject::getLevelfile() const
    85     {
    86         return this->level_->getFile();
     156    const std::string& BaseObject::getFilename() const
     157    {
     158        if (this->file_)
     159            return this->file_->getFilename();
     160        else
     161            return BLANKSTRING;
     162    }
     163
     164    /**
     165        @brief Adds a Template to the object.
     166        @param name The name of the Template
     167    */
     168    void BaseObject::addTemplate(const std::string& name)
     169    {
     170        Template* temp = Template::getTemplate(name);
     171        if (temp)
     172            this->addTemplate(temp);
     173        else
     174            COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;
     175    }
     176
     177    /**
     178        @brief Adds a Template to the object.
     179        @param temp The Template
     180    */
     181    void BaseObject::addTemplate(Template* temp)
     182    {
     183        this->templates_.insert(temp);
     184        temp->applyOn(this);
     185    }
     186
     187    /**
     188        @brief Returns the Template with the given index.
     189        @param index The index
     190    */
     191    Template* BaseObject::getTemplate(unsigned int index) const
     192    {
     193        unsigned int i = 0;
     194        for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
     195        {
     196            if (i == index)
     197                return (*it);
     198            i++;
     199        }
     200        return 0;
     201    }
     202
     203    void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)
     204    {
     205        event->registerEventListener(this, sectionname);
     206        this->events_.push_back(event);
     207    }
     208
     209    void BaseObject::removeEvent(BaseObject* event)
     210    {
     211        this->events_.remove(event);
     212    }
     213
     214    BaseObject* BaseObject::getEvent(unsigned int index) const
     215    {
     216        unsigned int i = 0;
     217        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
     218        {
     219            if (i == index)
     220                return (*it);
     221            ++i;
     222        }
     223        return 0;
     224    }
     225
     226    void BaseObject::addEventContainer(const std::string& sectionname, EventContainer* container)
     227    {
     228        std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
     229        if (it != this->eventContainers_.end())
     230        {
     231            COUT(2) << "Warning: Overwriting EventContainer in class " << this->getIdentifier()->getName() << "." << std::endl;
     232            delete (it->second);
     233        }
     234
     235        this->eventContainers_[sectionname] = container;
     236    }
     237
     238    EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const
     239    {
     240        std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
     241        if (it != this->eventContainers_.end())
     242            return ((*it).second);
     243        else
     244            return 0;
     245    }
     246
     247    void BaseObject::fireEvent()
     248    {
     249        this->fireEvent(true);
     250        this->fireEvent(false);
     251    }
     252
     253    void BaseObject::fireEvent(bool activate)
     254    {
     255        this->fireEvent(activate, this);
     256    }
     257
     258    void BaseObject::fireEvent(bool activate, BaseObject* originator)
     259    {
     260        Event event(activate, originator);
     261
     262        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     263        {
     264            event.sectionname_ = it->second;
     265            it->first->processEvent(event);
     266        }
     267    }
     268
     269    void BaseObject::fireEvent(Event& event)
     270    {
     271        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     272            it->first->processEvent(event);
     273    }
     274
     275    void BaseObject::processEvent(Event& event)
     276    {
     277        SetEvent(BaseObject, "activity", setActive, event);
     278        SetEvent(BaseObject, "visibility", setVisible, event);
    87279    }
    88280}
  • code/trunk/src/core/BaseObject.h

    r1841 r2087  
    3737#define _BaseObject_H__
    3838
     39#include <map>
     40
    3941#include "CorePrereqs.h"
    4042
     
    4244#include "OrxonoxClass.h"
    4345#include "XMLIncludes.h"
     46#include "Event.h"
    4447
    4548namespace orxonox
    4649{
     50    class Scene;
     51    class Gametype;
     52
    4753    //! The BaseObject is the parent of all classes representing an instance in the game.
    4854    class _CoreExport BaseObject : virtual public OrxonoxClass
    4955    {
    50         friend class WorldEntity;
    51 
    5256        public:
    53             BaseObject();
     57            BaseObject(BaseObject* creator);
    5458            virtual ~BaseObject();
    5559            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     
    5963
    6064            /** @brief Sets the name of the object. @param name The name */
    61             inline void setName(const std::string& name) { this->name_ = name; this->changedName(); }
    62             /** @brief Returns the name of the object. @return The name */
     65            inline void setName(const std::string& name) { this->oldName_ = this->name_; this->name_ = name; this->changedName(); }
     66            /** @brief Returns the name of the object. */
    6367            inline const std::string& getName() const { return this->name_; }
     68            /** @brief Returns the old name of the object. */
     69            inline const std::string& getOldName() const { return this->oldName_; }
    6470            /** @brief This function gets called if the name of the object changes. */
    6571            virtual void changedName() {}
     
    7985            virtual void changedVisibility() {}
    8086
    81             /** @brief Sets a pointer to the level that loaded this object. @param level The pointer to the level */
    82             inline void setLevel(const Level* level) { this->level_ = level; }
    83             /** @brief Returns a pointer to the level that loaded this object. @return The level */
    84             inline const Level* getLevel() const { return this->level_; }
    85             const std::string& getLevelfile() const;
     87            /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */
     88            inline void setFile(const XMLFile* file) { this->file_ = file; }
     89            /** @brief Returns a pointer to the XMLFile that loaded this object. @return The XMLFile */
     90            inline const XMLFile* getFile() const { return this->file_; }
     91            const std::string& getFilename() const;
     92
     93            void addTemplate(const std::string& name);
     94            void addTemplate(Template* temp);
     95            /** @brief Returns the set of all aplied templates. */
     96            inline const std::set<Template*>& getTemplates() const
     97                { return this->templates_; }
    8698
    8799            virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }
    88100            inline Namespace* getNamespace() const { return this->namespace_; }
     101
     102            inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
     103            inline BaseObject* getCreator() const { return this->creator_; }
     104
     105            inline void setScene(Scene* scene) { this->scene_ = scene; }
     106            inline Scene* getScene() const { return this->scene_; }
     107
     108            inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); }
     109            inline Gametype* getGametype() const { return this->gametype_; }
     110            inline Gametype* getOldGametype() const { return this->oldGametype_; }
     111            virtual inline void changedGametype() {}
     112
     113            void fireEvent();
     114            void fireEvent(bool activate);
     115            void fireEvent(bool activate, BaseObject* originator);
     116            void fireEvent(Event& event);
     117
     118            virtual void processEvent(Event& event);
     119
     120            inline void registerEventListener(BaseObject* object, const std::string& sectionname)
     121                { this->eventListeners_[object] = sectionname; }
     122            inline void unregisterEventListener(BaseObject* object)
     123                { this->eventListeners_.erase(object); }
     124
     125            void addEvent(BaseObject* event, const std::string& sectionname);
     126            void removeEvent(BaseObject* event);
     127            BaseObject* getEvent(unsigned int index) const;
     128
     129            void addEventContainer(const std::string& sectionname, EventContainer* container);
     130            EventContainer* getEventContainer(const std::string& sectionname) const;
    89131
    90132            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
     
    93135            inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
    94136
    95         private:
     137        protected:
    96138            std::string name_;                          //!< The name of the object
    97             bool bInitialized_;                         //!< True if the object was initialized (passed the object registration)
     139            std::string oldName_;                       //!< The old name of the object
    98140            bool bActive_;                              //!< True = the object is active
    99141            bool bVisible_;                             //!< True = the object is visible
    100             const Level* level_;                        //!< The level that loaded this object
    101             std::string loaderIndentation_;             //!< Indentation of the debug output in the Loader
    102             Namespace* namespace_;
     142
     143        private:
     144            void setXMLName(const std::string& name);
     145            Template* getTemplate(unsigned int index) const;
     146
     147            bool                  bInitialized_;         //!< True if the object was initialized (passed the object registration)
     148            const XMLFile*        file_;                 //!< The XMLFile that loaded this object
     149            std::string           loaderIndentation_;    //!< Indentation of the debug output in the Loader
     150            Namespace*            namespace_;
     151            BaseObject*           creator_;
     152            Scene*                scene_;
     153            Gametype*             gametype_;
     154            Gametype*             oldGametype_;
     155            std::set<Template*>   templates_;
     156            std::map<BaseObject*, std::string> eventListeners_;
     157            std::list<BaseObject*> events_;
     158            std::map<std::string, EventContainer*> eventContainers_;
    103159    };
    104160
     
    106162    SUPER_FUNCTION(2, BaseObject, changedActivity, false);
    107163    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
     164    SUPER_FUNCTION(4, BaseObject, processEvent, false);
    108165}
    109166
  • code/trunk/src/core/CMakeLists.txt

    r1887 r2087  
    44  ConfigValueContainer.cc
    55  Core.cc
     6  Event.cc
    67  GameState.cc
    78  Language.cc
     9  LuaBind.cc
    810  ObjectListBase.cc
    911  OrxonoxClass.cc
    1012  RootGameState.cc
    11   Script.cc
    1213
    1314  # command
     
    3132  Namespace.cc
    3233  NamespaceNode.cc
     34  Template.cc
    3335  XMLPort.cc
     36  XMLNameListener.cc
    3437
    3538  # shell
     
    6265    tolua_orxonox
    6366    tolua/tolua.pkg
    64     Script.h
     67    LuaBind.h
    6568    CommandExecutor.h
    6669  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
  • code/trunk/src/core/ClassFactory.h

    r1747 r2087  
    5555    {
    5656        public:
    57             static bool create(const std::string& name);
    58             BaseObject* fabricate();
     57            static bool create(const std::string& name, bool bLoadable = true);
     58            BaseObject* fabricate(BaseObject* creator);
    5959
    6060        private:
     
    6363            virtual ~ClassFactory() {}                      // Don't delete
    6464
    65             static T* createNewObject();
     65            static T* createNewObject(BaseObject* creator);
    6666    };
    6767
    6868    /**
    6969        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
     70        @param name The name of the class
     71        @param bLoadable True if the class can be loaded through XML
    7072        @return Always true (this is needed because the compiler only allows assignments before main())
    7173    */
    7274    template <class T>
    73     bool ClassFactory<T>::create(const std::string& name)
     75    bool ClassFactory<T>::create(const std::string& name, bool bLoadable)
    7476    {
    7577        COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
    7678        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
     79        ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    7780        Factory::add(name, ClassIdentifier<T>::getIdentifier());
    7881
     
    8588    */
    8689    template <class T>
    87     BaseObject* ClassFactory<T>::fabricate()
     90    BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
    8891    {
    89         return ClassFactory<T>::createNewObject();
     92        return ClassFactory<T>::createNewObject(creator);
    9093    }
    9194
     
    9598    */
    9699    template <class T>
    97     T* ClassFactory<T>::createNewObject()
     100    T* ClassFactory<T>::createNewObject(BaseObject* creator)
    98101    {
    99         return new T;
     102        return new T(creator);
    100103    }
    101104}
  • code/trunk/src/core/CommandEvaluation.cc

    r1879 r2087  
    7878        if (this->bEvaluatedParams_ && this->function_)
    7979        {
    80             COUT(5) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
     80            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
    8181            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    8282            return true;
  • code/trunk/src/core/CommandLine.cc

    r1755 r2087  
    3535    /**
    3636    @brief
     37        Parses a value string for a command line argument.
     38        It simply uses convertValue(Output, Input) to do that.
     39        Bools are treated specially. That is necessary
     40        so that you can have simple command line switches.
     41    */
     42    void CommandLineArgument::parse(const std::string& value)
     43    {
     44        if (value_.getType() == MT_bool)
     45        {
     46            // simulate command line switch
     47            bool temp;
     48            if (convertValue(&temp, value))
     49            {
     50                this->bHasDefaultValue_ = false;
     51                this->value_ = temp;
     52            }
     53            else if (value == "")
     54            {
     55                this->bHasDefaultValue_ = false;
     56                this->value_ = true;
     57            }
     58            else
     59            {
     60                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
     61            }
     62        }
     63        else
     64        {
     65            if (!value_.setValue(value))
     66            {
     67                value_.setValue(defaultValue_);
     68                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
     69            }
     70            else
     71                this->bHasDefaultValue_ = false;
     72        }
     73    }
     74
     75
     76    /**
     77    @brief
    3778        Destructor destroys all CommandLineArguments with it.
    3879    */
    3980    CommandLine::~CommandLine()
    4081    {
    41         for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
     82        for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
    4283            it != cmdLineArgs_.end(); ++it)
    4384        {
     
    73114        {
    74115            // first shove all the shortcuts in a map
    75             for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
     116            for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
    76117                it != cmdLineArgs_.end(); ++it)
    77118            {
     
    178219    void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
    179220    {
    180         std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
     221        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
    181222        if (it == cmdLineArgs_.end())
    182223            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
     
    195236    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
    196237    {
    197         std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
     238        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
    198239        if (it == cmdLineArgsShortcut_.end())
    199240            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
     
    206247        CommandLine* inst = &_getInstance();
    207248        std::string infoStr;
    208         for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
     249        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
    209250            it != inst->cmdLineArgs_.end(); ++it)
    210251        {
     
    214255    }
    215256
     257    /**
     258    @brief
     259        Retrieves a CommandLineArgument.
     260        The method throws an exception if 'name' was not found or the value could not be converted.
     261    @note
     262        You shold of course not call this method before the command line has been parsed.
     263    */
     264    const CommandLineArgument* CommandLine::getArgument(const std::string& name)
     265    {
     266        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
     267        if (it == _getInstance().cmdLineArgs_.end())
     268        {
     269            ThrowException(Argument, "Could find command line argument '" + name + "'.");
     270        }
     271        else
     272        {
     273            return it->second;
     274        }
     275    }
    216276}
  • code/trunk/src/core/CommandLine.h

    r1764 r2087  
    3535#include "util/Debug.h"
    3636#include "util/Exception.h"
     37#include "util/MultiType.h"
    3738
    3839#define SetCommandLineArgument(name, defaultValue) \
    39     BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
     40    CommandLineArgument& CmdArgumentDummyBoolVar##name \
    4041    = orxonox::CommandLine::addArgument(#name, defaultValue)
    4142#define SetCommandLineSwitch(name) \
    42     BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
     43    CommandLineArgument& CmdArgumentDummyBoolVar##name \
    4344    = orxonox::CommandLine::addArgument(#name, false)
    4445
     
    4849    /**
    4950    @brief
    50         Template struct which creates a distinct type for every integer constant.
    51     @note
    52         This allows to select a different function depending on a boolean value
    53         when creating a new CommandLineArgument.
    54         From 'Modern C++ Design' (Alexandrescu 2001).
     51        Container class for a command line argument of any type supported by MultiType.
     52
     53        Whenever you want to have an option specified by a command line switch,
     54        you need to first define it with SetCommandLineArgument(name, defaultValue).
     55        It is then added to a map and possibly changed when the command line is being parsed.
     56        If the option was not given, you can detect this by asking hasDefaultValue().
     57
     58        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
     59        Note the difference between "-" and "--"!
     60        Also, there is no restriction to the number of strings you add after --name.
     61        So "--startVector (2, 4, 5)" is perfectly legal.
     62
     63        Retrieving an argument is possible with the getCommandLineArgument function of the
     64        CommandLine class. It is a Singleton, but the public interface is static.
    5565    */
    56     template <int v>
    57     struct Int2Type
    58     {
    59         enum { value = v };
    60     };
    61 
    62     /**
    63     @brief
    64         Base class for CommandLineArguments.
    65     */
    66     class _CoreExport BaseCommandLineArgument
     66    class _CoreExport CommandLineArgument
    6767    {
    6868        friend class CommandLine;
     
    7878        const std::string& getShortcut() const { return shortcut_; }
    7979        //! Sets the shortcut for the argument
    80         BaseCommandLineArgument& setShortcut(const std::string& shortcut)
     80        CommandLineArgument& shortcut(const std::string& shortcut)
    8181        { this->shortcut_ = shortcut; return *this; }
    8282
     
    8484        const std::string& getInformation() const { return this->usageInformation_; }
    8585        //! Sets the option information when displaying orxonox usage.
    86         BaseCommandLineArgument& setInformation(const std::string& usage)
     86        CommandLineArgument& information(const std::string& usage)
    8787        { this->usageInformation_ = usage; return *this; }
    8888
    89     protected:
    90         BaseCommandLineArgument(const std::string& name)
     89        //! Returns the actual value of the argument. Can be equal to default value.
     90        MultiType getValue() const { return value_; }
     91        //! Returns the given default value as type T.
     92        MultiType getDefaultValue() const { return defaultValue_; }
     93
     94    private:
     95        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
     96        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
    9197            : bHasDefaultValue_(true)
    9298            , name_(name)
     99            , value_(defaultValue)
     100            , defaultValue_(defaultValue)
    93101        { }
    94102
    95103        //! Undefined copy constructor
    96         BaseCommandLineArgument(const BaseCommandLineArgument& instance);
    97         virtual ~BaseCommandLineArgument() { }
     104        CommandLineArgument(const CommandLineArgument& instance);
     105        ~CommandLineArgument() { }
    98106
    99107        //! Parses the value string of a command line argument.
    100         virtual void parse(const std::string& value) = 0;
     108        void parse(const std::string& value);
    101109
    102110        //! Tells whether the value has been changed by the command line.
     
    107115        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
    108116        std::string usageInformation_; //!< Tells about the usage of this parameter
     117
     118        MultiType value_;            //!< The actual value
     119        MultiType defaultValue_;     //!< Default value. Should not be changed.
    109120    };
    110 
    111 
    112     /**
    113     @brief
    114         Container class for a command line argument of type T.
    115        
    116         Whenever you want to have an option specified by a command line switch,
    117         you need to first define it with SetCommandLineArgument(name, defaultValue).
    118         It is then added to a map and possibly changed when the command line is being parsed.
    119         If the option was not given, you can detect this by asking hasDefaultValue().
    120        
    121         There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
    122         Note the difference between "-" and "--"!
    123         Also, there is no restriction to the number of strings you add after --name.
    124         So "--startVector (2, 4, 5)" is perfectly legal.
    125 
    126         Retrieving an argument is possible with the getCommandLineArgument function of the
    127         CommandLine class. It is a Singleton, but the public interface is static.
    128     */
    129     template <class T>
    130     class CommandLineArgument : public BaseCommandLineArgument
    131     {
    132         // Only let CommandLine change the value.
    133         friend class CommandLine;
    134 
    135     public:
    136         //! Returns the actual value of the argument. Can be equal to default value.
    137         T getValue() const { return value_; }
    138         //! Returns the given default value as type T.
    139         T getDefaultValue() const { return defaultValue_; }
    140 
    141     private:
    142         //! Constructor initialises both value_ and defaultValue_ with defaultValue.
    143         CommandLineArgument(const std::string& name, const T& defaultValue)
    144             : BaseCommandLineArgument(name)
    145             , value_(defaultValue)
    146             , defaultValue_(defaultValue)
    147         { }
    148 
    149         virtual void parse(const std::string& value);
    150 
    151         T value_;            //!< The actual value
    152         T defaultValue_;     //!< Default value. Should not be changed.
    153     };
    154 
    155     /**
    156     @brief
    157         Parses a value string for a command line argument.
    158         It simply uses convertValue(Output, Input) to do that.
    159     */
    160     template <class T>
    161     void CommandLineArgument<T>::parse(const std::string& value)
    162     {
    163         if (convertValue(&this->value_, value))
    164         {
    165             this->bHasDefaultValue_ = false;
    166         }
    167         else
    168         {
    169             ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    170         }
    171     }
    172 
    173     /**
    174     @brief
    175         Parses a value string for a command line argument.
    176         It simply uses convertValue(Output, Input) to do that.
    177         This is a template specialisation for bool type. That is necessary
    178         so that you can have simple command line switches.
    179     */
    180     template <>
    181     inline void CommandLineArgument<bool>::parse(const std::string& value)
    182     {
    183         if (convertValue(&this->value_, value))
    184         {
    185             this->bHasDefaultValue_ = false;
    186         }
    187         else if (value == "")
    188         {
    189             this->bHasDefaultValue_ = false;
    190             this->value_ = true;
    191         }
    192         else
    193         {
    194             ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    195         }
    196     }
    197121
    198122
     
    215139        static std::string getUsageInformation();
    216140
    217         template <class T>
    218         static const CommandLineArgument<T>* getArgument(const std::string& name);
     141        static const CommandLineArgument* getArgument(const std::string& name);
    219142        //! Writes the argument value in the given parameter.
    220143        template <class T>
    221144        static void getValue(const std::string& name, T* value)
    222         { *value = getArgument<T>(name)->getValue(); }
     145        { *value = (T)(getArgument(name)->getValue()); }
     146        static MultiType getValue(const std::string& name)
     147        { return getArgument(name)->getValue(); }
    223148        template <class T>
    224         static BaseCommandLineArgument& addArgument(const std::string& name, T defaultValue);
     149        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
     150
     151        static bool existsArgument(const std::string& name)
     152        {
     153            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
     154            return !(it == _getInstance().cmdLineArgs_.end());
     155        }
     156
    225157
    226158    private:
     
    237169        void checkShortcut(const std::string& shortcut, const std::string& value);
    238170
    239         template <class T>
    240         BaseCommandLineArgument* createArg(const std::string& name, T defaultValue, Int2Type<0> isString);
    241         template <class T>
    242         BaseCommandLineArgument* createArg(const std::string& name, T defaultValue, Int2Type<1> isString);
    243 
    244171        /**
    245             Tells whether we parse the first expression. The CommmandLineArguments are added before main().
     172            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
    246173            So when we call parse() the first time, we need to create a map with all shortcuts since these
    247174            get added after addCommandLineArgument().
     
    250177
    251178        //! Holds all pointers to the arguments and serves as a search map by name.
    252         std::map<std::string, BaseCommandLineArgument*> cmdLineArgs_;
     179        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
    253180        //! Search map by chortcut for the arguments.
    254         std::map<std::string, BaseCommandLineArgument*> cmdLineArgsShortcut_;
     181        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
    255182    };
    256183
    257 
    258     /**
    259     @brief
    260         Retrieves a CommandLineArgument.
    261         The method throws an exception if 'name' was not found or the value could not be converted.
    262     @note
    263         You shold of course not call this method before the command line has been parsed.
    264     */
    265     template <class T>
    266     const CommandLineArgument<T>* CommandLine::getArgument(const std::string& name)
    267     {
    268         std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
    269         if (it == _getInstance().cmdLineArgs_.end())
    270         {
    271             ThrowException(Argument, "Could find command line argument '" + name + "'.");
    272         }
    273         else
    274         {
    275             CommandLineArgument<T>* arg = dynamic_cast<CommandLineArgument<T>* >(it->second);
    276             if (arg == 0)
    277             {
    278                 ThrowException(Argument, "Could not convert command line argument value to requested type. " \
    279                     "You should use exactly the same type as predefined.");
    280             }
    281             else
    282             {
    283                 return arg;
    284             }
    285         }
     184    template <>
     185    inline void CommandLine::getValue<std::string>(const std::string& name, std::string* value)
     186    {
     187        *value = (std::string)(getArgument(name)->getValue().getString());
    286188    }
    287189
     
    294196    @param defaultValue
    295197        Default value that is used when argument was not given.
    296     @note
    297         In order to store char* strings as std::string too, there's
    298         little bit of template programming involved:
    299         StaticConversions::exists determines whether T converts to std::string.
    300         Int2Type<int> is then used to call the right function. One returns
    301         a CommandLineArgument<T> and the other CommandLineArgument<std::string>.
    302198    */
    303199    template <class T>
    304     BaseCommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
    305     {
    306         std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
    307         OrxAssert(it == _getInstance().cmdLineArgs_.end(),
     200    CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
     201    {
     202        OrxAssert(!_getInstance().existsArgument(name),
    308203            "Cannot add a command line argument with name '" + name + "' twice.");
    309204
    310         return *(_getInstance().cmdLineArgs_[name] =
    311             _getInstance().createArg(name, defaultValue, Int2Type<StaticConversion<T, std::string>::exists>()));
    312     }
    313 
    314     /**
    315         Returns a new CommandLineArgument<T>.
    316     */
    317     template <class T>
    318     BaseCommandLineArgument* CommandLine::createArg(const std::string& name, T defaultValue, Int2Type<0> isPrime)
    319     {
    320         return new CommandLineArgument<T>(name, defaultValue);
    321     }
    322 
    323     /**
    324         Returns a new CommandLineArgument<std::string>.
    325     */
    326     template <class T>
    327     BaseCommandLineArgument* CommandLine::createArg(const std::string& name, T defaultValue, Int2Type<1> isPrime)
    328     {
    329         return new CommandLineArgument<std::string>(name, defaultValue);
     205        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
    330206    }
    331207}
  • code/trunk/src/core/ConfigValueContainer.h

    r1887 r2087  
    5252#include "util/MultiType.h"
    5353#include "ConfigFileManager.h"
     54#include "Identifier.h"
    5455
    5556namespace orxonox
     
    6970            inline virtual ~ConfigValueCallback() {}
    7071            inline virtual void call(void* object)
    71                 { (((T*)object)->*this->function_)(); }
     72                { if (!Identifier::isCreatingHierarchy()) { (((T*)object)->*this->function_)(); } }
    7273
    7374        private:
  • code/trunk/src/core/ConsoleCommand.cc

    r1755 r2087  
    4141
    4242        this->keybindMode_ = KeybindMode::OnPress;
    43         this->axisParamIndex_ = -1;
    44         this->bAxisRelative_ = false;
     43        this->inputConfiguredParam_ = -1;
    4544    }
    4645
  • code/trunk/src/core/ConsoleCommand.h

    r1755 r2087  
    122122                { return this->argumentList_.end(); }
    123123
     124            inline ConsoleCommand& setAsInputCommand()
     125            {
     126                this->keybindMode(KeybindMode::OnHold);
     127                this->defaultValue(0, Vector2(0.0f, 0.0f));
     128                this->inputConfiguredParam(0);
     129                return *this;
     130            }
     131
    124132            inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
    125133                { this->keybindMode_ = mode; return *this; }
     
    127135                { return this->keybindMode_; }
    128136
    129             inline ConsoleCommand& axisParamIndex(int index)
    130                 { this->axisParamIndex_ = index; return *this; }
    131             inline int getAxisParamIndex() const
    132                 { return this->axisParamIndex_; }
    133 
    134             inline ConsoleCommand& isAxisRelative(bool val)
    135                 { this->bAxisRelative_ = val; return *this; }
    136             inline int getIsAxisRelative() const
    137                 { return this->bAxisRelative_; }
     137            inline ConsoleCommand& inputConfiguredParam(int index)
     138                { this->inputConfiguredParam_ = index; return *this; }
     139            inline int getInputConfiguredParam_() const
     140                { return this->inputConfiguredParam_; }
    138141
    139142        private:
     
    143146
    144147            KeybindMode::Enum keybindMode_;
    145             int axisParamIndex_;
    146             bool bAxisRelative_;
     148            int inputConfiguredParam_;
    147149    };
    148150
  • code/trunk/src/core/Core.cc

    r1762 r2087  
    3737#include "CoreIncludes.h"
    3838#include "ConfigValueIncludes.h"
    39 //#include "input/InputManager.h"
    40 //#include "TclThreadManager.h"
    4139
    4240namespace orxonox
    4341{
     42    bool Core::bShowsGraphics_s = false;
     43    bool Core::bHasServer_s     = false;
     44    bool Core::bIsClient_s      = false;
     45    bool Core::bIsStandalone_s  = false;
     46    bool Core::bIsMaster_s      = false;
     47
    4448    /**
    4549        @brief Constructor: Registers the object and sets the config-values.
     
    205209        ResetConfigValue(language_);
    206210    }
    207 
    208     ///**
    209     //    @brief Ticks every core class in a specified sequence. Has to be called
    210     //           every Orxonox tick!
    211     //    @param dt Delta Time
    212     //*/
    213     //void Core::tick(float dt)
    214     //{
    215     //    TclThreadManager::getInstance().tick(dt);
    216     //    InputManager::getInstance().tick(dt);
    217     //}
    218211}
  • code/trunk/src/core/Core.h

    r1755 r2087  
    6060            static void resetLanguage();
    6161
    62             //static void tick(float dt);
     62            // fast access global variables.
     63            static bool showsGraphics() { return bShowsGraphics_s; }
     64            static bool hasServer()     { return bHasServer_s; }
     65            static bool isClient()      { return bIsClient_s; }
     66            static bool isStandalone()  { return bIsStandalone_s; }
     67            static bool isMaster()      { return bIsMaster_s; }
     68            static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
     69            static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
     70            static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
     71            static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
     72            static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
    6373
    6474        private:
     
    7484            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    7585            std::string language_;                          //!< The language
     86
     87            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     88            static bool bHasServer_s;                       //!< global variable that tells whether this is a server
     89            static bool bIsClient_s;
     90            static bool bIsStandalone_s;
     91            static bool bIsMaster_s;
    7692    };
    7793}
  • code/trunk/src/core/CoreIncludes.h

    r1856 r2087  
    4646#include "Factory.h"
    4747#include "ClassFactory.h"
     48#include "Functor.h"
    4849#include "util/Debug.h"
    4950
     
    9899*/
    99100#define CreateFactory(ClassName) \
    100     bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName)
     101    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)
     102
     103/**
     104    @brief Creates the entry in the Factory for classes which should not be loaded through XML.
     105    @param ClassName The name of the class
     106*/
     107#define CreateUnloadableFactory(ClassName) \
     108    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)
    101109
    102110/**
     
    105113*/
    106114#define Class(ClassName) \
    107     ClassIdentifier<ClassName>::getIdentifier()
     115    orxonox::ClassIdentifier<ClassName>::getIdentifier()
    108116
    109117/**
     
    111119    @param String The name of the class
    112120*/
    113 #define ClassByName(String) \
     121#define ClassByString(String) \
    114122    orxonox::Factory::getIdentifier(String)
    115123
     
    121129    orxonox::Factory::getIdentifier(networkID)
    122130
     131/**
     132    @brief Registers a member function as callback when an object of 'type' is created.
     133    @param
     134*/
     135#define RegisterConstructionCallback(ThisClassName, TargetClassName, FunctionName) \
     136    orxonox::ClassIdentifier<TargetClassName>::getIdentifier()->addConstructionCallback( \
     137        createFunctor(&ThisClassName::FunctionName)->setObject(this))
     138
    123139#endif /* _CoreIncludes_H__ */
  • code/trunk/src/core/CorePrereqs.h

    r1757 r2087  
    103103  class CommandExecutor;
    104104  class CommandLine;
    105   class BaseCommandLineArgument;
    106   template <class T>
    107105  class CommandLineArgument;
    108106  class ConfigFile;
     
    115113  class ConsoleCommand;
    116114  class Core;
     115  struct Event;
     116  class EventContainer;
    117117  class Executor;
    118118  template <class T>
     
    131131  class Language;
    132132  class LanguageEntry;
    133   class Level;
    134133  class Loader;
    135134  class MetaObjectList;
     
    153152  struct TclInterpreterBundle;
    154153  class TclThreadManager;
     154  class Template;
    155155  class Tickable;
     156  class XMLFile;
     157  class XMLNameListener;
    156158  template <class T, class O>
    157159  class XMLPortClassObjectContainer;
  • code/trunk/src/core/Factory.cc

    r1856 r2087  
    4646    Identifier* Factory::getIdentifier(const std::string& name)
    4747    {
    48         return getFactoryPointer()->identifierStringMap_[name];
     48        std::map<std::string, Identifier*>::const_iterator it = getFactoryPointer()->identifierStringMap_.find(name);
     49        if (it != getFactoryPointer()->identifierStringMap_.end())
     50            return it->second;
     51        else
     52            return 0;
    4953    }
    5054
     
    5660    Identifier* Factory::getIdentifier(const unsigned int id)
    5761    {
    58         return getFactoryPointer()->identifierNetworkIDMap_[id];
     62        std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
     63        if (it != getFactoryPointer()->identifierNetworkIDMap_.end())
     64            return it->second;
     65        else
     66            return 0;
    5967    }
    6068
     
    6876        getFactoryPointer()->identifierStringMap_[name] = identifier;
    6977        getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
     78//std::cout << identifier->getName() << ": " << identifier->getNetworkID() << std::endl;
    7079    }
    7180
     
    8089        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
    8190        getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
     91//std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl;
    8292    }
    8393
     
    94104        {
    95105            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
    96             BaseObject* temp = (*it).second->fabricate();
     106            BaseObject* temp = (*it).second->fabricate(0);
    97107            delete temp;
    98108        }
  • code/trunk/src/core/Factory.h

    r1856 r2087  
    9393    {
    9494        public:
    95             virtual BaseObject* fabricate() = 0;
     95            virtual BaseObject* fabricate(BaseObject* creator) = 0;
    9696            virtual ~BaseFactory() {};
    9797    };
  • code/trunk/src/core/Functor.h

    r1889 r2087  
    106106            inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
    107107
    108             const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : blankString; }
     108            const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; }
    109109            const std::string& getTypenameReturnvalue() const { return this->typeReturnvalue_; }
    110110
     
    167167            }
    168168
    169             void setObject(T* object)
     169            FunctorMember* setObject(T* object)
    170170            {
    171171                this->bConstObject_ = false;
    172172                this->object_ = object;
     173                return this;
    173174            }
    174175
    175             void setObject(const T* object)
     176            FunctorMember* setObject(const T* object)
    176177            {
    177178                this->bConstObject_ = true;
    178179                this->constObject_ = object;
     180                return this;
    179181            }
    180182
  • code/trunk/src/core/Identifier.cc

    r1856 r2087  
    5959        this->bSetName_ = false;
    6060        this->factory_ = 0;
     61        this->bLoadable_ = true;
    6162
    6263        this->bHasConfigValues_ = false;
    6364        this->bHasConsoleCommands_ = false;
     65        this->bHasConstructionCallback_ = false;
    6466
    6567        this->children_ = new std::set<const Identifier*>();
     
    213215        @return The new object
    214216    */
    215     BaseObject* Identifier::fabricate()
     217    BaseObject* Identifier::fabricate(BaseObject* creator)
    216218    {
    217219        if (this->factory_)
    218220        {
    219             return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type.
     221            return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type.
    220222        }
    221223        else
     
    420422    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
    421423    {
    422         std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);
    423         if (it != xmlportParamContainers_.end())
     424        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
     425        if (it != this->xmlportParamContainers_.end())
    424426            return ((*it).second);
    425427        else
     
    434436    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
    435437    {
     438        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
     439        if (it != this->xmlportParamContainers_.end())
     440        {
     441            COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;
     442            delete (it->second);
     443        }
     444
    436445        this->xmlportParamContainers_[paramname] = container;
    437446    }
     
    444453    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
    445454    {
    446         std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
    447         if (it != xmlportObjectContainers_.end())
     455        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
     456        if (it != this->xmlportObjectContainers_.end())
    448457            return ((*it).second);
    449458        else
     
    458467    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
    459468    {
     469        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
     470        if (it != this->xmlportObjectContainers_.end())
     471        {
     472            COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;
     473            delete (it->second);
     474        }
     475
    460476        this->xmlportObjectContainers_[sectionname] = container;
     477    }
     478
     479    /**
     480        @brief Returns a XMLPortEventContainer that attaches an event to this class.
     481        @param sectionname The name of the section that contains the event
     482        @return The container
     483    */
     484    XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)
     485    {
     486        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
     487        if (it != this->xmlportEventContainers_.end())
     488            return ((*it).second);
     489        else
     490            return 0;
     491    }
     492
     493    /**
     494        @brief Adds a new XMLPortEventContainer that attaches an event to this class.
     495        @param sectionname The name of the section that contains the event
     496        @param container The container
     497    */
     498    void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)
     499    {
     500        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
     501        if (it != this->xmlportEventContainers_.end())
     502        {
     503            COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;
     504            delete (it->second);
     505        }
     506
     507        this->xmlportEventContainers_[eventname] = container;
     508    }
     509
     510    /**
     511        @brief Adds a construction callback functor that gets called every time an object is created.
     512        @param functor Functor pointer to any function with no argument.
     513    */
     514    void Identifier::addConstructionCallback(Functor* functor)
     515    {
     516        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
     517        {
     518            if (this->constructionCallbacks_[i] == functor)
     519                return;
     520        }
     521        this->constructionCallbacks_.push_back(functor);
     522        this->bHasConstructionCallback_ = true;
     523    }
     524
     525    /**
     526        @brief Removes a construction callback functor that gets called every time an object is created.
     527        @param functor Functor pointer to any function with no argument.
     528    */
     529    void Identifier::removeConstructionCallback(Functor* functor)
     530    {
     531        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
     532        {
     533            if (this->constructionCallbacks_[i] == functor)
     534            {
     535                this->constructionCallbacks_.erase(this->constructionCallbacks_.begin() + i);
     536            }
     537        }
     538        if (constructionCallbacks_.empty())
     539            this->bHasConstructionCallback_ = false;
    461540    }
    462541
  • code/trunk/src/core/Identifier.h

    r1856 r2087  
    5757#include <set>
    5858#include <map>
     59#include <vector>
    5960#include <string>
    6061#include <utility>
    6162#include <typeinfo>
    6263#include <stdlib.h>
     64#include <cassert>
    6365
    6466#include "MetaObjectList.h"
    6567#include "Iterator.h"
    6668#include "Super.h"
     69#include "Functor.h"
    6770#include "util/Debug.h"
    6871#include "util/String.h"
     
    99102            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
    100103
    101             BaseObject* fabricate();
     104            BaseObject* fabricate(BaseObject* creator);
    102105            bool isA(const Identifier* identifier) const;
    103106            bool isExactlyA(const Identifier* identifier) const;
     
    107110            bool isDirectParentOf(const Identifier* identifier) const;
    108111
     112            /** @brief Returns true if the class can be loaded through XML. */
     113            inline bool isLoadable() const { return this->bLoadable_; }
     114            /** @brief Set the class to be loadable through XML or not. */
     115            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
     116
    109117            /** @brief Returns the list of all existing objects of this class. @return The list */
    110118            inline ObjectListBase* getObjects() const
     
    204212            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }
    205213
     214            /** @brief Returns the map that stores all XMLPort events. @return The const_iterator */
     215            inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortEventMap() const { return this->xmlportEventContainers_; }
     216            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort events. @return The const_iterator */
     217            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapBegin() const { return this->xmlportEventContainers_.begin(); }
     218            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort events. @return The const_iterator */
     219            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }
     220
    206221            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
    207222            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    208223            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
    209224            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
     225            /** @brief Returns true if this class has at least one construction callback Functor registered. */
     226            inline bool hasConstructionCallback() const { return this->bHasConstructionCallback_; }
    210227
    211228            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
     
    228245            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
    229246
     247            void addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container);
     248            XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname);
     249
    230250            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
    231251            ConsoleCommand* getConsoleCommand(const std::string& name) const;
    232252            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
     253
     254            void addConstructionCallback(Functor* functor);
     255            void removeConstructionCallback(Functor* functor);
    233256
    234257            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     
    252275            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
    253276
     277            bool bHasConstructionCallback_;                                //!< True if at least one Functor is registered to get informed when an object of type T is created.
     278            std::vector<Functor*> constructionCallbacks_;                  //!< All construction callback Functors of this class.
     279
    254280            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    255281
     
    285311            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
    286312            bool bSetName_;                                                //!< True if the name is set
     313            bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
    287314            std::string name_;                                             //!< The name of the class the Identifier belongs to
    288315            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
     
    300327            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
    301328            std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_;   //!< All attachable objects
     329            std::map<std::string, XMLPortObjectContainer*> xmlportEventContainers_;    //!< All events
    302330    };
    303331
     
    423451        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    424452        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
     453        if (this->bHasConstructionCallback_)
     454        {
     455            // Call all registered callbacks that a new object of type T has been created.
     456            // Do NOT deliver a T* pointer here because it's way too risky (object not yet fully created).
     457            for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
     458                (*constructionCallbacks_[i])();
     459        }
    425460    }
    426461
     
    480515            SubclassIdentifier<T>& operator=(Identifier* identifier)
    481516            {
    482                 if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
     517                if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier()))
    483518                {
    484519                    COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    485                     COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
    486                     COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
    487                     COUT(1) << "Aborting..." << std::endl;
    488                     abort();
     520                    if (identifier)
     521                    {
     522                        COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
     523                        COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
     524                    }
     525                    else
     526                    {
     527                        COUT(1) << "Error: Can't assign NULL identifier" << std::endl;
     528                    }
    489529                }
    490                 this->identifier_ = identifier;
     530                else
     531                {
     532                    this->identifier_ = identifier;
     533                }
    491534                return *this;
    492535            }
     
    495538                @brief Overloading of the * operator: returns the assigned identifier.
    496539            */
    497             inline Identifier* operator*()
     540            inline Identifier* operator*() const
    498541            {
    499542                return this->identifier_;
     
    520563                @return The new object
    521564            */
    522             T* fabricate()
    523             {
    524                 BaseObject* newObject = this->identifier_->fabricate();
     565            T* fabricate(BaseObject* creator) const
     566            {
     567                BaseObject* newObject = this->identifier_->fabricate(creator);
    525568
    526569                // Check if the creation was successful
     
    546589                    }
    547590
    548                     abort();
     591                    assert(false);
     592                    return 0;
    549593                }
    550594            }
  • code/trunk/src/core/Loader.cc

    r1755 r2087  
    2828
    2929#include "Loader.h"
    30 #include "Level.h"
     30#include "XMLFile.h"
    3131#include "BaseObject.h"
    3232#include "Identifier.h"
     
    3434#include "ObjectList.h"
    3535#include "CoreIncludes.h"
    36 #include "Script.h"
     36#include "LuaBind.h"
    3737#include "Namespace.h"
    3838#include "util/Debug.h"
     
    4242namespace orxonox
    4343{
    44     std::vector<std::pair<const Level*, ClassTreeMask> > Loader::levels_s;
     44    std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
    4545    ClassTreeMask Loader::currentMask_s;
    4646
    47     bool Loader::open(const Level* level, const ClassTreeMask& mask)
     47    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask)
    4848    {
    49         Loader::add(level, mask);
    50         return Loader::load(level, mask);
     49        Loader::add(file, mask);
     50        return Loader::load(file, mask);
    5151    }
    5252
     
    5454    {
    5555        Loader::unload();
    56         Loader::levels_s.clear();
     56        Loader::files_s.clear();
    5757    }
    5858
    59     void Loader::close(const Level* level)
     59    void Loader::close(const XMLFile* file)
    6060    {
    61         Loader::unload(level);
    62         Loader::remove(level);
     61        Loader::unload(file);
     62        Loader::remove(file);
    6363    }
    6464
    65     void Loader::add(const Level* level, const ClassTreeMask& mask)
     65    void Loader::add(const XMLFile* file, const ClassTreeMask& mask)
    6666    {
    67         if (!level)
     67        if (!file)
    6868            return;
    69         Loader::levels_s.insert(Loader::levels_s.end(), std::pair<const Level*, ClassTreeMask>(level, mask));
     69        Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
    7070    }
    7171
    72     void Loader::remove(const Level* level)
     72    void Loader::remove(const XMLFile* file)
    7373    {
    74         if (!level)
     74        if (!file)
    7575            return;
    76         for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)
     76        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
    7777        {
    78             if ((*it).first == level)
     78            if ((*it).first == file)
    7979            {
    80                 Loader::levels_s.erase(it);
     80                Loader::files_s.erase(it);
    8181                break;
    8282            }
     
    8787    {
    8888        bool success = true;
    89         for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)
     89        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
    9090            if (!Loader::load((*it).first, (*it).second * mask))
    9191                success = false;
     
    111111    }
    112112
    113     bool Loader::load(const Level* level, const ClassTreeMask& mask)
     113    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask)
    114114    {
    115         if (!level)
     115        if (!file)
    116116            return false;
    117117
    118         Loader::currentMask_s = level->getMask() * mask;
     118        Loader::currentMask_s = file->getMask() * mask;
    119119
    120120        // let Lua work this out:
    121         //Script* lua;
    122         /*Script::loadFile(level->getFile(), true);
    123         Script::init(Script::getLuaState());
    124         Script::run();*/
    125         Script* lua = Script::getInstance();
     121        LuaBind* lua = LuaBind::getInstance();
    126122        lua->clearLuaOutput();
    127         lua->loadFile(level->getFile(), true);
     123        lua->loadFile(file->getFilename(), true);
    128124        lua->run();
    129125
    130126        try
    131127        {
    132             COUT(0) << "Start loading " << level->getFile() << "..." << std::endl;
     128            COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
    133129            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
    134130
    135             //ticpp::Document xmlfile(level->getFile());
     131            //ticpp::Document xmlfile(file->getFilename());
    136132            //xmlfile.LoadFile();
    137133            //ticpp::Element myelement(*Script::getFileString());
     
    148144
    149145            COUT(4) << "  creating root-namespace..." << std::endl;
    150             Namespace* rootNamespace = new Namespace();
     146            Namespace* rootNamespace = new Namespace(0);
    151147            rootNamespace->setLoaderIndentation("    ");
    152             rootNamespace->setLevel(level);
     148            rootNamespace->setFile(file);
    153149            rootNamespace->setNamespace(rootNamespace);
    154150            rootNamespace->setRoot(true);
    155151            rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
    156152
    157             COUT(0) << "Finished loading " << level->getFile() << "." << std::endl;
     153            COUT(0) << "Finished loading " << file->getFilename() << "." << std::endl;
    158154
    159155            COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
     
    164160        {
    165161            COUT(1) << std::endl;
    166             COUT(1) << "An error occurred in Loader.cc while loading " << level->getFile() << ":" << std::endl;
     162            COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
    167163            COUT(1) << ex.what() << std::endl;
    168164            COUT(1) << "Loading aborted." << std::endl;
     
    171167    }
    172168
    173     void Loader::unload(const Level* level, const ClassTreeMask& mask)
     169    void Loader::unload(const XMLFile* file, const ClassTreeMask& mask)
    174170    {
    175         if (!level)
     171        if (!file)
    176172            return;
    177173        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
    178174        {
    179             if ((it->getLevel() == level) && mask.isIncluded(it->getIdentifier()))
     175            if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier()))
    180176                delete (*(it++));
    181177            else
     
    184180    }
    185181
    186     bool Loader::reload(const Level* level, const ClassTreeMask& mask)
     182    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask)
    187183    {
    188         Loader::unload(level, mask);
    189         return Loader::load(level, mask);
     184        Loader::unload(file, mask);
     185        return Loader::load(file, mask);
    190186    }
    191187}
  • code/trunk/src/core/Loader.h

    r1505 r2087  
    3535
    3636#include "ClassTreeMask.h"
    37 #include "Level.h"
    3837
    3938namespace orxonox
     
    4241    {
    4342        public:
    44             static bool open(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
     43            static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
    4544            static void close();
    46             static void close(const Level* level);
     45            static void close(const XMLFile* file);
    4746
    48             static void add(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
    49             static void remove(const Level* level);
     47            static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
     48            static void remove(const XMLFile* file);
    5049
    5150            static bool load(const ClassTreeMask& mask = ClassTreeMask());
     
    5352            static bool reload(const ClassTreeMask& mask = ClassTreeMask());
    5453
    55             static bool load(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
    56             static void unload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
    57             static bool reload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
     54            static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
     55            static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
     56            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
    5857
    5958            static ClassTreeMask currentMask_s;
    6059
    6160        private:
    62             static std::vector<std::pair<const Level*, ClassTreeMask> > levels_s;
     61            static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s;
    6362    };
    6463}
  • code/trunk/src/core/Namespace.cc

    r1889 r2087  
    3737    CreateFactory(Namespace);
    3838
    39     Namespace::Namespace() :
     39    Namespace::Namespace(BaseObject* creator) : BaseObject(creator),
    4040      bAutogeneratedFileRootNamespace_(false),
    4141      bRoot_(false),
  • code/trunk/src/core/Namespace.h

    r1841 r2087  
    4242    {
    4343        public:
    44             Namespace();
     44            Namespace(BaseObject* creator);
    4545            virtual ~Namespace();
    4646
  • code/trunk/src/core/RootGameState.cc

    r1824 r2087  
    3939namespace orxonox
    4040{
    41     SetCommandLineArgument(state, "gui").setShortcut("s");
     41    SetCommandLineArgument(state, "gui").shortcut("s");
    4242
    4343    RootGameState::RootGameState(const std::string& name)
     
    147147
    148148            // get initial state from command line
    149             std::string initialState;
    150             CommandLine::getValue<std::string>("state", &initialState);
    151             gotoState(initialState);
     149            gotoState(CommandLine::getValue("state"));
    152150
    153151            while (this->activeChild_)
  • code/trunk/src/core/Super.h

    r1841 r2087  
    7373#include "util/Debug.h"
    7474#include "XMLIncludes.h"
     75#include "Event.h"
    7576
    7677///////////////////////
     
    229230    #define SUPER_changedVisibility(classname, functionname, ...) \
    230231        SUPER_NOARGS(classname, functionname)
     232
     233    #define SUPER_processEvent(classname, functionname, ...) \
     234        SUPER_ARGS(classname, functionname, __VA_ARGS__)
    231235    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    232236
     
    433437            ()
    434438        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     439
     440        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, processEvent, true, Event& event)
     441            (event)
     442        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    435443        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    436444
     
    479487    SUPER_INTRUSIVE_DECLARATION(changedActivity);
    480488    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
     489    SUPER_INTRUSIVE_DECLARATION(processEvent);
    481490    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    482491
  • code/trunk/src/core/XMLIncludes.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/XMLPort.h

    r1889 r2087  
    7070*/
    7171#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
    72     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
     72    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     73    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     74    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    7375/**
    7476    @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction.
     
    8385*/
    8486#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
    85     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
     87    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     88    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     89    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    8690
    8791// --------------------
     
    100104*/
    101105#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
    102     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
     106    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     107    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    103108/**
    104109    @brief This is the same as XMLPortParamTemplate, but for load-only attributes (see XMLPortParamLoadOnly).
    105110*/
    106111#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
    107     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
     112    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     113    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    108114
    109115// ------------------
     
    130136*/
    131137#define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
    132     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
     138    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
     139    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     140    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    133141/**
    134142    @brief This is the same as XMLPortParamTemplate, but for extern attributes (see XMLPortParamExtern).
    135143*/
    136144#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
    137     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
     145    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
     146    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
     147    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    138148
    139149// -------------------
     
    214224*/
    215225#define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    216     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
     226    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     227    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     228    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    217229/**
    218230    @brief This is the same as XMLPortObjectExtended, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
    219231*/
    220232#define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
    221     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
     233    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     234    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     235    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    222236
    223237// -------------
     
    228242*/
    229243#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \
    230     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
     244    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     245    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     246    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    231247/**
    232248    @brief This is the same as XMLPortObject, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
    233249*/
    234250#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
    235     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
     251    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
     252    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
     253    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    236254
    237255// --------------------
     
    336354                    {
    337355                        COUT(1) << std::endl;
    338                         COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getLevelfile() << ":" << std::endl;
     356                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ":" << std::endl;
    339357                        COUT(1) << ex.what() << std::endl;
    340358                    }
     
    468486                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
    469487                            {
    470                                 Identifier* identifier = ClassByName(child->Value());
     488                                Identifier* identifier = ClassByString(child->Value());
    471489                                if (identifier)
    472490                                {
    473491                                    if (identifier->isA(Class(O)))
    474492                                    {
    475                                         if (this->identifierIsIncludedInLoaderMask(identifier))
     493                                        if (identifier->isLoadable())
    476494                                        {
    477                                             COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
    478 
    479                                             BaseObject* newObject = identifier->fabricate();
    480                                             newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + "  ");
    481                                             newObject->setLevel(((BaseObject*)object)->getLevel());
    482                                             newObject->setNamespace(((BaseObject*)object)->getNamespace());
    483 
    484                                             if (this->bLoadBefore_)
     495                                            if (this->identifierIsIncludedInLoaderMask(identifier))
    485496                                            {
    486                                                 newObject->XMLPort(*child, XMLPort::LoadObject);
    487                                                 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     497                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
     498
     499                                                BaseObject* newObject = identifier->fabricate((BaseObject*)object);
     500                                                assert(newObject);
     501                                                newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + "  ");
     502
     503                                                O* castedObject = dynamic_cast<O*>(newObject);
     504                                                assert(castedObject);
     505
     506                                                if (this->bLoadBefore_)
     507                                                {
     508                                                    newObject->XMLPort(*child, XMLPort::LoadObject);
     509                                                    COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     510                                                }
     511                                                else
     512                                                {
     513                                                    COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     514                                                }
     515
     516                                                COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
     517                                                (*this->loadexecutor_)(object, castedObject);
     518
     519                                                if (!this->bLoadBefore_)
     520                                                    newObject->XMLPort(*child, XMLPort::LoadObject);
     521
     522                                                COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
    488523                                            }
    489                                             else
    490                                             {
    491                                                 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
    492                                             }
    493 
    494                                             COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
    495                                             (*this->loadexecutor_)(object, newObject);
    496 
    497                                             if (!this->bLoadBefore_)
    498                                                 newObject->XMLPort(*child, XMLPort::LoadObject);
    499 
    500                                             COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
     524                                        }
     525                                        else
     526                                        {
     527                                            COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
    501528                                        }
    502529                                    }
     
    508535                                else
    509536                                {
    510                                     COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
     537                                    if (this->sectionname_ != "")
     538                                    {
     539                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
     540                                    }
     541                                    else
     542                                    {
     543                                        // It's probably just another subsection
     544                                    }
    511545                                }
    512546                            }
     
    516550                    {
    517551                        COUT(1) << std::endl;
    518                         COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getLevelfile() << ":" << std::endl;
     552                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getFilename() << ":" << std::endl;
    519553                        COUT(1) << ex.what() << std::endl;
    520554                    }
  • code/trunk/src/core/input/Button.cc

    r1887 r2087  
    175175
    176176                // check for param command
    177                 int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
     177                int paramIndex = eval.getConsoleCommand()->getInputConfiguredParam_();
    178178                if (paramIndex >= 0)
    179179                {
    180180                    // parameter supported command
    181181                    ParamCommand* cmd = new ParamCommand();
    182                     cmd->paramModifier_ = paramModifier;
    183                     cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
     182                    cmd->scale_ = paramModifier;
    184183
    185184                    // add command to the buffer if not yet existing
    186185                    for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++)
    187186                    {
    188                         if (getLowercase((*paramCommandBuffer_)[iParamCmd]->evaluation_.getOriginalCommand())
    189                             == getLowercase(commandStr))
     187                        if ((*paramCommandBuffer_)[iParamCmd]->evaluation_.getConsoleCommand()
     188                            == eval.getConsoleCommand())
    190189                        {
    191190                            // already in list
  • code/trunk/src/core/input/HalfAxis.h

    r1887 r2087  
    5050            , paramCommands_(0)
    5151            , nParamCommands_(0)
    52             , wasDown_(false)
     52            , pressed_(false)
    5353            , hasChanged_(false)
    5454        { }
     
    6565
    6666        // button related
    67         bool wasDown_;
     67        bool pressed_;
    6868        bool hasChanged_;
    6969    };
  • code/trunk/src/core/input/InputCommands.cc

    r1887 r2087  
    3434
    3535#include "InputCommands.h"
     36#include "util/Math.h"
    3637#include "core/CommandExecutor.h"
    3738
     
    5152    bool BufferedParamCommand::execute()
    5253    {
    53         if (nValuesAdded_)
     54        if (this->abs_ != 0.0f || this->rel_ != 0.0f)
    5455        {
    55             BufferedParamCommand& cmd = *this;
    56             cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
     56            evaluation_.setEvaluatedParameter(paramIndex_, Vector2(abs_, rel_));
    5757            // reset
    58             cmd.nValuesAdded_ = 0;
    59             cmd.value_ = 0;
    60             return cmd.evaluation_.execute();
     58            rel_ = 0.0;
     59            abs_ = 0.0;
     60            return evaluation_.execute();
    6161        }
    6262        else
     
    7979        BufferedParamCommand& cmd = *paramCommand_;
    8080        // command has an additional parameter
    81         if (bRelative_)
     81        if (rel != 0.0f)
    8282        {
    83             if (rel != 0.0f)
    84             {
    85                 // we have to calculate a relative movement.
    86                 // paramModifier_ says how much one keystroke is
    87                 cmd.value_ += paramModifier_ * rel;
    88             }
     83            // calculate relative movement.
     84            // scale_ says how much one keystroke is
     85            cmd.rel_ += scale_ * rel;
    8986        }
    90         else if (abs != 0.0f)
     87
     88        if (abs != 0.0f)
    9189        {
    92             // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
    93             // and normally this is caught in tickInput(), but that threshold cannot be to high
    94             // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
    95             // Someone only uses buttons with an active joystick. The joy stick value could then
    96             // be 0.05 for instance and the the key value 1. Without handling the problem, the final
    97             // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
    98             float absQ = abs * abs;
    99             float valueQ = cmd.value_ * cmd.value_;
    100             if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
    101             {
    102                 cmd.value_ = abs * paramModifier_;
    103                 cmd.nValuesAdded_ = 1;
    104             }
    105             else if (absQ * 50.0f < valueQ)
    106             {
    107                 // abs is too small, we just don't do anything
    108             }
    109             else
    110             {
    111                 // we have to calculate the absolute position of the axis.
    112                 // Since there might be another axis that is affected, we have to wait and
    113                 // store the result in a temporary place
    114                 cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
    115             }
     90            cmd.abs_ += scale_ * abs;
     91            if (cmd.abs_ > 1.0)
     92                cmd.abs_ = 1.0;
     93            if (cmd.abs_ < -1.0)
     94                cmd.abs_ = -1.0;
    11695        }
    11796        return true;
  • code/trunk/src/core/input/InputCommands.h

    r1887 r2087  
    4444    {
    4545    public:
    46         BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
     46        BufferedParamCommand() : abs_(0.0f), rel_(0.0), paramIndex_(-1) { }
    4747        bool execute();
    4848
    49         float value_;
    50         unsigned int nValuesAdded_;
     49        float abs_;
     50        float rel_;
    5151        int paramIndex_;
    5252        CommandEvaluation evaluation_;
     
    8282    {
    8383    public:
    84         ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
     84        ParamCommand() : scale_(1.0f), paramCommand_(0) { }
    8585        bool execute(float abs = 1.0f, float rel = 1.0f);
    8686
    87         bool bRelative_;
    88         float paramModifier_;
     87        float scale_;
    8988        BufferedParamCommand* paramCommand_;
    9089    };
  • code/trunk/src/core/input/KeyBinder.cc

    r1887 r2087  
    137137        SetConfigValue(analogThreshold_, 0.05f)
    138138            .description("Threshold for analog axes until which the state is 0.");
     139        SetConfigValue(bFilterAnalogNoise_, false)
     140            .description("Specifies whether to filter small analog values like joy stick fluctuations.");
    139141        SetConfigValue(mouseSensitivity_, 1.0f)
    140142            .description("Mouse sensitivity.");
     
    145147        SetConfigValue(mouseSensitivityDerived_, 1.0f)
    146148            .description("Mouse sensitivity if mouse input is derived.");
    147         SetConfigValue(mouseWheelStepSize_, 120.0f)
     149        SetConfigValue(mouseWheelStepSize_, 120)
    148150            .description("Equals one step of the mousewheel.");
    149151        SetConfigValue(buttonThreshold_, 0.80f)
     
    323325    void KeyBinder::tickMouse(float dt)
    324326    {
    325         tickDevices(mouseAxes_, mouseAxes_ + MouseAxisCode::numberOfAxes * 2);
    326 
    327327        if (bDeriveMouseInput_)
    328328        {
     329            // only update when derive dt has passed
    329330            if (deriveTime_ > derivePeriod_)
    330331            {
     
    357358                deriveTime_ += dt;
    358359        }
    359     }
    360 
    361     void KeyBinder::tickDevices(HalfAxis* begin, HalfAxis* end)
    362     {
    363         for (HalfAxis* current = begin; current < end; ++current) // pointer arithmetic
    364         {
    365             // button mode
    366             // TODO: optimize out all the half axes that don't act as a button at the moment
    367             if (current->hasChanged_)
    368             {
    369                 if (!current->wasDown_ && current->absVal_ > current->buttonThreshold_)
    370                 {
    371                     current->wasDown_ = true;
    372                     if (current->nCommands_[KeybindMode::OnPress])
    373                         current->execute(KeybindMode::OnPress);
    374                 }
    375                 else if (current->wasDown_ && current->absVal_ < current->buttonThreshold_)
    376                 {
    377                     current->wasDown_ = false;
    378                     if (current->nCommands_[KeybindMode::OnRelease])
    379                         current->execute(KeybindMode::OnRelease);
    380                 }
    381                 current->hasChanged_ = false;
    382             }
    383 
    384             if (current->wasDown_)
    385             {
    386                 if (current->nCommands_[KeybindMode::OnHold])
    387                     current->execute(KeybindMode::OnHold);
    388             }
    389 
    390             // these are the actually useful axis bindings for analog input
    391             if (current->relVal_ > analogThreshold_ || current->absVal_ > analogThreshold_)
    392             {
    393                 current->execute();
    394             }
     360
     361        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
     362        {
     363            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
     364            // press a button that has relative movement, that value has to be multiplied by dt to be
     365            // frame rate independant. This can easily (and only) be done in tickInput(float).
     366            // Hence we need to divide by dt here for the mouse to compensate, because the relative
     367            // move movements have nothing to do with dt.
     368            if (dt != 0.0f)
     369            {
     370                // just ignore if dt == 0.0 because we have multiplied by 0.0 anyway..
     371                mouseAxes_[i].relVal_ /= dt;
     372            }
     373
     374            tickHalfAxis(mouseAxes_[i]);
     375        }
     376    }
     377
     378    void KeyBinder::tickJoyStick(float dt, unsigned int joyStick)
     379    {
     380        for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
     381        {
     382            tickHalfAxis(joyStickAxes_[joyStick][i]);
     383        }
     384    }
     385
     386    void KeyBinder::tickHalfAxis(HalfAxis& halfAxis)
     387    {
     388        // button mode
     389        // TODO: optimize out all the half axes that don't act as a button at the moment
     390        if (halfAxis.hasChanged_)
     391        {
     392            if (!halfAxis.pressed_ && halfAxis.absVal_ > halfAxis.buttonThreshold_)
     393            {
     394                // key pressed event
     395                halfAxis.pressed_ = true;
     396                if (halfAxis.nCommands_[KeybindMode::OnPress])
     397                    halfAxis.execute(KeybindMode::OnPress);
     398            }
     399            else if (halfAxis.pressed_ && halfAxis.absVal_ < halfAxis.buttonThreshold_)
     400            {
     401                // key released event
     402                halfAxis.pressed_ = false;
     403                if (halfAxis.nCommands_[KeybindMode::OnRelease])
     404                    halfAxis.execute(KeybindMode::OnRelease);
     405            }
     406            halfAxis.hasChanged_ = false;
     407        }
     408
     409        if (halfAxis.pressed_)
     410        {
     411            // key held event
     412            if (halfAxis.nCommands_[KeybindMode::OnHold])
     413                halfAxis.execute(KeybindMode::OnHold);
     414        }
     415
     416        // these are the actually useful axis bindings for analog input
     417        if (!bFilterAnalogNoise_ || halfAxis.relVal_ > analogThreshold_ || halfAxis.absVal_ > analogThreshold_)
     418        {
     419            halfAxis.execute();
    395420        }
    396421    }
     
    407432        int rel[] = { rel_.x, -rel_.y };
    408433
    409         if (!bDeriveMouseInput_)
     434        if (bDeriveMouseInput_)
     435        {
     436            mouseRelative_[0] += rel[0];
     437            mouseRelative_[1] += rel[1];
     438        }
     439        else
    410440        {
    411441            for (int i = 0; i < 2; i++)
     
    437467            }
    438468        }
    439         else
    440         {
    441             mouseRelative_[0] += rel[0];
    442             mouseRelative_[1] += rel[1];
    443         }
    444469
    445470        // relative
  • code/trunk/src/core/input/KeyBinder.h

    r1888 r2087  
    7171        void tickJoyStick(float dt, unsigned int joyStick);
    7272        // internal
    73         void tickDevices(HalfAxis* begin, HalfAxis* end);
     73        void tickHalfAxis(HalfAxis& halfAxis);
    7474
    7575        void buttonThresholdChanged();
     
    149149        //! Filename of default keybindings.
    150150        std::string defaultKeybindings_;
     151        //! Whether to filter small value analog input
     152        bool bFilterAnalogNoise_;
    151153        //! Threshold for analog triggers until which the state is 0.
    152154        float analogThreshold_;
     
    162164        float mouseSensitivityDerived_;
    163165        //! Equals one step of the mousewheel
    164         float mouseWheelStepSize_;
     166        int mouseWheelStepSize_;
    165167
    166168        //##### Constant config variables #####
     
    198200    { joyStickButtons_[joyStickID][id].execute(KeybindMode::OnHold); }
    199201
    200     inline void KeyBinder::tickJoyStick(float dt, unsigned int joyStick)
    201     {
    202         tickDevices(&joyStickAxes_[joyStick][0], &joyStickAxes_[joyStick][JoyStickAxisCode::numberOfAxes * 2]);
    203     }
    204 
    205202    inline void KeyBinder::tickInput(float dt)
    206203    {
    207204        // execute all buffered bindings (additional parameter)
    208205        for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
     206        {
     207            paramCommandBuffer_[i]->rel_ *= dt;
    209208            paramCommandBuffer_[i]->execute();
     209        }
    210210
    211211        // always reset the relative movement of the mouse
  • code/trunk/src/core/tolua/tolua.pkg

    r1755 r2087  
    1 $cfile "../../src/core/Script.h"
     1$cfile "../../src/core/LuaBind.h"
    22$cfile "../../src/core/CommandExecutor.h"
  • code/trunk/src/lua/COPYRIGHT

    • Property svn:eol-style set to native
  • code/trunk/src/lua/README

    • Property svn:eol-style set to native
  • code/trunk/src/network/CMakeLists.txt

    r1907 r2087  
    11SET( NETWORK_SRC_FILES
     2  ChatListener.cc
    23  Client.cc
    34  ClientConnection.cc
    45  ClientInformation.cc
     6  ClientConnectionListener.cc
    57  ConnectionManager.cc
    68  GamestateManager.cc
  • code/trunk/src/network/Client.cc

    r1907 r2087  
    3939//
    4040
     41#include <cassert>
     42
    4143#include "Client.h"
    4244#include "Host.h"
     
    4446#include "core/CoreIncludes.h"
    4547#include "packet/Packet.h"
     48
    4649// #include "packet/Acknowledgement.h"
    4750
     
    6770  * @param port port of the application on the server
    6871  */
    69   Client::Client(std::string address, int port) : client_connection(port, address){
     72  Client::Client(const std::string& address, int port) : client_connection(port, address){
    7073    isConnected=false;
    7174    isSynched_=false;
     
    114117  }
    115118
    116   bool Client::processChat(std::string message, unsigned int playerID){
    117     COUT(1) << "Player " << playerID << ": " << message << std::endl;
     119  bool Client::processChat(const std::string& message, unsigned int playerID){
     120//    COUT(1) << "Player " << playerID << ": " << message << std::endl;
    118121    return true;
    119122  }
    120  
     123
    121124  /**
    122125   * This function implements the method of sending a chat message to the server
    123    * @param message message to be sent 
     126   * @param message message to be sent
    124127   * @return result(true/false)
    125128   */
    126   bool Client::chat(std::string message){
     129  bool Client::chat(const std::string& message){
    127130    packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
    128131    return m->send();
     
    132135  /**
    133136   * Processes incoming packets, sends a gamestate to the server and does the cleanup
    134    * @param time 
     137   * @param time
    135138   */
    136139  void Client::tick(float time){
     
    152155      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
    153156      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
     157      // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
    154158      bool b = packet->process();
    155159      assert(b);
  • code/trunk/src/network/Client.h

    r1907 r2087  
    6666  public:
    6767    Client();
    68     Client(std::string address, int port);
     68    Client(const std::string& address, int port);
    6969    Client(const char *address, int port);
    7070    ~Client();
    71    
     71
    7272    bool establishConnection();
    7373    bool closeConnection();
    7474    bool queuePacket(ENetPacket *packet, int clientID);
    75     bool processChat(std::string message, unsigned int playerID);
    76     virtual bool chat(std::string message);
     75    bool processChat(const std::string& message, unsigned int playerID);
     76    virtual bool chat(const std::string& message);
     77    virtual bool broadcast(const std::string& message) { return false; }
    7778    //bool sendChat(packet::Chat *chat);
    78    
    79 //    static void Chat( std::string message );
    80    
    81     //static void setShipID( unsigned int shipID){ dynamic_cast<Client *>(instance_)->shipID_=shipID; }
    82     static void setClientID( unsigned int clientID){ dynamic_cast<Client *>(instance_)->clientID_=clientID; }
    83    
     79
    8480    void tick(float time);
    8581
    8682  private:
    8783    virtual bool isServer_(){return false;}
    88    
     84
    8985    ClientConnection client_connection;
    9086    GamestateClient gamestate;
    9187    bool isConnected;
    9288    bool isSynched_;
    93    
     89
    9490    bool gameStateFailure_;
    9591  };
  • code/trunk/src/network/ClientConnection.cc

    r1907 r2087  
    5454  boost::recursive_mutex ClientConnection::enet_mutex_;
    5555
    56   ClientConnection::ClientConnection(int port, std::string address) {
     56  ClientConnection::ClientConnection(int port, const std::string& address) {
    5757    quit=false;
    5858    server=NULL;
     
    7272  bool ClientConnection::waitEstablished(int milisec) {
    7373    for(int i=0; i<=milisec && !established; i++)
    74       usleep(1000);
     74      msleep(1);
    7575
    7676    return established;
     
    184184      case ENET_EVENT_TYPE_NONE:
    185185        //receiverThread_->yield();
    186         usleep(1000);
     186        msleep(1);
    187187        break;
    188188      }
  • code/trunk/src/network/ClientConnection.h

    r1907 r2087  
    6060
    6161
    62   class ClientConnection{
     62  class _NetworkExport ClientConnection{
    6363  public:
    64     ClientConnection(int port, std::string address);
     64    ClientConnection(int port, const std::string& address);
    6565    ClientConnection(int port, const char* address);
    6666    ~ClientConnection();
     
    9696    ENetPeer *server;
    9797    boost::thread *receiverThread_;
    98    
     98
    9999    static boost::recursive_mutex enet_mutex_;
    100100  };
  • code/trunk/src/network/ClientInformation.cc

    r1735 r2087  
    4545namespace network
    4646{
    47  
     47
    4848  ClientInformation *ClientInformation::head_=0;
    49  
     49
    5050  ClientInformation::ClientInformation() {
    5151    if(!head_)
     
    5959
    6060  ClientInformation::~ClientInformation() {
    61     if(this==head_)
    62       head_=next();
    6361    if(prev()!=0)
    6462      prev()->setNext(this->next());
    6563    if(next()!=0)
    6664      next()->setPrev(this->prev());
     65    if(this==head_)
     66      head_=next();
    6767  }
    6868
     
    129129    return true;
    130130  }
    131  
     131
    132132  bool ClientInformation::setPartialGamestateID(int id){
    133133    if(!this)
     
    137137  }
    138138
    139   int ClientInformation::getID() {
     139  unsigned int ClientInformation::getID() {
    140140    if(!this)
    141141      return CLIENTID_UNKNOWN;
     
    150150      return NULL;
    151151  }
    152  
     152
    153153  int ClientInformation::getFailures(){
    154154    return failures_;
     
    160160    failures_=0;
    161161  }
    162  
     162
    163163  enet_uint32 ClientInformation::getRTT(){
    164     return peer_->roundTripTime;
    165   }
    166  
    167   enet_uint32 ClientInformation::getPacketLoss(){
    168     return peer_->packetLoss;
    169   }
    170 
    171   int ClientInformation::getGamestateID() {
     164    return this->peer_->roundTripTime;
     165  }
     166
     167  double ClientInformation::getPacketLoss(){
     168    return ((double)this->peer_->packetLoss)/ENET_PEER_PACKET_LOSS_SCALE;
     169  }
     170
     171  unsigned int ClientInformation::getGamestateID() {
    172172    if(this)
    173173      return gamestateID_;
    174174    else
    175       return -1;
    176   }
    177  
    178   int ClientInformation::getPartialGamestateID() {
     175      return (unsigned int)-1;
     176  }
     177
     178  unsigned int ClientInformation::getPartialGamestateID() {
    179179    if(this)
    180180      return partialGamestateID_;
    181181    else
    182       return -1;
     182      return (unsigned int)-1;
    183183  }
    184184
    185185  ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
    186186    ClientInformation *temp = head_;
    187     if(temp==head_){
     187    if(temp==ins){
    188188      return head_;
    189189    }
     
    196196  }
    197197
    198   bool ClientInformation::removeClient(int clientID) {
    199     if(clientID==CLIENTID_UNKNOWN)
     198  bool ClientInformation::removeClient(unsigned int clientID) {
     199    if((unsigned int)clientID==CLIENTID_UNKNOWN)
    200200      return false;
    201201    ClientInformation *temp = head_;
     
    229229  * @return pointer to the last element in the list or 0 if the search was unsuccessfull
    230230  */
    231   ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) {
     231  ClientInformation *ClientInformation::findClient(unsigned int clientID, bool look_backwards) {
    232232    ClientInformation *temp = head_;
    233233    while(temp!=0 && temp->getID()!=clientID){
  • code/trunk/src/network/ClientInformation.h

    r1735 r2087  
    4646#include <boost/thread/recursive_mutex.hpp>
    4747
    48 #define GAMESTATEID_INITIAL -1
    49 #define CLIENTID_UNKNOWN -2
    50 
    5148// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
    5249
    5350namespace network
    5451{
     52  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
     53  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
     54
    5555  /**
    5656  * This class implements a list for client informations
    5757  * @author Oliver Scheuss
    5858  */
    59   class ClientInformation{
     59  class _NetworkExport ClientInformation{
    6060  public:
    6161    ClientInformation();
     
    6666    ClientInformation *prev();
    6767    static ClientInformation *insertBack(ClientInformation *ins);
    68    
     68
    6969    // set functions
    7070    void setID(int clientID);
     
    7373    bool setPartialGamestateID(int id);
    7474    inline void setShipID(unsigned int id){ShipID_=id;}
    75    
     75
    7676    // get functions
    7777    inline unsigned int getShipID(){return ShipID_;}
    78     int getID();
    79     int getGamestateID();
    80     int getPartialGamestateID();
     78    unsigned int getID();
     79    unsigned int getGamestateID();
     80    unsigned int getPartialGamestateID();
    8181    ENetPeer *getPeer();
    82    
     82
    8383    int getFailures();
    8484    void addFailure();
    8585    void resetFailures();
    8686    enet_uint32 getRTT();
    87     enet_uint32 getPacketLoss();
    88    
    89     static bool removeClient(int clientID);
     87    double getPacketLoss();
     88
     89    static bool removeClient(unsigned int clientID);
    9090    static bool removeClient(ENetPeer *peer);
    91     static ClientInformation *findClient(int clientID, bool look_backwards=false);
     91    static ClientInformation *findClient(unsigned int clientID, bool look_backwards=false);
    9292    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
    9393    static ClientInformation *getBegin(){return head_;}
     
    9999  private:
    100100    static ClientInformation *head_;
    101    
     101
    102102    bool setNext(ClientInformation *next);
    103103    bool setPrev(ClientInformation *prev);
    104104    ClientInformation *insertAfter(ClientInformation *ins);
    105105    ClientInformation *insertBefore(ClientInformation *ins);
    106    
     106
    107107    ClientInformation *preve;
    108108    ClientInformation *nexte;
    109109    //actual information:
    110110    ENetPeer *peer_;
    111     int clientID_;
    112     int gamestateID_;
    113     int partialGamestateID_;
     111    unsigned int clientID_;
     112    unsigned int gamestateID_;
     113    unsigned int partialGamestateID_;
    114114    unsigned int ShipID_;   // this is the unique objectID
    115115    bool synched_;
    116116    unsigned short failures_;
    117    
     117
    118118  };
    119119
  • code/trunk/src/network/ConnectionManager.cc

    r1907 r2087  
    4949#include "core/BaseObject.h"
    5050#include "core/Iterator.h"
    51 #include "objects/SpaceShip.h"
    5251#include "util/Math.h"
    5352#include "util/Sleep.h"
     
    8988  }
    9089
    91   ConnectionManager::ConnectionManager(int port, std::string address) :receiverThread_(0) {
     90  ConnectionManager::ConnectionManager(int port, const std::string& address) :receiverThread_(0) {
    9291    assert(instance_==0);
    9392    instance_=this;
     
    228227        case ENET_EVENT_TYPE_NONE:
    229228          //receiverThread_->yield();
    230           usleep(1000);
     229          msleep(1);
    231230          break;
    232231      }
     
    331330
    332331
    333 
    334   bool ConnectionManager::removeShip(ClientInformation *client){
    335     unsigned int id=client->getShipID();
    336     orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
    337     for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    338       if(it->getObjectID()!=id)
    339         continue;
    340       delete *it;
    341     }
    342     return true;
    343   }
    344 
    345 
    346332  void ConnectionManager::disconnectClient(ClientInformation *client){
    347333    {
     
    350336      lock.unlock();
    351337    }
    352     removeShip(client);
    353338  }
    354339
  • code/trunk/src/network/ConnectionManager.h

    r1785 r2087  
    6666    const int NETWORK_DEFAULT_CHANNEL = 0;
    6767
    68   struct ClientList{
     68  struct _NetworkExport ClientList{
    6969    ENetEvent *event;
    7070    int ID;
     
    7272  };
    7373
    74   class ConnectionManager{
     74  class _NetworkExport ConnectionManager{
    7575    public:
    7676    static boost::recursive_mutex enet_mutex;
     
    7979    ConnectionManager(int port);
    8080    ConnectionManager(int port, const char *address);
    81     ConnectionManager(int port, std::string address);
     81    ConnectionManager(int port, const std::string& address);
    8282    ~ConnectionManager();
    8383    //ENetPacket *getPacket(ENetAddress &address); // thread1
     
    107107    int getClientID(ENetAddress address);
    108108    ENetPeer *getClientPeer(int clientID);
    109     //bool createShip(ClientInformation *client);
    110     bool removeShip(ClientInformation *client);
    111109    PacketBuffer buffer;
    112110
  • code/trunk/src/network/GamestateClient.cc

    r1907 r2087  
    2929#include "GamestateClient.h"
    3030
     31#include <cassert>
    3132#include <zlib.h>
    3233
     
    4041namespace network
    4142{
    42   struct GameStateItem{
     43  struct _NetworkExport GameStateItem{
    4344    packet::Gamestate *state;
    44     int id;
     45    unsigned int id;
    4546  };
    4647
     
    5051    last_gamestate_=GAMESTATEID_INITIAL-1;
    5152    tempGamestate_=NULL;
    52     myShip_=NULL;
    5353  }
    5454
     
    5656  }
    5757
    58   bool GamestateClient::ack(int gamestateID, int clientID){
     58  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
    5959    return true;
    6060  }
    6161
    62   bool GamestateClient::add(packet::Gamestate *gs, int clientID){
     62  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){
    6363    if(tempGamestate_!=NULL){
    6464      //delete the obsolete gamestate
     
    7575      return false;
    7676    int id = GAMESTATEID_INITIAL;
    77     bool b = saveShipCache();
    7877    packet::Gamestate *processed = processGamestate(tempGamestate_);
    79     if(!processed){
    80       if(b)
    81         loadShipCache();
    82       return false;
    83     }
    8478//    assert(processed);
     79    if (!processed)
     80        return false;
    8581    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
    8682    tempGamestate_=NULL;
    8783    gamestateMap_[processed->getID()]=processed;
    8884    last_diff_ = processed->getID();
    89     if(b)
    90       loadShipCache();
    9185    id = processed->getID();
    9286    sendAck(id);
     
    108102  packet::Gamestate *GamestateClient::getGamestate(){
    109103    packet::Gamestate *gs = new packet::Gamestate();
    110     gs->collectData(0);
     104    if(!gs->collectData(0)){
     105      delete gs;
     106      return 0;
     107    }
    111108    return gs;
    112109  }
    113110
    114111  void GamestateClient::cleanup(){
    115     std::map<int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
     112    std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
    116113    while(it!=gamestateMap_.end()){
    117114      if(it->first>=last_diff_)
     
    126123
    127124  void GamestateClient::printGamestateMap(){
    128     std::map<int, packet::Gamestate*>::iterator it;
     125    std::map<unsigned int, packet::Gamestate*>::iterator it;
    129126    COUT(4) << "gamestates: ";
    130127    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
     
    134131
    135132  }
    136  
     133
    137134  bool GamestateClient::sendAck(unsigned int gamestateID){
    138135    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
     
    142139    }
    143140    else{
    144       COUT(3) << "acked a gamestate: " << gamestateID << std::endl;
     141      COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
    145142      return true;
    146143    }
    147   }
    148 
    149   bool GamestateClient::saveShipCache(){
    150     if(myShip_==NULL){
    151       myShip_ = orxonox::SpaceShip::getLocalShip();
    152 //      COUT(2) << "myShip_: " << myShip_ << " getLocalShip(): " << orxonox::SpaceShip::getLocalShip() << std::endl;
    153       if(!myShip_)
    154         return false;
    155     }
    156     if(myShip_){
    157       //      unsigned char *data = new unsigned char[myShip_->getSize()];
    158       int size=myShip_->getSize(0, 0x1);
    159       if(size==0)
    160         return false;
    161       shipCache_ = new unsigned char [size];
    162       unsigned char *temp = shipCache_;
    163       if(!myShip_->getData(temp, 0, 0x1))
    164         COUT(3) << "could not save shipCache" << std::endl;
    165       return true;
    166     }else
    167       return false;
    168   }
    169 
    170   bool GamestateClient::loadShipCache(){
    171     myShip_=orxonox::SpaceShip::getLocalShip(); //TODO: remove this (only a hack)
    172     if(myShip_ && shipCache_){
    173       assert(myShip_->getIdentifier());
    174       unsigned char *temp = shipCache_;
    175       myShip_->updateData(temp, 0x2);
    176       delete shipCache_;
    177       return true;
    178     }else
    179       return false;
    180144  }
    181145
     
    196160      delete gs;
    197161      gs=undiffed;
    198       COUT(3) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
     162      COUT(5) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
    199163    }
    200164    if(gs->spreadData())
  • code/trunk/src/network/GamestateClient.h

    r1769 r2087  
    4646#include "core/CorePrereqs.h"
    4747#include "packet/Gamestate.h"
    48 #include "objects/SpaceShip.h"
    4948#include "GamestateHandler.h"
    5049
    51 #define GAMESTATEID_INITIAL -1
     50const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
    5251
    5352namespace network
    5453{
    55   class GamestateClient: public GamestateHandler
     54  class _NetworkExport GamestateClient: public GamestateHandler
    5655  {
    5756  public:
     
    5958    ~GamestateClient();
    6059
    61     bool add(packet::Gamestate *gs, int clientID);
    62     bool ack(int gamestateID, int clientID);
     60    bool add(packet::Gamestate *gs, unsigned int clientID);
     61    bool ack(unsigned int gamestateID, unsigned int clientID);
    6362
    6463    bool processGamestates();
     
    7069    void printGamestateMap();
    7170    bool sendAck(unsigned int gamestateID);
    72     bool saveShipCache();
    73     bool loadShipCache();
    7471
    75     int           last_diff_;
    76     int           last_gamestate_;
    77     std::map<int, packet::Gamestate *> gamestateMap_;
     72    unsigned int           last_diff_;
     73    unsigned int           last_gamestate_;
     74    std::map<unsigned int, packet::Gamestate *> gamestateMap_;
    7875    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
    79     orxonox::SpaceShip *myShip_;
    8076    unsigned char *shipCache_;
    8177
  • code/trunk/src/network/GamestateHandler.h

    r1763 r2087  
    3939        @author Oliver Scheuss
    4040*/
    41 class GamestateHandler{
     41class _NetworkExport GamestateHandler{
    4242  private:
    43     virtual bool add(packet::Gamestate *gs, int clientID)=0;
    44     virtual bool ack(int gamestateID, int clientID)=0;
     43    virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0;
     44    virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0;
    4545
    4646    static GamestateHandler *instance_;
     
    5252
    5353  public:
    54     static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }
    55     static bool ackGamestate(int gamestateID, int clientID){ return instance_->ack(gamestateID, clientID); }
     54    static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
     55    static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
    5656};
    5757
  • code/trunk/src/network/GamestateManager.cc

    r1907 r2087  
    6464    return getSnapshot();
    6565  }
    66  
    67   bool GamestateManager::add(packet::Gamestate *gs, int clientID){
     66
     67  bool GamestateManager::add(packet::Gamestate *gs, unsigned int clientID){
    6868    assert(gs);
    69     std::map<int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
     69    std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
    7070    if(it!=gamestateQueue.end()){
    7171      // delete obsolete gamestate
     
    7575    return true;
    7676  }
    77  
     77
    7878  bool GamestateManager::processGamestates(){
    79     std::map<int, packet::Gamestate*>::iterator it;
     79    std::map<unsigned int, packet::Gamestate*>::iterator it;
    8080    // now push only the most recent gamestates we received (ignore obsolete ones)
    8181    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
    82       assert(processGamestate(it->second));
     82      bool b = processGamestate(it->second);
     83      assert(b);
    8384      delete it->second;
    8485    }
     
    8788    return true;
    8889  }
    89  
    90  
     90
     91
    9192  bool GamestateManager::getSnapshot(){
    9293    reference = new packet::Gamestate();
    93     reference->collectData(++id_);
    94     //COUT(4) << "inserting gamestate: " << reference << std::endl;
    95     //gamestateMap_.insert(std::pair<int, packet::Gamestate*>(id_, reference));
    96 //     gamestateUsed[id_]=0;
    97     return true;
    98   }
    99  
     94    if(!reference->collectData(++id_)){ //we have no data to send
     95      delete reference;
     96      reference=0;
     97    }
     98    return true;
     99  }
     100
    100101  /**
    101102   * this function is used to keep the memory usage low
    102103   * it tries to delete all the unused gamestates
    103    * 
    104    * 
     104   *
     105   *
    105106   */
    106107/*  void GamestateManager::cleanup(){
     
    126127  }*/
    127128
    128   packet::Gamestate *GamestateManager::popGameState(int clientID) {
     129  packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
    129130    //why are we searching the same client's gamestate id as we searched in
    130131    //Server::sendGameState?
    131132    packet::Gamestate *gs;
    132     int gID = ClientInformation::findClient(clientID)->getGamestateID();
     133    unsigned int gID = ClientInformation::findClient(clientID)->getGamestateID();
     134    if(!reference)
     135      return 0;
    133136    gs = reference->doSelection(clientID);
    134137//     gs = new packet::Gamestate(*reference);
     
    139142    packet::Gamestate *client=NULL;
    140143    if(gID != GAMESTATEID_INITIAL){
    141       std::map<unsigned int, std::map<int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
     144      std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
    142145      if(clientMap!=gamestateMap_.end()){
    143         std::map<int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
     146        std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
    144147        if(it!=clientMap->second.end())
    145148          client = it->second;
     
    158161    return gs;
    159162  }
    160  
    161  
    162   bool GamestateManager::ack(int gamestateID, int clientID) {
     163
     164
     165  bool GamestateManager::ack(unsigned int gamestateID, unsigned int clientID) {
    163166    ClientInformation *temp = ClientInformation::findClient(clientID);
    164167    assert(temp);
    165     int curid = temp->getGamestateID();
    166    
     168    unsigned int curid = temp->getGamestateID();
     169
    167170    if(gamestateID == 0){
    168171      temp->setGamestateID(GAMESTATEID_INITIAL);
    169172      return true;
    170173    }
    171    
    172     assert(curid<gamestateID);
     174
     175    assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
    173176    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    174     std::map<int, packet::Gamestate*>::iterator it, tempit;
     177    std::map<unsigned int, packet::Gamestate*>::iterator it, tempit;
    175178    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){
    176179      delete it->second;
     
    184187  void GamestateManager::removeClient(ClientInformation* client){
    185188    assert(client);
    186     std::map<unsigned int, std::map<int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
     189    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
    187190    // first delete all remained gamestates
    188     std::map<int, packet::Gamestate*>::iterator it;
     191    std::map<unsigned int, packet::Gamestate*>::iterator it;
    189192    for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
    190193      delete it->second;
     
    192195    gamestateMap_.erase(clientMap);
    193196  }
    194  
     197
    195198  bool GamestateManager::processGamestate(packet::Gamestate *gs){
    196199    if(gs->isCompressed())
  • code/trunk/src/network/GamestateManager.h

    r1907 r2087  
    6666  * @author Oliver Scheuss
    6767  */
    68   class GamestateManager: public GamestateHandler{
     68  class _NetworkExport GamestateManager: public GamestateHandler{
    6969  public:
    7070    GamestateManager();
    7171    ~GamestateManager();
    7272
    73     bool add(packet::Gamestate *gs, int clientID);
     73    bool add(packet::Gamestate *gs, unsigned int clientID);
    7474    bool processGamestates();
    7575    bool update();
    76     packet::Gamestate *popGameState(int clientID);
     76    packet::Gamestate *popGameState(unsigned int clientID);
    7777
    7878    bool getSnapshot();
    7979
    80     bool ack(int gamestateID, int clientID);
     80    bool ack(unsigned int gamestateID, unsigned int clientID);
    8181    void removeClient(ClientInformation *client);
    8282    private:
     
    8484    bool processGamestate(packet::Gamestate *gs);
    8585
    86     std::map<unsigned int, std::map<int, packet::Gamestate*> > gamestateMap_;
     86    std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
    8787    //std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
    8888    //std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
    89     std::map<int, packet::Gamestate*> gamestateQueue;
     89    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    9090    packet::Gamestate *reference;
    91     int id_;
     91    unsigned int id_;
    9292  };
    9393
  • code/trunk/src/network/Host.cc

    r1907 r2087  
    3232#include "core/ConsoleCommand.h"
    3333#include "packet/Packet.h"
     34#include "ChatListener.h"
    3435
    3536namespace network {
     
    3839
    3940Host *Host::instance_=0;
    40  
     41
    4142/**
    4243 * @brief Constructor: assures that only one reference will be created and sets the pointer
     
    9091 * @return playerID
    9192 */
    92 unsigned int Host::getPlayerID(){ 
     93unsigned int Host::getPlayerID(){
    9394  if(!instance_)
    9495    return 0;
     
    9697}
    9798
    98 bool Host::Chat(std::string message){
     99bool Host::Chat(const std::string& message){
    99100  if(!instance_)
    100101    return false;
     
    102103}
    103104
    104 bool Host::incomingChat(std::string message, unsigned int playerID){
     105bool Host::Broadcast(const std::string& message){
     106  if(!instance_)
     107    return false;
     108  return instance_->broadcast(message);
     109}
     110
     111bool Host::incomingChat(const std::string& message, unsigned int playerID){
     112  for (orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)
     113    it->incomingChat(message, playerID);
     114
    105115  return instance_->processChat(message, playerID);
    106116}
  • code/trunk/src/network/Host.h

    r1907 r2087  
    4444*       @author Oliver Scheuss
    4545*/
    46 class Host{
     46class _NetworkExport Host{
    4747  private:
    4848    //TODO add theese functions or adequate
     
    5050    //virtual bool sendChat(packet::Chat *chat)=0;
    5151    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
    52     virtual bool chat(std::string message)=0;
    53     virtual bool processChat(std::string message, unsigned int playerID)=0;
     52    virtual bool chat(const std::string& message)=0;
     53    virtual bool broadcast(const std::string& message)=0;
     54    virtual bool processChat(const std::string& message, unsigned int playerID)=0;
    5455    virtual bool isServer_()=0;
    5556
     
    7273    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
    7374    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
    74     static bool isServer(){ return instance_->isServer_(); }           
    75     static bool Chat(std::string message);
    76     static bool incomingChat(std::string message, unsigned int playerID);
     75    static bool isServer(){ return instance_->isServer_(); }
     76    static bool Chat(const std::string& message);
     77    static bool Broadcast(const std::string& message);
     78    static bool incomingChat(const std::string& message, unsigned int playerID);
    7779  private:
    7880};
  • code/trunk/src/network/NetworkCallback.h

    r1536 r2087  
    22#define _NETWORK_CALLBACK__
    33
     4#include "NetworkPrereqs.h"
     5
    46namespace network{
    5   class NetworkCallbackBase
     7  class _NetworkExport NetworkCallbackBase
    68  {
    79    public:
     
    911          virtual ~NetworkCallbackBase() {}
    1012  };
    11  
     13
    1214  template <class T>
    1315  class NetworkCallback: public NetworkCallbackBase
     
    1820      virtual void call()
    1921        { (this->object_->*function_)(); }
    20  
     22
    2123    private:
    2224      T* object_;
    2325      void (T::*function_) (void);
    24   }; 
     26  };
    2527
    2628
  • code/trunk/src/network/NetworkPrereqs.h

    r1735 r2087  
    6363  class Client;
    6464  class ClientConnection;
     65  class ClientConnectionListener;
    6566  class ClientFrameListener;
    6667  class ClientInformation;
  • code/trunk/src/network/PacketBuffer.h

    r1505 r2087  
    4949namespace network
    5050{
    51   struct PacketEnvelope{
     51  struct _NetworkExport PacketEnvelope{
    5252    int length;
    5353    int data;
    5454  };
    5555
    56   struct QueueItem{
     56  struct _NetworkExport QueueItem{
    5757    ENetEvent *event;
    5858    //ENetAddress address;
     
    6060  };
    6161
    62   class PacketBuffer{
     62  class _NetworkExport PacketBuffer{
    6363  public:
    6464    PacketBuffer();
  • code/trunk/src/network/Server.cc

    r1907 r2087  
    4646
    4747#include "ConnectionManager.h"
     48#include "ClientConnectionListener.h"
    4849#include "GamestateManager.h"
    4950#include "ClientInformation.h"
    5051#include "util/Sleep.h"
    51 #include "objects/SpaceShip.h"
    5252#include "core/ConsoleCommand.h"
    5353#include "core/CoreIncludes.h"
     
    5858#include "packet/DeleteObjects.h"
    5959#include <util/Convert.h>
     60#include "ChatListener.h"
    6061
    6162namespace network
    6263{
    63   const int MAX_FAILURES = 20;
    64   const int NETWORK_FREQUENCY = 30;
     64  const unsigned int MAX_FAILURES = 20;
     65  const unsigned int NETWORK_FREQUENCY = 25;
     66  const float NETWORK_PERIOD = (float)1/NETWORK_FREQUENCY;
    6567
    6668  /**
     
    8587  * @param bindAddress Address to listen on
    8688  */
    87   Server::Server(int port, std::string bindAddress) {
     89  Server::Server(int port, const std::string& bindAddress) {
    8890    timeSinceLastUpdate_=0;
    8991    connection = new ConnectionManager(port, bindAddress);
     
    101103    gamestates_ = new GamestateManager();
    102104  }
    103  
     105
    104106  /**
    105107  * @brief Destructor
     
    128130  }
    129131
    130   bool Server::processChat(std::string message, unsigned int playerID){
     132  bool Server::processChat(const std::string& message, unsigned int playerID){
    131133    ClientInformation *temp = ClientInformation::getBegin();
    132134    packet::Chat *chat;
     
    138140      temp = temp->next();
    139141    }
    140     COUT(1) << "Player " << playerID << ": " << message << std::endl;
     142//    COUT(1) << "Player " << playerID << ": " << message << std::endl;
    141143    return true;
    142144  }
     
    152154    //this steers our network frequency
    153155    timeSinceLastUpdate_+=time;
    154     if(timeSinceLastUpdate_>=(1./NETWORK_FREQUENCY)){
    155       timeSinceLastUpdate_=(float)((int)(timeSinceLastUpdate_*NETWORK_FREQUENCY))/timeSinceLastUpdate_;
     156    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
     157      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
    156158      gamestates_->processGamestates();
    157159      updateGamestate();
     
    162164    return connection->addPacket(packet, clientID);
    163165  }
    164 
     166 
     167  /**
     168   * @brief: returns ping time to client in milliseconds
     169   */
     170  unsigned int Server::getPing(unsigned int clientID){
     171    assert(ClientInformation::findClient(clientID));
     172    return ClientInformation::findClient(clientID)->getRTT();
     173  }
     174
     175  /**
     176   * @brief: return packet loss ratio to client (scales from 0 to 1)
     177   */
     178  double Server::getPacketLoss(unsigned int clientID){
     179    assert(ClientInformation::findClient(clientID));
     180    return ClientInformation::findClient(clientID)->getPacketLoss();
     181  }
     182 
    165183  /**
    166184  * processes all the packets waiting in the queue
     
    239257      if(gs==NULL){
    240258        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
     259        temp = temp->next();
    241260        continue;
    242261      }
     
    281300
    282301  bool Server::addClient(ENetEvent *event){
     302    static unsigned int newid=1;
     303
     304    COUT(2) << "Server: adding client" << std::endl;
    283305    ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
    284306    if(!temp){
     
    286308      return false;
    287309    }
    288     if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
    289       temp->setID(1);
     310    /*if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
     311      newid=1;
    290312    }
    291313    else
    292       temp->setID(temp->prev()->getID()+1);
     314      newid=temp->prev()->getID()+1;*/
     315    temp->setID(newid);
    293316    temp->setPeer(event->peer);
     317
     318    // inform all the listeners
     319    orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();
     320    while(listener){
     321      listener->clientConnected(newid);
     322      listener++;
     323    }
     324
     325    newid++;
     326
    294327    COUT(3) << "Server: added client id: " << temp->getID() << std::endl;
    295328    return createClient(temp->getID());
    296   }
     329}
    297330
    298331  bool Server::createClient(int clientID){
     
    304337    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
    305338    connection->syncClassid(temp->getID());
    306     COUT(5) << "creating spaceship for clientid: " << temp->getID() << std::endl;
    307     // TODO: this is only a hack, untill we have a possibility to define default player-join actions
    308     if(!createShip(temp))
    309       COUT(2) << "Con.Man. could not create ship for clientid: " << clientID << std::endl;
    310     else
    311       COUT(3) << "created spaceship" << std::endl;
    312339    temp->setSynched(true);
    313340    COUT(3) << "sending welcome" << std::endl;
     
    319346    g->setClientID(temp->getID());
    320347    b = g->collectData(0);
    321     assert(b);
     348    if(!b)
     349      return false; //no data for the client
    322350    b = g->compressData();
    323351    assert(b);
     
    327355  }
    328356
    329   bool Server::createShip(ClientInformation *client){
    330     if(!client)
    331       return false;
    332     orxonox::Identifier* id = ClassByName("SpaceShip");
    333     if(!id){
    334       COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;
    335       return false;
    336     }
    337     orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());
    338     no->classID = id->getNetworkID();
    339     client->setShipID(no->getObjectID());
    340     no->setPosition(orxonox::Vector3(0,0,80));
    341     no->setScale(10);
    342     //no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0));
    343     no->setMesh("assff.mesh");
    344     no->setMaxSpeed(500);
    345     no->setMaxSideAndBackSpeed(50);
    346     no->setMaxRotation(1.0);
    347     no->setTransAcc(200);
    348     no->setRotAcc(3.0);
    349     no->setTransDamp(75);
    350     no->setRotDamp(1.0);
    351     no->setCamera(std::string("cam_") + convertToString(client->getID()));
    352     no->create();
    353 
    354     return true;
    355   }
    356 
    357357  bool Server::disconnectClient(ENetEvent *event){
    358358    COUT(4) << "removing client from list" << std::endl;
     
    360360
    361361    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    362     orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    363362    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    364363    if(!client)
    365364      return false;
    366365    gamestates_->removeClient(client);
    367     while(it){
    368       if(it->getObjectID()!=client->getShipID()){
    369         ++it;
    370         continue;
    371       }
    372       orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
    373       ++it;
    374       delete  *temp;
    375       return ClientInformation::removeClient(event->peer);
    376     }
    377     return false;
     366
     367// inform all the listeners
     368    orxonox::ObjectList<ClientConnectionListener>::iterator listener = orxonox::ObjectList<ClientConnectionListener>::begin();
     369    while(listener){
     370      listener->clientDisconnected(client->getID());
     371      listener++;
     372    }
     373
     374    return ClientInformation::removeClient(event->peer);
    378375  }
    379376
     
    387384    gamestates_->removeClient(client);
    388385  }
    389  
    390   bool Server::chat(std::string message){
     386
     387  bool Server::chat(const std::string& message){
     388      return this->sendChat(message, Host::getPlayerID());
     389  }
     390
     391  bool Server::broadcast(const std::string& message){
     392      return this->sendChat(message, CLIENTID_UNKNOWN);
     393  }
     394
     395  bool Server::sendChat(const std::string& message, unsigned int clientID){
    391396    ClientInformation *temp = ClientInformation::getBegin();
    392397    packet::Chat *chat;
    393398    while(temp){
    394       chat = new packet::Chat(message, Host::getPlayerID());
     399      chat = new packet::Chat(message, clientID);
    395400      chat->setClientID(temp->getID());
    396401      if(!chat->send())
     
    398403      temp = temp->next();
    399404    }
    400     COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl;
     405//    COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl;
     406    for (orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it)
     407      it->incomingChat(message, clientID);
     408
    401409    return true;
    402410  }
  • code/trunk/src/network/Server.h

    r1907 r2087  
    5252{
    5353  const int CLIENTID_SERVER = 0;
    54  
     54
    5555  /**
    5656  * This class is the root class of the network module for a server.
     
    6161    Server();
    6262    Server(int port);
    63     Server(int port, std::string bindAddress);
     63    Server(int port, const std::string& bindAddress);
    6464    Server(int port, const char *bindAddress);
    6565    ~Server();
    66    
     66
    6767    void open();
    6868    void close();
    69     bool processChat(std::string message, unsigned int playerID);
     69    bool processChat(const std::string& message, unsigned int playerID);
    7070    bool queuePacket(ENetPacket *packet, int clientID);
    7171    void tick(float time);
     72    unsigned int getPing(unsigned int clientID);
     73    double getPacketLoss(unsigned int clientID);
    7274  protected:
    7375    void processQueue();
     
    7779    unsigned int shipID(){return 0;}
    7880    unsigned int playerID(){return 0;}
    79    
     81
    8082    bool addClient(ENetEvent *event);
    8183    bool createClient(int clientID);
    82     bool createShip(ClientInformation *client);
    8384    bool disconnectClient(ENetEvent *event);
    8485    void disconnectClient(int clientID);
     
    8788    bool sendGameState();
    8889    bool sendObjectDeletes();
    89     virtual bool chat(std::string message);
    90    
     90    virtual bool chat(const std::string& message);
     91    virtual bool broadcast(const std::string& message);
     92    bool sendChat(const std::string& message, unsigned int clientID);
     93
    9194    //void processChat( chat *data, int clientId);
    9295    ConnectionManager *connection;
    9396    GamestateManager *gamestates_;
    9497
    95    
     98
    9699    float timeSinceLastUpdate_;
    97100  };
  • code/trunk/src/network/Synchronisable.cc

    r1907 r2087  
    4242
    4343#include <cstring>
     44#include <string>
    4445#include <iostream>
    4546#include <assert.h>
     
    5152namespace network
    5253{
    53  
     54
    5455
    5556  std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
     
    6263  * Initializes all Variables and sets the right objectID
    6364  */
    64   Synchronisable::Synchronisable(){
     65  Synchronisable::Synchronisable(orxonox::BaseObject* creator){
    6566    RegisterRootObject(Synchronisable);
    6667    static uint32_t idCounter=0;
     
    6869    objectMode_=0x1; // by default do not send data to server
    6970    objectID=idCounter++;
     71    classID = (unsigned int)-1;
    7072    syncList = new std::list<synchronisableVariable *>;
    71   }
    72 
    73   /**
    74    * Destructor:
     73
     74    this->creatorID = OBJECTID_UNKNOWN;
     75
     76    searchcreatorID:
     77    if (creator)
     78    {
     79        Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
     80        if (synchronisable_creator && synchronisable_creator->objectMode_)
     81        {
     82            this->creatorID = synchronisable_creator->getObjectID();
     83        }
     84        else if (creator != creator->getCreator())
     85        {
     86            creator = creator->getCreator();
     87            goto searchcreatorID;
     88        }
     89    }
     90  }
     91
     92  /**
     93   * Destructor:
    7594   * Delete all callback objects and remove objectID from the objectMap_
    7695   */
     
    8099      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
    81100        delete (*it)->callback;
    82       deletedObjects_.push(objectID);
     101      if (this->objectMode_ != 0x0)
     102        deletedObjects_.push(objectID);
    83103//       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
    84104//       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
     
    96116    this->classID = this->getIdentifier()->getNetworkID();
    97117//     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
    98    
     118
    99119//     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
    100120//     objectMap_[objectID]=this;
     
    127147    synchronisableHeader *header = (synchronisableHeader *)mem;
    128148
    129     COUT(3) << "fabricating object with id: " << header->objectID << std::endl;
     149    if(!header->dataAvailable)
     150    {
     151      mem += header->size;
     152      return 0;
     153    }
     154   
     155    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
    130156
    131157    orxonox::Identifier* id = ClassByID(header->classID);
    132158    assert(id);
    133     orxonox::BaseObject *bo = id->fabricate();
     159    orxonox::BaseObject* creator = 0;
     160    if (header->creatorID != OBJECTID_UNKNOWN)
     161    {
     162      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
     163      if (!synchronisable_creator)
     164      {
     165        mem += header->size; //.TODO: this suckz.... remove size from header
     166        return 0;
     167      }
     168      else
     169        creator = dynamic_cast<orxonox::BaseObject*>(synchronisable_creator);
     170    }
     171    orxonox::BaseObject *bo = id->fabricate(creator);
     172    assert(bo);
    134173    Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
    135174    assert(no);
    136175    no->objectID=header->objectID;
     176    no->creatorID=header->creatorID; //TODO: remove this
    137177    no->classID=header->classID;
    138     COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
     178    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
    139179          // update data and create object/entity...
    140     bool b = no->updateData(mem, mode);
     180    bool b = no->updateData(mem, mode, true);
    141181    assert(b);
    142     b = no->create();
    143     assert(b);
     182    if (b)
     183    {
     184        b = no->create();
     185        assert(b);
     186    }
    144187    return no;
    145188  }
    146189
    147  
     190
    148191  /**
    149192   * Finds and deletes the Synchronisable with the appropriate objectID
     
    164207    return true;
    165208  }
    166  
     209
    167210  /**
    168211   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
     
    185228  }
    186229
    187  
     230
    188231  /**
    189232  * This function is used to register a variable to be synchronized
     
    196239  */
    197240  void Synchronisable::registerVar(void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){
     241    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
    198242    // create temporary synch.Var struct
    199243    synchronisableVariable *temp = new synchronisableVariable;
     
    203247    temp->type = t;
    204248    temp->callback = cb;
     249    if( ( mode & direction::bidirectional ) )
     250    {
     251      temp->varBuffer = new uint8_t[size];
     252      memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time
     253      temp->varReference = 0;
     254    }
    205255    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
    206256    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
     
    228278   *             0x2: client->server (not recommended)
    229279   *             0x3: bidirectional
    230    * @return true: if !isMyTick or if everything was successfully saved
     280   * @return true: if !doSync or if everything was successfully saved
    231281   */
    232282  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){
    233283    //if this tick is we dont synchronise, then abort now
    234     if(!isMyTick(id))
     284    if(!doSync(id))
    235285      return true;
    236286    //std::cout << "inside getData" << std::endl;
     
    240290    if(classID==0)
    241291      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
     292
     293    if (this->classID == (unsigned int)-1)
     294        this->classID = this->getIdentifier()->getNetworkID();
     295
    242296    assert(this->classID==this->getIdentifier()->getNetworkID());
    243297//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
     
    250304    header->size = size;
    251305    header->objectID = this->objectID;
     306    header->creatorID = this->creatorID;
    252307    header->classID = this->classID;
    253308    header->dataAvailable = true;
     
    263318        COUT(5) << "not getting data: " << std::endl;
    264319        continue;  // this variable should only be received
     320      }
     321      // if the variable gets synchronised bidirectional, then add the reference to the bytestream
     322      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
     323      {
     324        *(uint8_t*)mem = (*i)->varReference;
     325        mem += sizeof( (*i)->varReference );
     326        tempsize += sizeof( (*i)->varReference );
    265327      }
    266328      switch((*i)->type){
     
    271333          break;
    272334        case STRING:
    273           memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(int) );
    274           mem+=sizeof(int);
     335          memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) );
     336          mem+=sizeof(size_t);
    275337          const char *data = ( ( *(std::string *) (*i)->var).c_str());
    276338          memcpy( mem, (void*)data, (*i)->size);
    277339          COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
    278340          mem+=(*i)->size;
    279           tempsize+=(*i)->size + 4;
     341          tempsize+=(*i)->size + sizeof(size_t);
    280342          break;
    281343      }
     
    292354   * @return true/false
    293355   */
    294   bool Synchronisable::updateData(uint8_t*& mem, int mode){
     356  bool Synchronisable::updateData(uint8_t*& mem, int mode, bool forceCallback){
    295357    if(mode==0x0)
    296358      mode=state_;
     
    305367    synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
    306368    assert(syncHeader->objectID==this->objectID);
     369//    assert(syncHeader->creatorID==this->creatorID);
    307370    if(syncHeader->dataAvailable==false){
    308371      mem+=syncHeader->size;
     
    314377    assert(this->objectID==syncHeader->objectID);
    315378//    assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
    316    
     379
    317380    COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
    318381    for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){
     
    325388      switch((*i)->type){
    326389        case DATA:
     390          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
     391          {
     392            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
     393                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master on this variable
     394            {
     395              uint8_t refNr = *(uint8_t *)mem;
     396              if( refNr != (*i)->varReference )
     397              {
     398                mem += sizeof((*i)->varReference) + (*i)->size; // the reference for this variable is not recent, discard data
     399                break;
     400              }
     401            }
     402            else //we are slave for this variable
     403            {
     404              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
     405            }
     406            mem += sizeof((*i)->varReference);
     407          }
    327408          if((*i)->callback) // check whether this variable changed (but only if callback was set)
    328409            if(strncmp((char *)(*i)->var, (char *)mem, (*i)->size)!=0)
     
    332413          break;
    333414        case STRING:
    334           (*i)->size = *(uint32_t *)mem;
     415          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
     416          {
     417            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
     418                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master for this variable
     419            {
     420              uint8_t refNr = *(uint8_t *)mem;
     421              mem += sizeof( (*i)->varReference );
     422              if( refNr != (*i)->varReference ){
     423                mem += sizeof(size_t) + *(size_t *)mem; // the reference for this variable is not recent, discard data
     424                break;
     425              }
     426            }
     427            else //we are slave for this variable
     428            {
     429              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
     430            }
     431            mem += sizeof( (*i)->varReference );
     432          }
     433          (*i)->size = *(size_t *)mem;
    335434          COUT(5) << "string size: " << (*i)->size << std::endl;
    336           mem+=sizeof(int);
     435          mem += sizeof(size_t);
    337436          if((*i)->callback) // check whether this string changed
    338437            if( *(std::string *)((*i)->var) != std::string((char *)mem) )
     
    344443      }
    345444      // call the callback function, if defined
    346       if(callback && (*i)->callback)
     445      if((callback || forceCallback) && (*i)->callback)
    347446        (*i)->callback->call();
    348447    }
     
    357456  */
    358457  uint32_t Synchronisable::getSize(unsigned int id, int mode){
    359     if(!isMyTick(id))
     458    if(!doSync(id))
    360459      return 0;
    361460    int tsize=sizeof(synchronisableHeader);
     
    377476        break;
    378477      }
     478      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
     479      {
     480        tsize+=sizeof( (*i)->varReference );
     481      }
    379482    }
    380483    return tsize;
     
    386489   * @return true/false
    387490   */
    388   bool Synchronisable::isMyTick(unsigned int id){
    389     return ( (objectMode_&state_)!=0 );
     491  bool Synchronisable::doSync(unsigned int id){
     492    return ( (objectMode_&state_)!=0 && (!syncList->empty() ) );
    390493  }
    391494
     
    413516   */
    414517  void Synchronisable::setObjectMode(int mode){
    415     assert(mode==0x1 || mode==0x2 || mode==0x3);
     518    assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
    416519    objectMode_=mode;
    417520  }
  • code/trunk/src/network/Synchronisable.h

    r1910 r2087  
    4141#include "util/Integers.h"
    4242
    43 #define REGISTERDATA(varname) registerVar(&varname, sizeof(varname), network::DATA)
    44 #define REGISTERDATA_WITHDIR(varname, mode) registerVar(&varname, sizeof(varname), network::DATA, mode)
    45 #define REGISTERSTRING(stringname) registerVar(&stringname, stringname.length()+1, network::STRING)
    46 #define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)
    47 
    48 //TODO: this is only a very ugly hack ...
    49 namespace orxonox{
    50 class SpaceShip;
    51 }
     43#define REGISTERDATA(varname, ...) \
     44    registerVar((void*)&varname, sizeof(varname), network::DATA, __VA_ARGS__)
     45#define REGISTERSTRING(stringname, ...) \
     46    registerVar(&stringname, stringname.length()+1, network::STRING, __VA_ARGS__)
    5247
    5348namespace network
    5449{
     50  static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1;
     51
    5552  namespace direction{
    5653    enum syncdirection{
    5754      toclient=0x1,
    5855      toserver=0x2,
    59       bidirectional=0x3
     56      bidirectional=0x3,
     57      serverMaster=0x3,
     58      clientMaster=0x7
    6059    };
    6160  }
    62  
     61
    6362  namespace syncmode{
    6463    enum mode{
     
    6766    };
    6867  }
    69  
     68
    7069  enum variableType{
    7170    DATA,
     
    7372  };
    7473
    75   struct synchronisableHeader{
     74  struct _NetworkExport synchronisableHeader{
    7675    uint32_t size:31;
    7776    bool dataAvailable:1;
    7877    uint32_t objectID;
     78    uint32_t creatorID;
    7979    uint32_t classID;
    8080  };
    8181
    82   typedef struct synchronisableVariable{
     82  struct _NetworkExport synchronisableVariable{
    8383    unsigned int size;
    8484    int mode; // this determines in which direction the variable gets synchronised
     
    8686    variableType type;
    8787    NetworkCallbackBase *callback;
    88   }SYNCVAR;
     88    void *varBuffer;
     89    uint8_t varReference;
     90  };
    8991
    9092  /**
     
    98100    friend class GamestateClient;
    99101    friend class Server;
    100     friend class orxonox::SpaceShip;
    101102    virtual ~Synchronisable();
    102103
    103    
     104
    104105    virtual bool create();
    105106    static void setClient(bool b);
    106    
     107
    107108    static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);
    108109    static bool deleteObject(unsigned int objectID);
     
    110111    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
    111112    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    112    
     113
    113114    inline unsigned int getObjectID(){return objectID;}
    114115    inline unsigned int getClassID(){return classID;}
    115116  protected:
    116     Synchronisable();
     117    Synchronisable(orxonox::BaseObject* creator);
    117118    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
    118119    void setObjectMode(int mode);
    119120    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
    120     virtual void registerAllVariables()=0;
    121    
    122    
     121
     122
    123123  private:
    124124    bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
    125125    uint32_t getSize(unsigned int id, int mode=0x0);
    126     bool updateData(uint8_t*& mem, int mode=0x0);
     126    bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);
    127127    bool isMyData(uint8_t* mem);
    128128    bool doSelection(unsigned int id);
    129     bool isMyTick(unsigned int id);
    130    
     129    bool doSync(unsigned int id);
     130
    131131    unsigned int objectID;
     132    unsigned int creatorID;
    132133    unsigned int classID;
    133    
     134
    134135    std::list<synchronisableVariable *> *syncList;
    135136    static int state_; // detemines wheter we are server (default) or client
  • code/trunk/src/network/packet/Acknowledgement.h

    r1907 r2087  
    2929#define NETWORKACKNOLEDGEMENT_H
    3030
     31#include "../NetworkPrereqs.h"
    3132#include "Packet.h"
    3233
     
    3536namespace packet {
    3637/**
    37         @author 
     38        @author
    3839*/
    39 class Acknowledgement : public Packet
     40class _NetworkExport Acknowledgement : public Packet
    4041{
    4142public:
     
    4344  Acknowledgement( uint8_t* data, unsigned int clientID );
    4445  ~Acknowledgement();
    45  
     46
    4647  inline unsigned int getSize() const;
    4748  bool process();
    48  
     49
    4950  unsigned int getAckID();
    5051private:
  • code/trunk/src/network/packet/Chat.h

    r1907 r2087  
    22#ifndef NETWORKCHAT_H
    33#define NETWORKCHAT_H
     4
     5#include "../NetworkPrereqs.h"
    46
    57#include <string>
     
    1113namespace packet {
    1214/**
    13         @author 
     15        @author
    1416*/
    15 class Chat : public Packet
     17class _NetworkExport Chat : public Packet
    1618{
    1719public:
     
    1921  Chat( uint8_t* data, unsigned int clientID );
    2022  ~Chat();
    21  
     23
    2224  inline unsigned int getSize() const;
    2325  bool process();
    24  
     26
    2527  unsigned int getMessageLength(){ return messageLength_; };
    2628  unsigned char *getMessage();
  • code/trunk/src/network/packet/ClassID.h

    r1907 r2087  
    2929#define NETWORKCLASSID_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include <string>
    3234
     
    3739
    3840/**
    39         @author 
     41        @author
    4042*/
    41 class ClassID : public Packet
     43class _NetworkExport ClassID : public Packet
    4244{
    4345public:
     
    4547  ClassID( uint8_t* data, unsigned int clientID );
    4648  ~ClassID();
    47  
     49
    4850  inline unsigned int getSize() const;
    4951  bool process();
    50  
     52
    5153  unsigned int getClassID();
    5254  unsigned int getClassNameLength(){ return classNameLength_; }
  • code/trunk/src/network/packet/DeleteObjects.h

    r1907 r2087  
    2929#define NETWORKPACKETDELETEOBJECTS_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include "Packet.h"
    3234
     
    3537namespace packet {
    3638/**
    37         @author 
     39        @author
    3840*/
    39 class DeleteObjects : public Packet
     41class _NetworkExport DeleteObjects : public Packet
    4042{
    4143public:
     
    4345  DeleteObjects( uint8_t* data, unsigned int clientID );
    4446  ~DeleteObjects();
    45  
     47
    4648  bool fetchIDs();
    47  
     49
    4850  inline unsigned int getSize() const;
    4951  bool process();
    50  
     52
    5153private:
    5254};
  • code/trunk/src/network/packet/Gamestate.cc

    r1907 r2087  
    4646#define HEADER GAMESTATE_HEADER(data_)
    4747
    48  
     48
    4949#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
    50  
     50
    5151Gamestate::Gamestate()
    5252{
     
    8585    return false;
    8686  }
    87  
     87
    8888#ifndef NDEBUG
    8989  std::list<Synchronisable*> slist;
     
    115115    slist.push_back(*it);
    116116#endif
    117    
     117
    118118    //if(it->doSelection(id))
    119119    dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
     
    157157    if(!s)
    158158    {
    159       s = Synchronisable::fabricate(mem, mode);
    160       assert(s);
    161 //       if(!s)
    162 //         return false;
     159      Synchronisable::fabricate(mem, mode);
    163160    }
    164161    else
     
    257254  HEADER->compressed = true;
    258255  assert(HEADER->compressed);
    259   COUT(3) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
     256  COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
    260257  return true;
    261258}
     
    264261  assert(HEADER);
    265262  assert(HEADER->compressed);
    266   COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
     263  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
    267264  unsigned int datasize = HEADER->datasize;
    268265  unsigned int compsize = HEADER->compsize;
    269266  unsigned int bufsize;
    270   assert(compsize<=datasize);
     267//  assert(compsize<=datasize);
    271268  bufsize = datasize;
    272269  assert(bufsize!=0);
     
    289286  //copy over the header
    290287  *GAMESTATE_HEADER(ndata) = *HEADER;
    291   //delete old (compressed data)
    292   delete[] data_;
     288
     289  if (this->bDataENetAllocated_){
     290    // Memory was allocated by ENet. --> We let it be since enet_packet_destroy will
     291    // deallocated it anyway. So data and packet stay together.
     292    this->bDataENetAllocated_ = false;
     293  }
     294  else{
     295    // We allocated the memory in the first place (unlikely). So we destroy the old data
     296    // and overwrite it with the new decompressed data.
     297    delete[] this->data_;
     298  }
     299
    293300  //set new pointers
    294301  data_ = ndata;
     
    339346  assert(data_);
    340347  std::map<unsigned int, Synchronisable *>::iterator it;
    341  
     348
    342349  // allocate memory for new data
    343350  uint8_t *gdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
     
    346353  uint8_t *newdata = gdata + sizeof(GamestateHeader);
    347354  uint8_t *origdata = GAMESTATE_START(data_);
    348  
     355
    349356  //copy the GamestateHeader
    350357  *(GamestateHeader*)gdata = *HEADER;
    351  
     358
    352359  synchronisableHeader *oldobjectheader, *newobjectheader;
    353360  unsigned int objectOffset;
    354  
     361
    355362  //copy in the zeros
    356363  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
     
    360367    assert(it->second->objectID==oldobjectheader->objectID);
    361368    *newobjectheader = *oldobjectheader;
    362     objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableDate variables in the objectheader
     369    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
    363370    if(it->second->doSelection(HEADER->id)){
    364371      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
     
    390397  assert(!HEADER->compressed);
    391398  assert(!HEADER->diffed);
    392  
     399
    393400  //preparations
    394401  std::map<unsigned int, Synchronisable *>::iterator it;
    395402  uint8_t *origdata, *basedata, *destdata, *ndata;
    396403  unsigned int objectOffset, streamOffset=0;    //data offset
    397   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 
     404  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    398405  synchronisableHeader *origheader;
    399406  synchronisableHeader *destheader;
    400  
     407
    401408  origdata = GAMESTATE_START(this->data_);
    402409  basedata = GAMESTATE_START(base->data_);
    403410  ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
    404411  destdata = ndata + sizeof(GamestateHeader);
    405  
     412
    406413  // do the diff
    407414  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
     
    410417    origheader = (synchronisableHeader *)(origdata+streamOffset);
    411418    destheader = (synchronisableHeader *)(destdata+streamOffset);
    412    
     419
    413420    //copy and partially diff the object header
    414421    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
     
    420427    }else{
    421428      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
    422       *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0; 
     429      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
    423430    }
    424431    objectOffset=sizeof(synchronisableHeader);
    425432    streamOffset+=sizeof(synchronisableHeader);
    426    
     433
    427434    //now handle the object data or fill with zeros
    428435    while(objectOffset<origheader->size ){
    429      
     436
    430437      if(sendData && streamOffset<minsize)
    431438        *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
     
    434441      else
    435442        *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
    436      
     443
    437444      objectOffset++;
    438445      streamOffset++;
     
    442449    basedata+=objectOffset;
    443450  }
    444  
     451
    445452  //copy over the gamestate header and set the diffed flag
    446453  *(GamestateHeader *)ndata = *HEADER; //copy over the header
     
    458465  assert(!HEADER->compressed);
    459466  assert(HEADER->diffed);
    460  
     467
    461468  //preparations
    462469  std::map<unsigned int, Synchronisable *>::iterator it;
    463470  uint8_t *origdata, *basedata, *destdata, *ndata;
    464471  unsigned int objectOffset, streamOffset=0;    //data offset
    465   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 
     472  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    466473  synchronisableHeader *origheader;
    467474  synchronisableHeader *destheader;
    468  
     475
    469476  origdata = GAMESTATE_START(this->data_);
    470477  basedata = GAMESTATE_START(base->data_);
    471478  ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
    472479  destdata = ndata + sizeof(GamestateHeader);
    473  
     480
    474481  // do the undiff
    475482  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
     
    478485    destheader = (synchronisableHeader *)(destdata+streamOffset);
    479486    bool sendData;
    480    
     487
    481488    //copy and partially diff the object header
    482489    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
     
    489496    }else{
    490497      *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
    491       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0; 
     498      *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
    492499    }
    493500    objectOffset=sizeof(synchronisableHeader);
    494501    streamOffset+=sizeof(synchronisableHeader);
    495    
     502
    496503    //now handle the object data or fill with zeros
    497504    while(objectOffset<origheader->size ){
    498      
     505
    499506      if(sendData && streamOffset<minsize)
    500507        *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
     
    503510      else
    504511        *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
    505      
     512
    506513      objectOffset++;
    507514      streamOffset++;
     
    511518    basedata+=objectOffset;
    512519  }
    513  
     520
    514521  //copy over the gamestate header and set the diffed flag
    515522  *(GamestateHeader *)ndata = *HEADER; //copy over the header
  • code/trunk/src/network/packet/Gamestate.h

    r1907 r2087  
    2727 */
    2828
     29
     30#ifndef NETWORK_PACKETGAMESTATE_H
     31#define NETWORK_PACKETGAMESTATE_H
     32
     33#include "../NetworkPrereqs.h"
     34
    2935#include "Packet.h"
    3036#include "network/Synchronisable.h"
     
    3440#endif
    3541
    36 
    37 #ifndef NETWORK_PACKETGAMESTATE_H
    38 #define NETWORK_PACKETGAMESTATE_H
    39 
    4042namespace network {
    4143
    4244namespace packet {
    4345
    44 struct GamestateHeader{
     46struct _NetworkExport GamestateHeader{
    4547  ENUM::Type packetType;
    4648  int32_t id; // id of the gamestate
     
    5961        @author Oliver Scheuss
    6062*/
    61 class Gamestate: public Packet{
     63class _NetworkExport Gamestate: public Packet{
    6264  public:
    6365    Gamestate();
  • code/trunk/src/network/packet/Packet.cc

    r1907 r2087  
    4949
    5050namespace packet{
    51  
     51
    5252#define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
    5353#define _PACKETID           0
    54  
     54
    5555std::map<ENetPacket *, Packet *> Packet::packetMap_;
    56  
     56
    5757Packet::Packet(){
    5858  flags_ = PACKET_FLAG_DEFAULT;
     
    6161  data_=0;
    6262  enetPacket_=0;
     63  bDataENetAllocated_ = false;
    6364}
    6465
     
    7374  data_=data;
    7475  enetPacket_=0;
     76  bDataENetAllocated_ = false;
    7577}
    7678
     
    8688  }else
    8789    data_=0;
    88 }
    89 
     90  bDataENetAllocated_ = p.bDataENetAllocated_;
     91}
     92
     93/**
     94@brief
     95    Destroys a packet completely.
     96   
     97    That also means destroying the ENetPacket if one exists. There
     98*/
    9099Packet::~Packet(){
    91   if(enetPacket_){
    92     assert(enetPacket_->freeCallback==0);
     100  // Deallocate data_ memory if necessary.
     101  if (this->bDataENetAllocated_){
     102    // In this case ENet allocated data_ and will destroy it.
     103  }
     104  else if (this->data_) {
     105    // This destructor was probably called as a consequence to ENet executing our callback.
     106    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
     107    // we have created it in the first place.
     108    delete[] this->data_;
     109  }
     110
     111  // Destroy the ENetPacket if necessary.
     112  // Note: For the case ENet used the callback to destroy the packet, we have already set
     113  // enetPacket_ to NULL to avoid destroying it again.
     114  if (this->enetPacket_){
     115    // enetPacket_->data gets destroyed too by ENet if it was allocated by it.
    93116    enet_packet_destroy(enetPacket_);
    94117  }
    95   if(data_)
    96     delete[] data_;
    97118}
    98119
     
    107128      return false;
    108129    }
     130    // We deliver ENet the data address so that it doesn't memcpy everything again.
     131    // --> We have to delete data_ ourselves!
    109132    enetPacket_ = enet_packet_create(getData(), getSize(), getFlags());
    110133    enetPacket_->freeCallback = &Packet::deletePacket;
    111 //     enetPacket_->freeCallback = &blub;
     134    // Add the packet to a global list so we can access it again once enet calls our
     135    // deletePacket method. We can of course only give a one argument function to the ENet C library.
    112136    packetMap_[enetPacket_] = this;
    113137  }
    114 #ifndef NDEBUG 
     138#ifndef NDEBUG
    115139  switch( *(ENUM::Type *)(data_ + _PACKETID) )
    116140  {
     
    127151  }
    128152#endif
    129   ENetPacket *temp = enetPacket_;
    130   enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
    131   network::Host::addPacket( temp, clientID_);
     153//  ENetPacket *temp = enetPacket_;
     154//  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
     155  network::Host::addPacket( enetPacket_, clientID_);
    132156  return true;
    133157}
     
    135159Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
    136160  uint8_t *data = packet->data;
     161  assert(ClientInformation::findClient(&peer->address)->getID() != (unsigned int)-2 || !Host::isServer());
    137162  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    138163  Packet *p;
     
    169194      break;
    170195  }
     196
     197  // Data was created by ENet
     198  p->bDataENetAllocated_ = true;
     199
    171200  return p;
    172201}
    173202
    174 void Packet::deletePacket(ENetPacket *packet){
    175   assert(packetMap_[packet]);
    176   assert(packetMap_[packet]->enetPacket_==0);
    177   delete packetMap_[packet];
     203/**
     204@brief
     205    ENet calls this method whenever it wants to destroy a packet that contains
     206    data we allocated ourselves.
     207*/
     208void Packet::deletePacket(ENetPacket *enetPacket){
     209  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
     210  std::map<ENetPacket*, Packet*>::iterator it = packetMap_.find(enetPacket);
     211  assert(it != packetMap_.end());
     212  // Make sure we don't delete it again in the destructor
     213  it->second->enetPacket_ = 0;
     214  delete it->second;
     215  //packetMap_.erase(it);
     216  COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl;
    178217}
    179218
  • code/trunk/src/network/packet/Packet.h

    r1907 r2087  
    2929#define NETWORKPACKET_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include <map>
    3234#include <enet/enet.h>
     
    3739
    3840namespace packet{
    39  
     41
    4042namespace ENUM{
    4143  enum Direction{
     
    5355  };
    5456}
    55  
     57
    5658/**
    5759        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
    5860*/
    59 class Packet{
     61class _NetworkExport Packet{
    6062  public:
    6163    Packet(const Packet &p);
     
    6365    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
    6466    static void deletePacket(ENetPacket *packet);
    65    
     67
    6668    virtual unsigned char *getData(){ return data_; };
    6769    virtual unsigned int getSize() const =0;
     
    7375    void setClientID( int id )
    7476      { clientID_ = id; }
    75    
     77
    7678    bool send();
    7779  protected:
     
    8284    unsigned int clientID_;
    8385    ENUM::Direction packetDirection_;
     86    /** Pointer to the data. Be careful when deleting it because it might
     87        point to a location that was allocated by ENet.
     88        See bDataENetAllocated_ */
    8489    uint8_t *data_;
     90    /** Tells whether data_ was allocated by ENet or ourselves.
     91        data_ might no correlate with enetPacket_->data. */
     92    bool bDataENetAllocated_;
    8593  private:
    8694    static std::map<ENetPacket *, Packet *> packetMap_;
  • code/trunk/src/network/packet/Welcome.h

    r1907 r2087  
    2929#define NETWORKWELCOME_H
    3030
     31#include "../NetworkPrereqs.h"
     32
    3133#include "Packet.h"
    3234
     
    3537
    3638/**
    37         @author 
     39        @author
    3840*/
    39 class Welcome : public Packet
     41class _NetworkExport Welcome : public Packet
    4042{
    4143public:
     
    4345  Welcome( uint8_t* data, unsigned int clientID );
    4446  virtual ~Welcome();
    45  
     47
    4648  uint8_t *getData();
    4749  inline unsigned int getSize() const;
    4850  bool process();
    49  
     51
    5052private:
    5153};
  • code/trunk/src/orxonox/CMakeLists.txt

    r1844 r2087  
    11SET( ORXONOX_SRC_FILES
     2  CameraManager.cc
    23  GraphicsEngine.cc
     4  LevelManager.cc
    35  Main.cc
    46  Settings.cc
    5   SignalHandler.cc
    67
    78  gamestates/GSClient.cc
     
    3334  overlays/hud/HUDRadar.cc
    3435  overlays/hud/HUDSpeedBar.cc
     36  overlays/hud/ChatOverlay.cc
    3537
    3638  tools/BillboardSet.cc
    37   tools/Light.cc
    3839  tools/Mesh.cc
    3940  tools/ParticleInterface.cc
     
    4243  tools/WindowEventListener.cc
    4344
    44   objects/Ambient.cc
    45   objects/Backlight.cc
    46   objects/Camera.cc
    47   objects/CameraHandler.cc
    48   objects/Model.cc
    49   objects/NPC.cc
    50   objects/ParticleSpawner.cc
     45  objects/EventListener.cc
     46  objects/EventDispatcher.cc
     47  objects/EventTarget.cc
    5148  objects/Radar.cc
    5249  objects/RadarListener.cc
    5350  objects/RadarViewable.cc
    54   objects/Skybox.cc
    55   objects/SpaceShip.cc
    56   objects/SpaceShipAI.cc
    5751  objects/Tickable.cc
    58   objects/WorldEntity.cc
     52  objects/Test.cc
     53  objects/Script.cc
    5954
    60   objects/Projectile.cc
    61   objects/BillboardProjectile.cc
    62   objects/RotatingProjectile.cc
    63   objects/ParticleProjectile.cc
     55  objects/Scene.cc
     56  objects/worldentities/WorldEntity.cc
     57  objects/worldentities/PositionableEntity.cc
     58  objects/worldentities/MovableEntity.cc
     59  objects/worldentities/ControllableEntity.cc
     60  objects/worldentities/Model.cc
     61  objects/worldentities/Billboard.cc
     62  objects/worldentities/BlinkingBillboard.cc
     63  objects/worldentities/Light.cc
     64  objects/worldentities/Camera.cc
     65  objects/worldentities/CameraPosition.cc
     66  objects/worldentities/SpawnPoint.cc
     67  objects/worldentities/ParticleEmitter.cc
     68  objects/worldentities/ParticleSpawner.cc
     69#  objects/worldentities/Backlight.cc
     70
     71  objects/worldentities/triggers/Trigger.cc
     72  objects/worldentities/triggers/DistanceTrigger.cc
     73  objects/worldentities/triggers/EventTrigger.cc
     74
     75  objects/worldentities/pawns/Spectator.cc
     76  objects/worldentities/pawns/Pawn.cc
     77  objects/worldentities/pawns/SpaceShip.cc
     78
     79  objects/controllers/Controller.cc
     80  objects/controllers/HumanController.cc
     81
     82  objects/infos/Info.cc
     83  objects/infos/Level.cc
     84  objects/infos/PlayerInfo.cc
     85  objects/infos/HumanPlayer.cc
     86
     87  objects/gametypes/Gametype.cc
    6488
    6589  tolua/tolua_bind.cc
     
    76100  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
    77101)
    78        
     102
     103
    79104ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
    80105
     
    83108  SET( ORXONOXS_SRC_FILES
    84109    GraphicsEngine.cc
    85     objects/Ambient.cc
    86110    objects/Camera.cc
    87     objects/CameraHandler.cc
    88     objects/Explosion.cc
    89     objects/Model.cc
    90     objects/NPC.cc
    91     objects/Projectile.cc
    92     objects/Skybox.cc
    93     objects/SpaceShip.cc
    94     objects/WorldEntity.cc
     111    CameraManager.cc
    95112  )
    96113
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1755 r2087  
    6868    */
    6969    GraphicsEngine::GraphicsEngine()
    70         : root_(0)
    71         , renderWindow_(0)
    72         , levelSceneManager_(0)
    73         , viewport_(0)
     70//        : root_(0)
     71//        , renderWindow_(0)
     72//        , viewport_(0)
    7473    {
    7574        RegisterObject(GraphicsEngine);
     
    103102        singletonRef_s = 0;
    104103    }
    105 
    106     /**
    107     @brief
    108         Get the width of the render window
    109     @return
    110         The width of the render window
    111     */
    112     int GraphicsEngine::getWindowWidth() const
    113     {
    114         if (this->renderWindow_)
    115             return this->renderWindow_->getWidth();
    116         else
    117             return 0;
    118     }
    119 
    120     /**
    121     @brief
    122         Get the height of the render window
    123     @return
    124         The height of the render window
    125     */
    126     int GraphicsEngine::getWindowHeight() const
    127     {
    128         if (this->renderWindow_)
    129             return this->renderWindow_->getHeight();
    130         else
    131             return 0;
    132     }
    133 
    134     /**
    135     @brief
    136         Returns the window aspect ratio height/width.
    137     @return
    138         The window aspect ratio
    139     */
    140     float GraphicsEngine::getWindowAspectRatio() const
    141     {
    142         if (this->renderWindow_)
    143             return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
    144         else
    145             return 1.0f;
    146     }
    147104}
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1755 r2087  
    6161        void detailLevelParticleChanged();
    6262
    63         void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
    64         Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
    65 
    66         Ogre::Viewport* getViewport() { return this->viewport_; }
    67         Ogre::Root*     getOgreRoot() { return this->root_; }
    68 
    69         // several window properties
    70         int getWindowWidth() const;
    71         int getWindowHeight() const;
    72         float getWindowAspectRatio() const;
    7363        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
    7464        float getAverageTickTime() const          { return this->avgTickTime_; }
     
    8676        GraphicsEngine(GraphicsEngine&);
    8777
    88         Ogre::Root*         root_;                  //!< Ogre's root
    89         Ogre::RenderWindow* renderWindow_;          //!< the current render window
    90         Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
    91         Ogre::Viewport*     viewport_;              //!< default full size viewport
    92 
    9378        // stats
    9479        float               avgTickTime_;           //!< time in ms to tick() one frame
  • code/trunk/src/orxonox/Main.cc

    r1896 r2087  
    4040#include "util/OrxonoxPlatform.h"
    4141#include "util/Debug.h"
     42#include "util/SignalHandler.h"
    4243#include "core/ConfigFileManager.h"
    43 #include "SignalHandler.h"
    4444
    4545#include "gamestates/GSRoot.h"
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r1755 r2087  
    8080    class RadarListener;
    8181
     82    class CameraManager;
     83    class LevelManager;
     84
    8285    // objects
    83     class Ambient;
     86    class Scene;
     87
     88    class WorldEntity;
     89    class PositionableEntity;
     90    class MovableEntity;
     91    class ControllableEntity;
     92    class Sublevel;
     93
     94    class Model;
     95    class Billboard;
     96    class BlinkingBillboard;
     97    class Light;
    8498    class Backlight;
     99    class ParticleEmitter;
     100    class ParticleSpawner;
     101
    85102    class Camera;
    86     class Model;
    87     class NPC;
    88     class ParticleSpawner;
    89     class Skybox;
     103    class CameraPosition;
     104    class SpawnPoint;
     105
     106    class Spectator;
     107    class Pawn;
    90108    class SpaceShip;
    91     class SpaceShipAI;
    92     class WorldEntity;
    93109
    94     class Projectile;
    95     class BillboardProjectile;
    96     class RotatingProjectile;
    97     class ParticleProjectile;
     110    class Trigger;
     111    class DistanceTrigger;
     112    class EventTrigger;
     113
     114    class EventListener;
     115    class EventDispatcher;
     116    class EventTarget;
     117
     118    class Controller;
     119    class HumanController;
     120
     121    class Info;
     122    class Level;
     123    class PlayerInfo;
     124    class HumanPlayer;
     125
     126    class Gametype;
     127
     128    class Scores;
    98129
    99130    // tools
  • code/trunk/src/orxonox/OrxonoxStableHeaders.h

    r1841 r2087  
    3737#include "util/OrxonoxPlatform.h"
    3838
    39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH)
     39#if defined(ORXONOX_ENABLE_PCH)
    4040
    4141// including std headers here is useless since they're already precompiled
     
    4747#include <Ogre.h>
    4848#include <CEGUI.h>
     49#include "ois/OIS.h"
    4950#include <boost/thread/recursive_mutex.hpp>
    50 #include <boost/thread/mutex.hpp>
    51 #include <boost/thread/condition.hpp>
    52 #include <boost/thread/thread.hpp>
    53 
     51//#include <boost/thread/mutex.hpp>
     52//#include <boost/thread/condition.hpp>
     53//#include <boost/thread/thread.hpp>
     54#include <boost/static_assert.hpp>
    5455#include "tinyxml/ticpp.h"
    5556#include "tinyxml/tinyxml.h"
     57#include "tolua/tolua++.h"
    5658
    57 //Get around Windows hackery (windows.h is included by Ogre)
     59//Get around Windows hackery (windows.h is included by Ogre.h)
    5860#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    5961#  ifdef max
     
    6769//----------- Our files ----------
    6870//--------------------------------
    69 // only include when not debugging so that we may find issues with missing headers quicker
    70 #if defined(NDEBUG)
     71//// only include when not debugging so that we may find issues with missing headers quicker
     72//#if defined(NDEBUG)
    7173
    7274#include "util/Convert.h"
    7375#include "util/Debug.h"
     76#include "util/Exception.h"
    7477#include "util/Math.h"
    7578#include "util/Multitype.h"
    76 #include "util/OutputBuffer.h"
    77 #include "util/OutputHandler.h"
    7879#include "util/Sleep.h"
    7980#include "util/String.h"
     
    8586#include "core/ConfigValueIncludes.h"
    8687#include "core/CommandExecutor.h"
     88#include "core/Core.h"
    8789#include "core/Executor.h"
     90#include "core/ObjectList.h"
     91#include "core/Super.h"
    8892#include "core/XMLIncludes.h"
    8993#include "core/XMLPort.h"
     94#include "core/input/SimpleInputState.h"
     95#include "core/input/InputManager.h"
    9096
    9197#include "network/Synchronisable.h"
    9298
    93 //#include "tools/Mesh.h"
    94 //#include "tools/Timer.h"
    95 //#include "objects/Model.h"
    96 //#include "objects/Tickable.h"
    97 //#include "objects/WorldEntity.h"
     99#include "Settings.h"
    98100
    99 #endif /* ifdef NDEBUG */
     101//#endif /* ifdef NDEBUG */
    100102
    101103#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
  • code/trunk/src/orxonox/Settings.cc

    r1907 r2087  
    3939#include "core/CoreIncludes.h"
    4040#include "core/ConfigValueIncludes.h"
     41#include "core/LuaBind.h"
    4142
    4243namespace orxonox
     
    4950    */
    5051    Settings::Settings()
    51         : bShowsGraphics_(false)
    52         , bHasServer_(false)
    53         , bIsClient_(false)
    5452    {
    5553        RegisterRootObject(Settings);
     
    6563    void Settings::setConfigValues()
    6664    {
    67         SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
     65        SetConfigValue(dataPath_, "../../media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
    6866    }
    6967
     
    8482            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
    8583        }
     84
     85        LuaBind::getInstance()->setIncludePath(this->dataPath_);
    8686    }
    8787
  • code/trunk/src/orxonox/Settings.h

    r1907 r2087  
    5050        friend class ClassIdentifier<Settings>;
    5151        friend class GSRoot;
    52         friend class GSGraphics;
    53         friend class GSServer;
    54         friend class GSClient;
    55         friend class GSDedicated;
    5652
    5753    public:
     
    6157        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
    6258
    63         // an alternative to a global game mode variable
    64         static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }
    65         static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; }
    66         static bool isClient()      { assert(singletonRef_s); return singletonRef_s->bIsClient_; }
    67 
    6859    private:
    69         // GSRoot has access to these
    70         static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; }
    71         static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; }
    72         static void setIsClient     (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_      = val; }
    73 
    7460        Settings();
    7561        Settings(const Settings& instance);
     
    8268        void setConfigValues();
    8369
    84         bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
    85         bool bHasServer_;                                      //!< global variable that tells whether this is a server
    86         bool bIsClient_;
    87 
    8870        std::string dataPath_;                                 //!< Path to the game data
    8971
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r1907 r2087  
    3232#include "core/input/InputManager.h"
    3333#include "core/CommandLine.h"
     34#include "core/Core.h"
    3435#include "network/Client.h"
    35 #include "Settings.h"
    3636
    3737namespace orxonox
    3838{
    39     SetCommandLineArgument(ip, "127.0.0.1").setInformation("#.#.#.#");
     39    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
    4040
    4141    GSClient::GSClient()
    42         : GSLevel("client")
     42        : GameState<GSGraphics>("client")
    4343        , client_(0)
    4444    {
     
    5151    void GSClient::enter()
    5252    {
    53         Settings::_getInstance().bIsClient_ = true;
     53        Core::setIsClient(true);
    5454
    55         GSLevel::enter();
    56 
    57         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    58         std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue();
    59         this->client_ = new network::Client(serverIP, serverPort);
     55        this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
    6056
    6157        if(!client_->establishConnection())
    6258            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    6359
     60        GSLevel::enter(this->getParent()->getViewport());
     61
    6462        client_->tick(0);
    65 
    66         // level is loaded: we can start capturing the input
    67         InputManager::getInstance().requestEnterState("game");
    6863    }
    6964
    7065    void GSClient::leave()
    7166    {
    72         InputManager::getInstance().requestLeaveState("game");
    73 
    74         // TODO: How do we unload the level in client mode?
     67        GSLevel::leave();
    7568
    7669        client_->closeConnection();
     
    7972        delete this->client_;
    8073
    81         GSLevel::leave();
    82 
    83         Settings::_getInstance().bIsClient_ = false;
     74        Core::setIsClient(false);
    8475    }
    8576
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSClient : public GSLevel
     39    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r1790 r2087  
    3030#include "GSDedicated.h"
    3131
    32 #include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
    34 #include "core/ConsoleCommand.h"
    3532#include "core/CommandLine.h"
    36 #include "core/Loader.h"
     33#include "core/Core.h"
    3734#include "network/Server.h"
    38 #include "objects/Tickable.h"
    39 #include "GraphicsEngine.h"
    40 #include "Settings.h"
    4135
    4236namespace orxonox
     
    4438    GSDedicated::GSDedicated()
    4539        : GameState<GSRoot>("dedicated")
    46         , timeFactor_(0)
    4740        , server_(0)
    48         , sceneManager_(0)
    49         , startLevel_(0)
    5041    {
    5142    }
     
    5748    void GSDedicated::enter()
    5849    {
    59         Settings::_getInstance().bHasServer_ = true;
     50        Core::setHasServer(true);
    6051
    61         // create Ogre SceneManager for the level
    62         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    63         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
     52        this->server_ = new network::Server(CommandLine::getValue("port"));
     53        COUT(0) << "Loading scene in server mode" << std::endl;
    6454
    65         // temporary hack
    66         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    67 
    68         // reset game speed to normal
    69         timeFactor_ = 1.0f;
    70 
    71         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    72         this->server_ = new network::Server(serverPort);
    73 
    74         // call the loader
    75         COUT(0) << "Loading level..." << std::endl;
    76         startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
    77         Loader::open(startLevel_);
     55        GSLevel::enter(0);
    7856
    7957        server_->open();
    80 
    81         // add console commands
    82         FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    83         functor->setObject(this);
    84         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8558    }
    8659
    8760    void GSDedicated::leave()
    8861    {
    89         // TODO: Remove and destroy console command
    90 
    91         Loader::unload(startLevel_);
    92         delete this->startLevel_;
     62        GSLevel::leave();
    9363
    9464        this->server_->close();
    9565        delete this->server_;
    9666
    97         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    98 
    99         Settings::_getInstance().bHasServer_ = false;
     67        Core::setHasServer(false);
    10068    }
    10169
    10270    void GSDedicated::ticked(const Clock& time)
    10371    {
    104         // Call the scene objects
    105         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    106             it->tick(time.getDeltaTime() * this->timeFactor_);
    107 
     72        GSLevel::ticked(time);
    10873        server_->tick(time.getDeltaTime());
    10974        this->tickChild(time);
    11075    }
    111 
    112     /**
    113     @brief
    114         Changes the speed of Orxonox
    115     */
    116     void GSDedicated::setTimeFactor(float factor)
    117     {
    118         this->timeFactor_ = factor;
    119     }
    12076}
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
    3435#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSDedicated : public GameState<GSRoot>
     39    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
    3940    {
    4041    public:
    4142        GSDedicated();
    4243        ~GSDedicated();
    43 
    44         void setTimeFactor(float factor);
    45         float getTimeFactor() { return this->timeFactor_; }
    4644
    4745    private:
     
    5048        void ticked(const Clock& time);
    5149
    52         void loadLevel();
    53         void unloadLevel();
    54 
    55         float                 timeFactor_;       //!< A factor to change the gamespeed
    5650        network::Server*      server_;
    57         Ogre::SceneManager*   sceneManager_;
    58         Level*                startLevel_;       //!< current hard coded default level
    5951    };
    6052}
  • code/trunk/src/orxonox/gamestates/GSGUI.cc

    r1755 r2087  
    3131
    3232#include <OgreViewport.h>
    33 #include "GraphicsEngine.h"
    3433#include "core/input/InputManager.h"
    3534#include "core/input/SimpleInputState.h"
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r1891 r2087  
    4747#include "core/ConfigValueIncludes.h"
    4848#include "core/CoreIncludes.h"
     49#include "core/Core.h"
    4950#include "core/input/InputManager.h"
    5051#include "core/input/KeyBinder.h"
    5152#include "core/input/ExtendedInputState.h"
     53#include "core/Loader.h"
     54#include "core/XMLFile.h"
    5255#include "overlays/console/InGameConsole.h"
    5356#include "gui/GUIManager.h"
    5457#include "tools/WindowEventListener.h"
     58#include "objects/Tickable.h"
    5559#include "Settings.h"
    5660
     
    6468        , renderWindow_(0)
    6569        , viewport_(0)
     70        , bWindowEventListenerUpdateRequired_(false)
    6671        , inputManager_(0)
    6772        , console_(0)
     
    7681        , statisticsStartCount_(0)
    7782        , tickTime_(0)
     83        , debugOverlay_(0)
    7884    {
    7985        RegisterRootObject(GSGraphics);
     
    101107    void GSGraphics::enter()
    102108    {
    103         Settings::_getInstance().bShowsGraphics_ = true;
     109        Core::setShowsGraphics(true);
    104110
    105111        // initialise graphics engine. Doesn't load the render window yet!
     
    113119        this->initialiseResources();
    114120
    115 
    116         // HACK: temporary:
    117         graphicsEngine_->renderWindow_  = this->renderWindow_;
    118         graphicsEngine_->root_          = this->ogreRoot_;
    119         graphicsEngine_->viewport_      = this->viewport_;
    120 
     121        // We want to get informed whenever an object of type WindowEventListener is created
     122        // in order to later update the window size.
     123        bWindowEventListenerUpdateRequired_ = false;
     124        RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
     125
     126        // load debug overlay
     127        COUT(3) << "Loading Debug Overlay..." << std::endl;
     128        this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo");
     129        Loader::open(debugOverlay_);
    121130
    122131        // Calls the InputManager which sets up the input devices.
     
    133142        // Load the InGameConsole
    134143        console_ = new InGameConsole();
    135         console_->initialise();
     144        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    136145
    137146        // load the CEGUI interface
     
    165174        //delete this->masterKeyBinder_;
    166175        delete this->inputManager_;
     176
     177        Loader::unload(this->debugOverlay_);
     178        delete this->debugOverlay_;
    167179
    168180        // destroy render window
     
    196208        delete graphicsEngine_;
    197209
    198         Settings::_getInstance().bShowsGraphics_ = false;
     210        Core::setShowsGraphics(false);
    199211    }
    200212
     
    221233        this->console_->tick(dt);
    222234        this->tickChild(time);
    223        
     235
     236        /*** HACK *** HACK ***/
     237        // Call the Tickable objects
     238        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     239            it->tick(time.getDeltaTime());
     240        /*** HACK *** HACK ***/
     241
     242        if (this->bWindowEventListenerUpdateRequired_)
     243        {
     244            // Update all WindowEventListeners for the case a new one was created.
     245            this->windowResized(this->renderWindow_);
     246            this->bWindowEventListenerUpdateRequired_ = false;
     247        }
     248
    224249        unsigned long long timeAfterTick = time.getRealMicroseconds();
    225250
     
    487512        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    488513            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
     514
     515        // OIS needs this under linux even if we only use relative input measurement.
     516        if (this->inputManager_)
     517            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
    489518    }
    490519
     
    501530
    502531        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    503         InputManager::getInstance().clearBuffers();
     532        if (this->inputManager_)
     533            this->inputManager_->clearBuffers();
    504534    }
    505535
     
    512542    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
    513543    {
    514         // using CommandExecutor in order to avoid depending on Orxonox.h.
    515         //CommandExecutor::execute("exit", false);
    516544        this->requestState("root");
    517545    }
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r1891 r2087  
    7777        void windowClosed      (Ogre::RenderWindow* rw);
    7878
     79        void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
     80
    7981    private: // variables
    8082        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
    8183        Ogre::Viewport*       viewport_;              //!< default full size viewport
     84        bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
    8285
    8386        // managed singletons
     
    97100        unsigned long         statisticsStartCount_;
    98101        unsigned int          tickTime_;
     102        XMLFile*              debugOverlay_;
    99103
    100104        // config values
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r1755 r2087  
    3636
    3737#include "core/ConsoleCommand.h"
    38 #include "core/TclThreadManager.h"
    39 #include "GraphicsEngine.h"
    4038
    4139namespace orxonox
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r1934 r2087  
    3030#include "GSLevel.h"
    3131
    32 #include <OgreSceneManager.h>
    33 #include <OgreRoot.h>
    3432#include "core/input/InputManager.h"
    3533#include "core/input/SimpleInputState.h"
    3634#include "core/input/KeyBinder.h"
    3735#include "core/Loader.h"
     36#include "core/XMLFile.h"
    3837#include "core/CommandExecutor.h"
    3938#include "core/ConsoleCommand.h"
     
    4140#include "core/ConfigValueIncludes.h"
    4241#include "core/CoreIncludes.h"
    43 #include "objects/Backlight.h"
     42#include "core/Core.h"
     43//#include "objects/Backlight.h"
    4444#include "objects/Tickable.h"
    4545#include "objects/Radar.h"
    46 #include "tools/ParticleInterface.h"
     46//#include "tools/ParticleInterface.h"
     47#include "CameraManager.h"
     48#include "LevelManager.h"
    4749#include "Settings.h"
    48 #include "GraphicsEngine.h"
    4950
    5051namespace orxonox
    5152{
    52     SetCommandLineArgument(level, "sample.oxw").setShortcut("l");
    53 
    54     GSLevel::GSLevel(const std::string& name)
    55         : GameState<GSGraphics>(name)
    56         , timeFactor_(1.0f)
    57         , sceneManager_(0)
     53    SetCommandLineArgument(level, "sample2.oxw").shortcut("l");
     54
     55    GSLevel::GSLevel()
     56//        : GameState<GSGraphics>(name)
     57        : timeFactor_(1.0f)
    5858        , keyBinder_(0)
    5959        , inputState_(0)
    6060        , radar_(0)
    61         , startLevel_(0)
    62         , hud_(0)
     61        , startFile_(0)
     62        , cameraManager_(0)
     63        , levelManager_(0)
    6364    {
    6465        RegisterObject(GSLevel);
     
    7576    }
    7677
    77     void GSLevel::enter()
    78     {
    79         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
    80         keyBinder_ = new KeyBinder();
    81         keyBinder_->loadBindings("keybindings.ini");
    82         inputState_->setHandler(keyBinder_);
    83 
    84         // create Ogre SceneManager for the level
    85         this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    86         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
    87 
    88         // temporary hack
    89         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    90 
    91         // Start the Radar
    92         this->radar_ = new Radar();
    93 
    94         // Load the HUD
    95         COUT(3) << "Orxonox: Loading HUD" << std::endl;
    96         hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
    97         Loader::load(hud_);
    98 
    99         // reset game speed to normal
    100         timeFactor_ = 1.0f;
    101 
    102         // TODO: insert slomo console command with
    103         // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
    104 
    105         // keybind console command
    106         FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    107         functor1->setObject(this);
    108         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
    109         FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    110         functor2->setObject(this);
    111         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
    112         // set our console command as callback for the key detector
    113         InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     78    void GSLevel::enter(Ogre::Viewport* viewport)
     79    {
     80        if (Core::showsGraphics())
     81        {
     82            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
     83            keyBinder_ = new KeyBinder();
     84            keyBinder_->loadBindings("keybindings.ini");
     85            inputState_->setHandler(keyBinder_);
     86
     87            // create the global CameraManager
     88            assert(viewport);
     89            this->cameraManager_ = new CameraManager(viewport);
     90
     91            // Start the Radar
     92            this->radar_ = new Radar();
     93        }
     94
     95        if (Core::isMaster())
     96        {
     97            // create the global LevelManager
     98            this->levelManager_ = new LevelManager();
     99
     100            // reset game speed to normal
     101            timeFactor_ = 1.0f;
     102
     103            this->loadLevel();
     104        }
     105
     106        if (Core::showsGraphics())
     107        {
     108            // TODO: insert slomo console command with
     109            // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
     110
     111            // keybind console command
     112            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
     113            functor1->setObject(this);
     114            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     115            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
     116            functor2->setObject(this);
     117            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     118            // set our console command as callback for the key detector
     119            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     120
     121            // level is loaded: we can start capturing the input
     122            InputManager::getInstance().requestEnterState("game");
     123        }
     124
     125        if (Core::isMaster())
     126        {
     127            // time factor console command
     128            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
     129            functor->setObject(this);
     130            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     131        }
    114132    }
    115133
    116134    void GSLevel::leave()
    117135    {
    118         Loader::unload(hud_);
    119         delete this->hud_;
    120 
    121136        // this call will delete every BaseObject!
    122137        // But currently this will call methods of objects that exist no more
     
    125140        //Loader::close();
    126141
    127         delete this->radar_;
    128 
    129         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    130 
    131         inputState_->setHandler(0);
    132         InputManager::getInstance().requestDestroyState("game");
    133         delete this->keyBinder_;
     142        if (Core::showsGraphics())
     143            InputManager::getInstance().requestLeaveState("game");
     144
     145        if (Core::isMaster())
     146            this->unloadLevel();
     147
     148        if (this->radar_)
     149            delete this->radar_;
     150
     151        if (this->cameraManager_)
     152            delete this->cameraManager_;
     153
     154        if (this->levelManager_)
     155            delete this->levelManager_;
     156
     157        if (Core::showsGraphics())
     158        {
     159            inputState_->setHandler(0);
     160            InputManager::getInstance().requestDestroyState("game");
     161            if (this->keyBinder_)
     162                delete this->keyBinder_;
     163        }
    134164    }
    135165
    136166    void GSLevel::ticked(const Clock& time)
    137167    {
    138         // Call the scene objects
    139         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    140             it->tick(time.getDeltaTime() * this->timeFactor_);
     168        // Commented by 1337: Temporarily moved to GSGraphics.
     169        //// Call the scene objects
     170        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     171        //    it->tick(time.getDeltaTime() * this->timeFactor_);
    141172    }
    142173
     
    147178    void GSLevel::setTimeFactor(float factor)
    148179    {
     180/*
    149181        float change = factor / this->timeFactor_;
     182*/
    150183        this->timeFactor_ = factor;
     184/*
    151185        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    152186            it->setSpeedFactor(it->getSpeedFactor() * change);
     
    154188        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    155189            it->setTimeFactor(timeFactor_);
     190*/
    156191    }
    157192
     
    162197        std::string levelName;
    163198        CommandLine::getValue("level", &levelName);
    164         startLevel_ = new Level(Settings::getDataPath() + std::string("levels/") + levelName);
    165         Loader::open(startLevel_);
     199        startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName);
     200        Loader::open(startFile_);
    166201    }
    167202
    168203    void GSLevel::unloadLevel()
    169204    {
    170         Loader::unload(startLevel_);
    171         delete this->startLevel_;
     205        //////////////////////////////////////////////////////////////////////////////////////////
     206        // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO //
     207        //////////////////////////////////////////////////////////////////////////////////////////
     208        // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY /
     209        //////////////////////////////////////////////////////////////////////////////////////////
     210
     211        delete this->startFile_;
    172212    }
    173213
     
    192232    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    193233    {
    194         static std::string bindingString = "";
    195         static bool bTemporarySaved = false;
    196         static bool bound = true;
    197         // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
    198         // Howerver there will be no real issue if it happens anyway.
    199         if (command.find(keyDetectorCallbackCode_) != 0)
    200         {
    201             if (bound)
     234        if (Core::showsGraphics())
     235        {
     236            static std::string bindingString = "";
     237            static bool bTemporarySaved = false;
     238            static bool bound = true;
     239            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
     240            // Howerver there will be no real issue if it happens anyway.
     241            if (command.find(keyDetectorCallbackCode_) != 0)
    202242            {
    203                 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
    204                 InputManager::getInstance().requestEnterState("detector");
    205                 bindingString = command;
    206                 bTemporarySaved = bTemporary;
    207                 bound = false;
     243                if (bound)
     244                {
     245                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
     246                    InputManager::getInstance().requestEnterState("detector");
     247                    bindingString = command;
     248                    bTemporarySaved = bTemporary;
     249                    bound = false;
     250                }
     251                //else:  We're still in a keybind command. ignore this call.
    208252            }
    209             //else:  We're still in a keybind command. ignore this call.
    210         }
    211         else
    212         {
    213             if (!bound)
     253            else
    214254            {
    215                 // user has pressed the key
    216                 std::string name = command.substr(this->keyDetectorCallbackCode_.size());
    217                 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
    218                 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
    219                 InputManager::getInstance().requestLeaveState("detector");
    220                 bound = true;
     255                if (!bound)
     256                {
     257                    // user has pressed the key
     258                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
     259                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
     260                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
     261                    InputManager::getInstance().requestLeaveState("detector");
     262                    bound = true;
     263                }
     264                // else: A key was pressed within the same tick, ignore it.
    221265            }
    222             // else: A key was pressed within the same tick, ignore it.
    223266        }
    224267    }
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r1887 r2087  
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass
     39    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
    4040    {
    4141        friend class ClassIdentifier<GSLevel>;
    4242    public:
    43         GSLevel(const std::string& name);
    44         virtual ~GSLevel();
     43        GSLevel();
     44        ~GSLevel();
    4545
    4646        // this has to be public because proteced triggers a bug in msvc
     
    5050
    5151    protected:
    52         virtual void enter();
    53         virtual void leave();
    54         virtual void ticked(const Clock& time);
     52        void enter(Ogre::Viewport* viewport);
     53        void leave();
     54        void ticked(const Clock& time);
    5555
    5656        void loadLevel();
    5757        void unloadLevel();
    5858
    59         float timeFactor_;       //!< A factor to change the gamespeed
     59        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6060
    6161        // console commands
     
    6464        void keybindInternal(const std::string& command, bool bTemporary);
    6565
    66         Ogre::SceneManager*   sceneManager_;
    6766        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    6867        SimpleInputState*     inputState_;
    6968        Radar*                radar_;            //!< represents the Radar (not the HUD part)
    70         Level*                startLevel_;       //!< current hard coded default level
    71         Level*                hud_;              //!< 'level' object fo the HUD
     69        XMLFile*              startFile_;        //!< current hard coded default level
     70        CameraManager*        cameraManager_;
     71        LevelManager*         levelManager_;
    7272
    7373        // config values
    7474        std::string           keyDetectorCallbackCode_;
    75        
     75
    7676    private:
    7777        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r1891 r2087  
    4141#include "core/TclThreadManager.h"
    4242#include "tools/Timer.h"
    43 #include "GraphicsEngine.h"
    4443#include "Settings.h"
    4544
     
    6160namespace orxonox
    6261{
    63     SetCommandLineArgument(dataPath, "").setInformation("PATH");
    64     SetCommandLineArgument(limitToCPU, 1).setInformation("0: off | #cpu");
     62    SetCommandLineArgument(dataPath, "").information("PATH");
     63    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
    6564
    6665    GSRoot::GSRoot()
     
    9190        this->settings_ = new Settings();
    9291
    93         std::string dataPath;
    94         CommandLine::getValue("dataPath", &dataPath);
     92        std::string dataPath = CommandLine::getValue("dataPath");
    9593        if (dataPath != "")
    9694        {
     
    111109        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    112110        // the timer though).
    113         int limitToCPU;
    114         CommandLine::getValue("limitToCPU", &limitToCPU);
     111        int limitToCPU = CommandLine::getValue("limitToCPU");
    115112        if (limitToCPU > 0)
    116113            setThreadAffinity((unsigned int)(limitToCPU - 1));
     
    157154        Copyright (c) 2000-2008 Torus Knot Software Ltd
    158155       
    159         OGRE is licensed under the LGPL. For more info, see ogre license info.
     156        OGRE is licensed under the LGPL. For more info, see OGRE license.
    160157    */
    161158    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r1910 r2087  
    3030#include "GSServer.h"
    3131
    32 #include "core/ConsoleCommand.h"
    33 #include "core/input/InputManager.h"
    3432#include "core/CommandLine.h"
     33#include "core/Core.h"
    3534#include "network/Server.h"
    36 #include "Settings.h"
    3735
    3836namespace orxonox
    3937{
    40     SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("0-65535");
     38    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
    4139
    4240    GSServer::GSServer()
    43         : GSLevel("server")
     41        : GameState<GSGraphics>("server")
    4442        , server_(0)
    4543    {
     
    5250    void GSServer::enter()
    5351    {
    54         Settings::_getInstance().bHasServer_ = true;
     52        Core::setHasServer(true);
    5553
    56         GSLevel::enter();
    57 
    58         int serverPort = CommandLine::getArgument<int>("port")->getValue();
    59         this->server_ = new network::Server(serverPort);
     54        this->server_ = new network::Server(CommandLine::getValue("port"));
    6055        COUT(0) << "Loading scene in server mode" << std::endl;
    6156
    62         this->loadLevel();
     57        GSLevel::enter(this->getParent()->getViewport());
    6358
    6459        server_->open();
    65 
    66         // add console commands
    67         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    68         functor->setObject(this);
    69         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    70 
    71         // level is loaded: we can start capturing the input
    72         InputManager::getInstance().requestEnterState("game");
    7360    }
    7461
    7562    void GSServer::leave()
    7663    {
    77         InputManager::getInstance().requestLeaveState("game");
    78 
    79         // TODO: Remove and destroy console command
    80 
    81         this->unloadLevel();
     64        GSLevel::leave();
    8265
    8366        this->server_->close();
    8467        delete this->server_;
    8568
    86         GSLevel::leave();
    87        
    88         Settings::_getInstance().bHasServer_ = false;
     69        Core::setHasServer(false);
    8970    }
    9071
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSServer : public GSLevel
     39    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    4142        GSServer();
    4243        ~GSServer();
    43 
    4444
    4545    private:
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r1755 r2087  
    3030#include "GSStandalone.h"
    3131
    32 #include "core/input/InputManager.h"
    33 #include "core/ConsoleCommand.h"
     32#include "core/Core.h"
    3433
    3534namespace orxonox
    3635{
    3736    GSStandalone::GSStandalone()
    38         : GSLevel("standalone")
     37        : GameState<GSGraphics>("standalone")
    3938    {
    4039    }
     
    4645    void GSStandalone::enter()
    4746    {
    48         GSLevel::enter();
     47        Core::setIsStandalone(true);
    4948
    50         this->loadLevel();
    51 
    52         // add console commands
    53         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    54         functor->setObject(this);
    55         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    56 
    57         // level is loaded: we can start capturing the input
    58         InputManager::getInstance().requestEnterState("game");
     49        GSLevel::enter(this->getParent()->getViewport());
    5950    }
    6051
    6152    void GSStandalone::leave()
    6253    {
    63         InputManager::getInstance().requestLeaveState("game");
     54        GSLevel::leave();
    6455
    65         // TODO: Remove and destroy console command
    66 
    67         this->unloadLevel();
    68 
    69         GSLevel::leave();
     56        Core::setIsStandalone(false);
    7057    }
    7158
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "GSLevel.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSStandalone : public GSLevel
     38    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
    3839    {
    3940    public:
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r1887 r2087  
    4747#include "core/Core.h"
    4848#include "tolua/tolua_bind.h"
    49 #include "GraphicsEngine.h"
    5049#include "OgreCEGUIRenderer.h"
    5150
  • code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp

    r1755 r2087  
    2525*************************************************************************/
    2626
     27#include "OrxonoxStableHeaders.h"
    2728#include <CEGUIImagesetManager.h>
    2829#include <CEGUIImageset.h>
  • code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp

    r1755 r2087  
    2424    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2525*************************************************************************/
     26#include "OrxonoxStableHeaders.h"
    2627#include "OgreCEGUIResourceProvider.h"
    2728
  • code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp

    r1755 r2087  
    2525*************************************************************************/
    2626
     27#include "OrxonoxStableHeaders.h"
    2728#include <CEGUISystem.h>
    2829#include <CEGUIExceptions.h>
  • code/trunk/src/orxonox/objects/Radar.cc

    r1818 r2087  
    3636#include <cfloat>
    3737#include <cassert>
    38 #include "objects/WorldEntity.h"
    39 #include "objects/SpaceShip.h"
    4038#include "core/CoreIncludes.h"
    4139#include "core/ConsoleCommand.h"
     
    114112            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    115113            {
     114/*
    116115                if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
    117116                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
     117*/
    118118            }
    119119        }
     
    130130        else
    131131        {
    132             Vector3 localPosition = SpaceShip::getLocalShip()->getPosition();
     132            Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition();
    133133            Vector3 targetPosition = localPosition;
    134134            if (*(this->itFocus_))
     
    143143            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    144144            {
     145/*
    145146                if (*it == SpaceShip::getLocalShip())
    146147                    continue;
    147 
     148*/
    148149                float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
    149150                if (targetDistance > currentDistance && targetDistance < nextDistance)
  • code/trunk/src/orxonox/objects/RadarViewable.cc

    r1818 r2087  
    3131#include "util/Debug.h"
    3232#include "core/CoreIncludes.h"
    33 #include "objects/WorldEntity.h"
     33//#include "objects/WorldEntity.h"
    3434#include "Radar.h"
    3535
     
    6363    {
    6464        validate();
    65         return this->radarObject_->getWorldPosition();
     65        return Vector3::ZERO;//this->radarObject_->getWorldPosition();
    6666    }
    6767
     
    6969    {
    7070        validate();
    71         return this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
     71        return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
    7272    }
    7373}
  • code/trunk/src/orxonox/objects/RadarViewable.h

    r1818 r2087  
    4444    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
    4545    {
     46    class WorldEntity;
     47
    4648    public:
    4749        enum Shape
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r1755 r2087  
    4444#include "core/XMLPort.h"
    4545#include "core/ConsoleCommand.h"
    46 #include "GraphicsEngine.h"
    4746
    4847namespace orxonox
     
    5554    SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User);
    5655
    57     OrxonoxOverlay::OrxonoxOverlay()
    58         : overlay_(0)
    59         , background_(0)
     56    OrxonoxOverlay::OrxonoxOverlay(BaseObject* creator)
     57        : BaseObject(creator)
    6058    {
    6159        RegisterObject(OrxonoxOverlay);
     60
     61        // add this overlay to the static map of OrxonoxOverlays
     62        if (overlays_s.find(this->getName()) != overlays_s.end())
     63        {
     64            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
     65        }
     66        overlays_s[this->getName()] = this;
     67
     68        // create the Ogre::Overlay
     69        overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
     70            + convertToString(hudOverlayCounter_s++));
     71
     72        // create background panel (can be used to show any picture)
     73        this->background_ = static_cast<Ogre::PanelOverlayElement*>(
     74            Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
     75            "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
     76        this->overlay_->add2D(this->background_);
     77
     78        // We'll have to set the aspect ratio to a default value first.
     79        // GSGraphics gets informed about our construction here and can update us in the next tick.
     80        this->windowAspectRatio_ = 1.0;
     81        this->sizeCorrectionChanged();
     82
     83        this->changedVisibility();
     84
     85        setSize(Vector2(1.0f, 1.0f));
     86        setPickPoint(Vector2(0.0f, 0.0f));
     87        setPosition(Vector2(0.0f, 0.0f));
     88        setRotation(Degree(0.0));
     89        setAspectCorrection(true);
     90        setBackgroundMaterial("");
    6291    }
    6392
     
    7099    OrxonoxOverlay::~OrxonoxOverlay()
    71100    {
    72         // erase ourself from the map with all overlays
    73         std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName());
    74         if (it != overlays_s.end())
    75             overlays_s.erase(it);
    76 
    77         if (this->background_)
     101        if (this->isInitialized())
     102        {
     103            // erase ourself from the map with all overlays
     104            std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName());
     105            if (it != overlays_s.end())
     106                overlays_s.erase(it);
     107
    78108            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_);
    79         if (this->overlay_)
    80109            Ogre::OverlayManager::getSingleton().destroy(this->overlay_);
     110        }
    81111    }
    82112
     
    94124        SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode);
    95125
    96         if (mode == XMLPort::LoadObject)
    97         {
    98             // add this overlay to the static map of OrxonoxOverlays
    99             if (overlays_s.find(this->getName()) != overlays_s.end())
    100             {
    101                 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl;
    102             }
    103             overlays_s[this->getName()] = this;
    104 
    105             // create the Ogre::Overlay
    106             overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
    107                 + convertToString(hudOverlayCounter_s++));
    108 
    109             // create background panel (can be used to show any picture)
    110             this->background_ = static_cast<Ogre::PanelOverlayElement*>(
    111                 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
    112                 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
    113             this->overlay_->add2D(this->background_);
    114 
    115             // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
    116             // called automatically by the GraphicsEngine.
    117             this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
    118                 GraphicsEngine::getInstance().getWindowHeight());
    119 
    120             this->changedVisibility();
    121         }
    122 
    123         XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode)
    124             .defaultValues(Vector2(1.0f, 1.0f));
    125         XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode)
    126             .defaultValues(Vector2(0.0f, 0.0f));
    127         XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode)
    128             .defaultValues(Vector2(0.0f, 0.0f));
    129         XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode)
    130             .defaultValues(0.0f);
    131         XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode)
    132             .defaultValues(true);
    133         XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode)
    134             .defaultValues("");
     126        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode);
     127        XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode);
     128        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode);
     129        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode);
     130        XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
     131        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
     132    }
     133
     134    void OrxonoxOverlay::changedName()
     135    {
     136        OrxonoxOverlay::overlays_s.erase(this->getOldName());
     137
     138        if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
     139            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
     140
     141        OrxonoxOverlay::overlays_s[this->getName()] = this;
    135142    }
    136143
     
    148155            return this->background_->getMaterialName();
    149156        else
    150             return blankString;
     157            return BLANKSTRING;
    151158    }
    152159
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r1747 r2087  
    8484
    8585    public:
    86         OrxonoxOverlay();
     86        OrxonoxOverlay(BaseObject* creator);
    8787        virtual ~OrxonoxOverlay();
    8888
    8989        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     90
     91        virtual void changedName();
    9092
    9193        //! Shows the overlay with an detour to BaseObject::visibility_
  • code/trunk/src/orxonox/overlays/OverlayGroup.cc

    r1854 r2087  
    5050    SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User);
    5151
    52     OverlayGroup::OverlayGroup()
     52    OverlayGroup::OverlayGroup(BaseObject* creator)
     53        : BaseObject(creator)
    5354    {
    5455        RegisterObject(OverlayGroup);
     56
     57        setScale(Vector2(1.0, 1.0));
     58        setScroll(Vector2(0.0, 0.0));
     59    }
     60
     61    OverlayGroup::~OverlayGroup()
     62    {
     63        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     64            delete it->second;
    5565    }
    5666
     
    6575        SUPER(OverlayGroup, XMLPort, xmlElement, mode);
    6676
    67         XMLPortParam(OverlayGroup, "scale",  setScale,  getScale,  xmlElement, mode).defaultValues(Vector2(1.0, 1.0));
    68         XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode).defaultValues(Vector2(0.0, 0.0));
     77        XMLPortParam(OverlayGroup, "scale",  setScale,  getScale,  xmlElement, mode);
     78        XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode);
    6979        // loads all the child elements
    7080        XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode);
     
    100110        }
    101111        else
     112        {
    102113            hudElements_[element->getName()] = element;
     114            element->setVisible(this->isVisible());
     115        }
    103116    }
    104117
  • code/trunk/src/orxonox/overlays/OverlayGroup.h

    r1747 r2087  
    5454    {
    5555    public:
    56         OverlayGroup();
     56        OverlayGroup(BaseObject* creator);
    5757        //! Empty destructor.
    58         ~OverlayGroup() { }
     58        ~OverlayGroup();
    5959
    6060        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     
    6363        static void scaleGroup(const std::string& name, float scale);
    6464        static void scrollGroup(const std::string& name, const Vector2& scroll);
     65
     66        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
     67            { return this->hudElements_; }
    6568
    6669        void changedVisibility();
  • code/trunk/src/orxonox/overlays/OverlayText.cc

    r1784 r2087  
    3131
    3232#include <OgreOverlayManager.h>
    33 #include <OgreTextAreaOverlayElement.h>
    3433#include <OgrePanelOverlayElement.h>
    3534
     
    4241    CreateFactory(OverlayText);
    4342
    44     OverlayText::OverlayText()
    45         : text_(0)
     43    OverlayText::OverlayText(BaseObject* creator)
     44        : OrxonoxOverlay(creator)
    4645    {
    4746        RegisterObject(OverlayText);
     47
     48        this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
     49            .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberString()));
     50        this->text_->setCharHeight(1.0);
     51
     52        setFont("Monofur");
     53        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        setCaption("");
     55        setTextSize(1.0f);
     56        setAlignmentString("left");
     57
     58        this->background_->addChild(this->text_);
    4859    }
    4960
    5061    OverlayText::~OverlayText()
    5162    {
    52         if (this->text_)
     63        if (this->isInitialized())
    5364            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_);
    5465    }
     
    5869        SUPER(OverlayText, XMLPort, xmlElement, mode);
    5970
    60         if (mode == XMLPort::LoadObject)
    61         {
    62             this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
    63                 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr()));
    64             this->text_->setCharHeight(1.0);
    65 
    66             this->background_->addChild(this->text_);
    67         }
    68 
    69         XMLPortParam(OverlayText, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
    70         XMLPortParam(OverlayText, "caption",  setCaption,  getCaption,  xmlElement, mode).defaultValues("");
    71         XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f);
     71        XMLPortParam(OverlayText, "font",     setFont,            getFont,            xmlElement, mode);
     72        XMLPortParam(OverlayText, "colour",   setColour,          getColour,          xmlElement, mode);
     73        XMLPortParam(OverlayText, "caption",  setCaption,         getCaption,         xmlElement, mode);
     74        XMLPortParam(OverlayText, "textSize", setTextSize,        getTextSize,        xmlElement, mode);
     75        XMLPortParam(OverlayText, "align",    setAlignmentString, getAlignmentString, xmlElement, mode);
    7276    }
    7377
    7478    void OverlayText::setFont(const std::string& font)
    7579    {
    76         if (this->text_ && font != "")
     80        if (font != "")
    7781            this->text_->setFontName(font);
    7882    }
    7983
    80     const std::string& OverlayText::getFont() const
     84    void OverlayText::setAlignmentString(const std::string& alignment)
    8185    {
    82         if (this->text_)
    83             return this->text_->getFontName();
    84         else
    85             return blankString;
     86        if (alignment == "right")
     87            this->setAlignment(Ogre::TextAreaOverlayElement::Right);
     88        else if (alignment == "center")
     89            this->setAlignment(Ogre::TextAreaOverlayElement::Center);
     90        else // "left" and default
     91            this->setAlignment(Ogre::TextAreaOverlayElement::Left);
     92    }
     93
     94    std::string OverlayText::getAlignmentString() const
     95    {
     96        Ogre::TextAreaOverlayElement::Alignment alignment = this->text_->getAlignment();
     97
     98        switch (alignment)
     99        {
     100            case Ogre::TextAreaOverlayElement::Right:
     101                return "right";
     102            case Ogre::TextAreaOverlayElement::Center:
     103                return "center";
     104            case Ogre::TextAreaOverlayElement::Left:
     105                return "left";
     106            default:
     107                assert(false); return "";
     108        }
    86109    }
    87110
    88111    void OverlayText::sizeChanged()
    89112    {
    90         if (!this->overlay_)
    91             return;
    92 
    93113        if (this->rotState_ == Horizontal)
    94114            this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y);
  • code/trunk/src/orxonox/overlays/OverlayText.h

    r1625 r2087  
    3434#include <string>
    3535#include <OgrePrerequisites.h>
     36#include <OgreTextAreaOverlayElement.h>
    3637#include "OrxonoxOverlay.h"
    3738
     
    4142    {
    4243    public:
    43         OverlayText();
     44        OverlayText(BaseObject* creator);
    4445        virtual ~OverlayText();
    4546
    4647        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4748
     49        void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
     50        std::string getCaption() const              { return this->text_->getCaption(); }
     51
     52        void setFont(const std::string& font);
     53        const std::string& getFont() const { return this->text_->getFontName(); }
     54
     55        void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
     56        const ColourValue& getColour() const      { return this->text_->getColour(); }
     57
     58        void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
     59        Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
     60
    4861    protected:
    4962        virtual void sizeChanged();
    5063
    51         void setCaption(const std::string& caption) { this->caption_ = caption; }
    52         const std::string& getCaption() const       { return this->caption_; }
    53 
    54         void setFont(const std::string& font);
    55         const std::string& getFont() const;
     64        void setAlignmentString(const std::string& alignment);
     65        std::string getAlignmentString() const;
    5666
    5767        void setTextSize(float size) { this->setSize(Vector2(size, size)); }
     
    5969
    6070        Ogre::TextAreaOverlayElement* text_;
    61 
    62     private:
    63         std::string caption_;
    6471    };
    6572}
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r1879 r2087  
    4848#include "core/input/SimpleInputState.h"
    4949#include "core/input/InputBuffer.h"
    50 #include "GraphicsEngine.h"
    5150
    5251namespace orxonox
     
    170169        @brief Initializes the InGameConsole.
    171170    */
    172     void InGameConsole::initialise()
     171    void InGameConsole::initialise(int windowWidth, int windowHeight)
    173172    {
    174173        // create the corresponding input state
     
    246245        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    247246
    248         this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
     247        this->windowResized(windowWidth, windowHeight);
    249248
    250249        // move overlay "above" the top edge of the screen
     
    613612        @return The converted string
    614613    */
    615     /*static*/ Ogre::UTFString InGameConsole::convert2UTF(std::string s)
     614    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text)
    616615    {
    617616        Ogre::UTFString utf;
    618617        Ogre::UTFString::code_point cp;
    619         for (unsigned int i = 0; i < s.size(); ++i)
    620         {
    621           cp = s[i];
     618        for (unsigned int i = 0; i < text.size(); ++i)
     619        {
     620          cp = text[i];
    622621          cp &= 0xFF;
    623622          utf.append(1, cp);
  • code/trunk/src/orxonox/overlays/console/InGameConsole.h

    r1879 r2087  
    4949        ~InGameConsole();
    5050
    51         void initialise();
     51        void initialise(int windowWidth, int windowHeight);
    5252        void destroy();
    5353        void setConfigValues();
     
    6060        static void openConsole();
    6161        static void closeConsole();
     62
     63        static Ogre::UTFString convert2UTF(const std::string& text);
    6264
    6365    private: // functions
     
    8385        // config value related
    8486        void bHidesAllInputChanged();
    85 
    86         static Ogre::UTFString convert2UTF(std::string s);
    8787
    8888    private: // variables
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

    r1755 r2087  
    3838    CreateFactory(DebugFPSText);
    3939
    40     DebugFPSText::DebugFPSText()
     40    DebugFPSText::DebugFPSText(BaseObject* creator) : OverlayText(creator)
    4141    {
    4242        RegisterObject(DebugFPSText);
     
    5050    {
    5151        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    52         this->text_->setCaption(this->getCaption() + convertToString(fps));
     52        this->setCaption(convertToString(fps));
    5353    }
    5454}
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.h

    r1747 r2087  
    4040    {
    4141    public:
    42         DebugFPSText();
     42        DebugFPSText(BaseObject* creator);
    4343        ~DebugFPSText();
    4444
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc

    r1755 r2087  
    3838    CreateFactory(DebugRTRText);
    3939
    40     DebugRTRText::DebugRTRText()
     40    DebugRTRText::DebugRTRText(BaseObject* creator) : OverlayText(creator)
    4141    {
    4242        RegisterObject(DebugRTRText);
     
    5050    {
    5151        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    52         this->text_->setCaption(this->getCaption() + convertToString(rtr));
     52        this->setCaption(convertToString(rtr));
    5353    }
    5454}
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.h

    r1747 r2087  
    4040    {
    4141    public:
    42         DebugRTRText();
     42        DebugRTRText(BaseObject* creator);
    4343        ~DebugRTRText();
    4444
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r1854 r2087  
    3838
    3939#include "util/Convert.h"
     40#include "util/String.h"
    4041#include "core/CoreIncludes.h"
    4142#include "core/XMLPort.h"
     
    4546    CreateFactory(BarColour);
    4647
    47     BarColour::BarColour()
    48         : position_(0.0)
     48    BarColour::BarColour(BaseObject* creator)
     49        : BaseObject(creator)
    4950    {
    5051        RegisterObject(BarColour);
     52
     53        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        setPosition(0.0);
    5155    }
    5256
     
    5559        SUPER(BarColour, XMLPort, xmlElement, mode);
    5660
    57         XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode)
    58             .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    59         XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f);
     61        XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode);
     62        XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode);
    6063    }
    6164
     
    6366    unsigned int HUDBar::materialcount_s = 0;
    6467
    65     HUDBar::HUDBar()
    66         : bar_(0)
    67         , textureUnitState_(0)
     68    HUDBar::HUDBar(BaseObject* creator)
     69        : OrxonoxOverlay(creator)
    6870    {
    6971        RegisterObject(HUDBar);
     72
     73        // create new material
     74        std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
     75        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
     76        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
     77        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
     78        this->textureUnitState_->setTextureName("bar2.tga");
     79        // use the default colour
     80        this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
     81
     82        this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     83            .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString()));
     84        this->bar_->setMaterialName(materialname);
     85
     86        setValue(0.4567654f);
     87        setRightToLeft(false);
     88        setAutoColour(true);
     89
     90        this->background_->addChild(bar_);
    7091    }
    7192
    7293    HUDBar::~HUDBar()
    7394    {
    74         if (this->bar_)
     95        if (this->isInitialized())
    7596            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
    7697    }
     
    80101        SUPER(HUDBar, XMLPort, xmlElement, mode);
    81102
    82         if (mode == XMLPort::LoadObject)
    83         {
    84             // create new material
    85             std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
    86             Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
    87             material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    88             this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
    89             this->textureUnitState_->setTextureName("bar2.tga");
    90             // use the default colour
    91             this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
    92 
    93             this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    94                 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr()));
    95             this->bar_->setMaterialName(materialname);
    96             this->background_->addChild(bar_);
    97         }
    98 
    99         XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode).defaultValues(0.4567654f);
    100         XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false);
    101         XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode).defaultValues(true);
     103        XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
     104        XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
     105        XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
    102106        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    103107    }
  • code/trunk/src/orxonox/overlays/hud/HUDBar.h

    r1747 r2087  
    4444    {
    4545    public:
    46         BarColour();
     46        BarColour(BaseObject* creator);
    4747        ~BarColour() { }
    4848
     
    6464    {
    6565    public:
    66         HUDBar();
     66        HUDBar(BaseObject* creator);
    6767        virtual ~HUDBar();
    6868
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc

    r1819 r2087  
    4141#include "core/XMLPort.h"
    4242#include "objects/Radar.h"
    43 #include "objects/SpaceShip.h"
    44 #include "objects/Projectile.h"
    45 #include "objects/CameraHandler.h"
    4643
    4744namespace orxonox
     
    4946    CreateFactory(HUDNavigation);
    5047
    51     HUDNavigation::HUDNavigation()
    52         : navMarker_(0)
    53         , aimMarker_(0)
    54         , navText_(0)
     48    HUDNavigation::HUDNavigation(BaseObject* creator)
     49        : OrxonoxOverlay(creator)
    5550    {
    5651        RegisterObject(HUDNavigation);
     52
     53        // create nav text
     54        navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
     55            .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
     56
     57        // create nav marker
     58        navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     59            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
     60        navMarker_->setMaterialName("Orxonox/NavArrows");
     61
     62        // create aim marker
     63        aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     64            .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
     65        aimMarker_->setMaterialName("Orxonox/NavCrosshair");
     66        this->wasOutOfView_ = true; // Ensure the material is changed right the first time..
     67
     68        setFont("Monofur");
     69        setTextSize(0.05f);
     70        setNavMarkerSize(0.05f);
     71        setAimMarkerSize(0.04f);
     72
     73        background_->addChild(navMarker_);
     74        background_->addChild(aimMarker_);
     75        background_->addChild(navText_);
     76
     77        // hide at first
     78        this->setVisible(false);
    5779    }
    5880
    5981    HUDNavigation::~HUDNavigation()
    6082    {
    61         if (this->navMarker_)
     83        if (this->isInitialized())
     84        {
    6285            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
    63         if (this->navText_)
    6486            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
    65         if (this->aimMarker_)
    6687            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
     88        }
    6789    }
    6890
     
    7193        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
    7294
    73         if (mode == XMLPort::LoadObject)
    74         {
    75             // create nav text
    76             navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
    77                 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr()));
    78 
    79             // create nav marker
    80             navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    81                 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr()));
    82             navMarker_->setMaterialName("Orxonox/NavArrows");
    83             wasOutOfView_ = true; // just to ensure the material is changed right the first time..
    84 
    85             // create aim marker
    86             aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    87                 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr()));
    88             aimMarker_->setMaterialName("Orxonox/NavCrosshair");
    89 
    90             background_->addChild(navMarker_);
    91             background_->addChild(aimMarker_);
    92             background_->addChild(navText_);
    93 
    94             // hide at first
    95             this->setVisible(false);
    96         }
    97 
    98         XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
    99         XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f);
    100         XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode)
    101             .defaultValues(0.05f);
    102         XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode)
    103             .defaultValues(0.04f);
     95        XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode);
     96        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
     97        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
     98        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
    10499    }
    105100
     
    115110            return this->navText_->getFontName();
    116111        else
    117             return blankString;
     112            return BLANKSTRING;
    118113    }
    119114
     
    149144        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
    150145
     146/*
    151147        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
    152148        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
     149*/
    153150        // transform to screen coordinates
    154         Vector3 pos = transformationMatrix * Radar::getInstance().getFocus()->getWorldPosition();
     151        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
    155152
    156153        bool outOfView;
     
    224221        {
    225222            // object is in view
    226 
     223/*
    227224            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
    228225                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
    229 
     226*/
    230227            if (wasOutOfView_)
    231228            {
     
    240237
    241238            aimMarker_->show();
     239/*
    242240            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
    243241            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
    244 
     242*/
    245243            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
    246244            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
     
    250248    float HUDNavigation::getDist2Focus() const
    251249    {
     250/*
    252251        if (Radar::getInstance().getFocus())
    253252            return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    254253        else
     254*/
    255255            return 0;
    256256    }
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.h

    r1747 r2087  
    4141    {
    4242    public:
    43         HUDNavigation();
     43        HUDNavigation(BaseObject* creator);
    4444        ~HUDNavigation();
    4545
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.cc

    r1819 r2087  
    3535
    3636#include "util/Math.h"
     37#include "util/String.h"
    3738#include "core/ConsoleCommand.h"
    3839#include "core/CoreIncludes.h"
    3940#include "core/XMLPort.h"
    40 #include "objects/SpaceShip.h"
    41 #include "objects/WorldEntity.h"
    4241#include "objects/Radar.h"
    4342#include "tools/TextureGenerator.h"
     
    4746    CreateFactory(HUDRadar);
    4847
    49     HUDRadar::HUDRadar()
    50         : marker_(0)
     48    HUDRadar::HUDRadar(BaseObject* creator)
     49        : OrxonoxOverlay(creator)
    5150    {
    5251        RegisterObject(HUDRadar);
     52
     53        marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     54            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
     55        marker_->setMaterialName("Orxonox/RadarMarker");
     56        overlay_->add2D(marker_);
     57        marker_->hide();
     58
     59        setRadarSensitivity(1.0f);
     60        setHalfDotSizeDistance(3000.0f);
     61        setMaximumDotSize(0.1f);
     62
     63        shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
     64        shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     65        shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
    5366    }
    5467
    5568    HUDRadar::~HUDRadar()
    5669    {
    57         if (this->marker_)
     70        if (this->isInitialized())
     71        {
    5872            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
    59         for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
    60             it != this->radarDots_.end(); ++it)
    61         {
    62             Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
     73            for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
     74                it != this->radarDots_.end(); ++it)
     75            {
     76                Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
     77            }
    6378        }
    6479    }
     
    6883        SUPER(HUDRadar, XMLPort, xmlElement, mode);
    6984
    70         if (mode == XMLPort::LoadObject)
    71         {
    72             marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    73                 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberStr()));
    74             marker_->setMaterialName("Orxonox/RadarMarker");
    75             overlay_->add2D(marker_);
    76             marker_->hide();
    77         }
    78 
    79         XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode)
    80             .defaultValues(1.0f);
    81         XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance,
    82             xmlElement, mode).defaultValues(3000.0f);
    83         XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode)
    84             .defaultValues(0.1f);
    85 
    86         shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
    87         shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
    88         shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     85        XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode);
     86        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode);
     87        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode);
    8988    }
    9089
    9190    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9291    {
     92/*
    9393        const WorldEntity* wePointer = object->getWorldEntity();
    9494
     
    100100            return;
    101101        }
    102 
     102*/
    103103        // try to find a panel already created
    104104        Ogre::PanelOverlayElement* panel;
     
    108108            // we have to create a new entry
    109109            panel = static_cast<Ogre::PanelOverlayElement*>(
    110                 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));
     110                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString()));
    111111            radarDots_.push_back(panel);
    112112            // get right material
     
    126126        }
    127127        panel->show();
    128 
     128/*
    129129        // set size to fit distance...
    130130        float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     
    144144            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    145145        }
     146*/
    146147    }
    147148
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.h

    r1819 r2087  
    4545    {
    4646    public:
    47         HUDRadar();
     47        HUDRadar(BaseObject* creator);
    4848        ~HUDRadar();
    4949
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r1755 r2087  
    3131#include "HUDSpeedBar.h"
    3232#include "core/CoreIncludes.h"
    33 #include "objects/SpaceShip.h"
    3433
    3534namespace orxonox
     
    3736    CreateFactory(HUDSpeedBar);
    3837
    39     HUDSpeedBar::HUDSpeedBar()
     38    HUDSpeedBar::HUDSpeedBar(BaseObject* creator)
     39        : HUDBar(creator)
    4040    {
    4141        RegisterObject(HUDSpeedBar);
     
    4949    void HUDSpeedBar::tick(float dt)
    5050    {
     51/*
    5152        SpaceShip* ship = SpaceShip::getLocalShip();
    5253        if (ship)
     
    5758                this->setValue(value);
    5859        }
     60*/
    5961    }
    6062}
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h

    r1747 r2087  
    4141    {
    4242    public:
    43         HUDSpeedBar();
     43        HUDSpeedBar(BaseObject* creator);
    4444        ~HUDSpeedBar();
    4545
  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r1755 r2087  
    3131
    3232#include <sstream>
     33#include <cassert>
    3334
    3435#include <OgreSceneManager.h>
     36#include <OgreBillboard.h>
    3537
    36 #include "GraphicsEngine.h"
    37 #include "util/Math.h"
     38#include "util/Convert.h"
     39#include "util/String.h"
    3840
    3941namespace orxonox
     
    4648    }
    4749
    48     void BillboardSet::setBillboardSet(const std::string& file, int count)
     50    BillboardSet::~BillboardSet()
    4951    {
    50         std::ostringstream name;
    51         name << (BillboardSet::billboardSetCounter_s++);
    52         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    53         this->billboardSet_->createBillboard(Vector3::ZERO);
    54         this->billboardSet_->setMaterialName(file);
     52        this->destroyBillboardSet();
    5553    }
    5654
    57     void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, int count)
     55    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count)
    5856    {
    59         std::ostringstream name;
    60         name << (BillboardSet::billboardSetCounter_s++);
    61         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    62         this->billboardSet_->createBillboard(Vector3::ZERO, colour);
    63         this->billboardSet_->setMaterialName(file);
     57        this->setBillboardSet(scenemanager, file, Vector3::ZERO, count);
    6458    }
    6559
    66     void BillboardSet::setBillboardSet(const std::string& file, const Vector3& position, int count)
     60    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count)
    6761    {
    68         std::ostringstream name;
    69         name << (BillboardSet::billboardSetCounter_s++);
    70         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    71         this->billboardSet_->createBillboard(position);
    72         this->billboardSet_->setMaterialName(file);
     62        this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count);
    7363    }
    7464
    75     void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count)
     65    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count)
    7666    {
    77         std::ostringstream name;
    78         name << (BillboardSet::billboardSetCounter_s++);
    79         this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
    80         this->billboardSet_->createBillboard(position, colour);
    81         this->billboardSet_->setMaterialName(file);
     67        assert(scenemanager);
     68        this->destroyBillboardSet();
     69
     70        try
     71        {
     72            this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     73            this->billboardSet_->createBillboard(position);
     74            this->billboardSet_->setMaterialName(file);
     75        }
     76        catch (...)
     77        {
     78            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
     79        }
     80
     81        this->scenemanager_ = scenemanager;
    8282    }
    8383
    84     BillboardSet::~BillboardSet()
     84    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count)
     85    {
     86        assert(scenemanager);
     87        this->destroyBillboardSet();
     88
     89        try
     90        {
     91            this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     92            this->billboardSet_->createBillboard(position, colour);
     93            this->billboardSet_->setMaterialName(file);
     94        }
     95        catch (...)
     96        {
     97            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
     98        }
     99
     100        this->scenemanager_ = scenemanager;
     101    }
     102
     103    void BillboardSet::destroyBillboardSet()
     104    {
     105        if (this->billboardSet_ && this->scenemanager_)
     106            this->scenemanager_->destroyBillboardSet(this->billboardSet_);
     107    }
     108
     109    const std::string& BillboardSet::getName() const
    85110    {
    86111        if (this->billboardSet_)
    87             GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
     112            return this->billboardSet_->getName();
     113        else
     114            return BLANKSTRING;
     115    }
     116
     117    void BillboardSet::setVisible(bool visible)
     118    {
     119        if (this->billboardSet_)
     120            this->billboardSet_->setVisible(visible);
     121    }
     122
     123    bool BillboardSet::getVisible() const
     124    {
     125        if (this->billboardSet_)
     126            return this->billboardSet_->getVisible();
     127        else
     128            return false;
     129    }
     130
     131    void BillboardSet::setColour(const ColourValue& colour)
     132    {
     133        if (this->billboardSet_)
     134        {
     135            for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i)
     136                this->billboardSet_->getBillboard(i)->setColour(colour);
     137        }
     138    }
     139
     140    const ColourValue& BillboardSet::getColour() const
     141    {
     142        if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0)
     143        {
     144            return this->billboardSet_->getBillboard(0)->getColour();
     145        }
     146        else
     147            return ColourValue::White;
     148    }
     149
     150    void BillboardSet::setMaterial(const std::string& material)
     151    {
     152        if (this->billboardSet_)
     153            this->billboardSet_->setMaterialName(material);
     154    }
     155
     156    const std::string& BillboardSet::getMaterial() const
     157    {
     158        if (this->billboardSet_)
     159            return this->billboardSet_->getMaterialName();
     160        else
     161            return BLANKSTRING;
    88162    }
    89163}
  • code/trunk/src/orxonox/tools/BillboardSet.h

    r1602 r2087  
    4444            BillboardSet();
    4545            ~BillboardSet();
    46             void setBillboardSet(const std::string& file, int count = 1);
    47             void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1);
    48             void setBillboardSet(const std::string& file, const Vector3& position, int count = 1);
    49             void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
     46
     47            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1);
     48            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1);
     49            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count = 1);
     50            void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
    5051
    5152            inline Ogre::BillboardSet* getBillboardSet()
    5253                { return this->billboardSet_; }
    5354
    54             inline const std::string& getName() const
    55                 { return this->billboardSet_->getName(); }
     55            const std::string& getName() const;
    5656
    57             inline void setVisible(bool visible)
    58                 { this->billboardSet_->setVisible(visible); }
    59             inline bool getVisible() const
    60                 { return this->billboardSet_->getVisible(); }
     57            void setVisible(bool visible);
     58            bool getVisible() const;
     59
     60            void setColour(const ColourValue& colour);
     61            const ColourValue& getColour() const;
     62
     63            void setMaterial(const std::string& material);
     64            const std::string& getMaterial() const;
    6165
    6266        private:
     67            void destroyBillboardSet();
     68
    6369            static unsigned int billboardSetCounter_s;
    6470            Ogre::BillboardSet* billboardSet_;
     71            Ogre::SceneManager* scenemanager_;
    6572    };
    6673}
  • code/trunk/src/orxonox/tools/Mesh.cc

    r1755 r2087  
    3232#include <sstream>
    3333#include <OgreSceneManager.h>
    34 #include "GraphicsEngine.h"
    35 #include "Settings.h"
     34#include <cassert>
     35
     36#include "core/Core.h"
     37#include "util/Convert.h"
     38#include "util/String.h"
    3639
    3740namespace orxonox
     
    3942    unsigned int Mesh::meshCounter_s = 0;
    4043
    41     Mesh::Mesh() :
    42       entity_(0)
     44    Mesh::Mesh()
    4345    {
    44     }
    45 
    46     void Mesh::setMesh(const std::string& file)
    47     {
    48         std::ostringstream name;
    49         name << (Mesh::meshCounter_s++);
    50         if (Settings::showsGraphics())
    51             this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
     46        this->entity_ = 0;
     47        this->bCastShadows_ = true;
    5248    }
    5349
    5450    Mesh::~Mesh()
    5551    {
    56         if (this->entity_ && Settings::showsGraphics())
    57             GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
     52        if (this->entity_ && this->scenemanager_)
     53            this->scenemanager_->destroyEntity(this->entity_);
     54    }
     55
     56    void Mesh::setMeshSource(Ogre::SceneManager* scenemanager, const std::string& meshsource)
     57    {
     58        assert(scenemanager);
     59
     60        this->scenemanager_ = scenemanager;
     61
     62        if (this->entity_)
     63            this->scenemanager_->destroyEntity(this->entity_);
     64
     65        if (Core::showsGraphics())
     66        {
     67            try
     68            {
     69                this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     70                this->entity_->setCastShadows(this->bCastShadows_);
     71            }
     72            catch (...)
     73            {
     74                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
     75            }
     76        }
     77    }
     78
     79    void Mesh::setCastShadows(bool bCastShadows)
     80    {
     81        this->bCastShadows_ = bCastShadows;
     82        if (this->entity_)
     83            this->entity_->setCastShadows(this->bCastShadows_);
     84    }
     85
     86    const std::string& Mesh::getName() const
     87    {
     88        if (this->entity_)
     89            return this->entity_->getName();
     90        else
     91            return BLANKSTRING;
     92    }
     93
     94    void Mesh::setVisible(bool bVisible)
     95    {
     96        if (this->entity_)
     97            this->entity_->setVisible(bVisible);
     98    }
     99
     100    bool Mesh::isVisible() const
     101    {
     102        if (this->entity_)
     103            return this->entity_->getVisible();
     104        else
     105            return false;
    58106    }
    59107}
  • code/trunk/src/orxonox/tools/Mesh.h

    r1627 r2087  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    3333
    3434#include <string>
    35 
    3635#include <OgreEntity.h>
    3736
     
    4342            Mesh();
    4443            ~Mesh();
    45             void setMesh(const std::string& file);
     44
     45            void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file);
    4646
    4747            inline Ogre::Entity* getEntity()
    4848                { return this->entity_; }
    4949
    50             inline const std::string& getName() const
    51                 { return this->entity_->getName(); }
     50            const std::string& getName() const;
    5251
    53             inline void setVisible(bool visible)
    54                 { if (this->entity_) this->entity_->setVisible(visible); }
    55             inline bool getVisible() const
    56                 { if (this->entity_) return this->entity_->getVisible(); else return false; }
     52            void setVisible(bool bVisible);
     53            bool isVisible() const;
     54
     55            void setCastShadows(bool bCastShadows);
     56            inline bool getCastShadows() const
     57                { return this->bCastShadows_; }
    5758
    5859        private:
    5960            static unsigned int meshCounter_s;
    6061            Ogre::Entity* entity_;
     62            bool bCastShadows_;
     63            Ogre::SceneManager* scenemanager_;
    6164    };
    6265}
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r1755 r2087  
    11/*
    2 *   ORXONOX - the hottest 3D action shooter ever to exist
    3 *
    4 *
    5 *   License notice:
    6 *
    7 *   This program is free software; you can redistribute it and/or
    8 *   modify it under the terms of the GNU General Public License
    9 *   as published by the Free Software Foundation; either version 2
    10 *   of the License, or (at your option) any later version.
    11 *
    12 *   This program is distributed in the hope that it will be useful,
    13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 *   GNU General Public License for more details.
    16 *
    17 *   You should have received a copy of the GNU General Public License
    18 *   along with this program; if not, write to the Free Software
    19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    20 *
    21 *   Author:
    22 *      ...
    23 *   Co-authors:
    24 *      ...
    25 *
    26 */
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Fabian 'x3n' Landau
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    2728
    2829/**
     
    3738#include <OgreParticleEmitter.h>
    3839#include <OgreSceneManager.h>
     40#include <cassert>
    3941
    4042#include "GraphicsEngine.h"
     
    4446namespace orxonox
    4547{
    46   unsigned int ParticleInterface::counter_s = 0;
    47   ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
    48 
    49   ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel)
    50   {
    51     RegisterRootObject(ParticleInterface);
    52 
    53     this->sceneNode_ = 0;
    54     this->bEnabled_ = true;
    55     this->detaillevel_ = (unsigned int)detaillevel;
    56     this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    57     //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
    58     this->particleSystem_->setSpeedFactor(1.0f);
    59 
    60     if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
    61     {
    62       this->bVisible_ = false;
    63       this->updateVisibility();
    64     }
    65     else
    66     {
    67       this->bVisible_ = true;
    68     }
    69   }
    70 
    71   ParticleInterface::~ParticleInterface()
    72   {
    73     this->particleSystem_->removeAllEmitters();
    74     GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
    75   }
    76 
    77   void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
    78   {
    79     this->sceneNode_ = sceneNode;
    80     this->sceneNode_->attachObject(this->particleSystem_);
    81   }
    82 
    83   void ParticleInterface::detachFromSceneNode()
    84   {
    85     if (this->sceneNode_)
    86     {
    87       this->sceneNode_->detachObject(this->particleSystem_);
    88       this->sceneNode_ = 0;
    89     }
    90   }
    91 
    92   Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
    93   {
    94     if (this->particleSystem_->getNumEmitters() > 0)
    95     {
    96       Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
    97       this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter);
    98       return newemitter;
    99     }
    100     else
    101       return 0;
    102   }
    103   Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
    104   {
    105     if (emitterNr < this->particleSystem_->getNumEmitters())
    106       return this->particleSystem_->getEmitter(emitterNr);
    107     else
    108       return 0;
    109   }
    110   void ParticleInterface::removeEmitter(unsigned int emitterNr)
    111   {
    112     if (emitterNr < this->particleSystem_->getNumEmitters())
    113       this->particleSystem_->removeEmitter(emitterNr);
    114   }
    115   void ParticleInterface::removeAllEmitters()
    116   {
    117     this->particleSystem_->removeAllEmitters();
    118   }
    119   unsigned int ParticleInterface::getNumEmitters() const
    120   {
    121     return this->particleSystem_->getNumEmitters();
    122   }
    123 
    124   Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
    125   {
    126     return this->particleSystem_->addAffector(name);
    127   }
    128   Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
    129   {
    130     if (affectorNr < this->particleSystem_->getNumAffectors())
    131       return this->particleSystem_->getAffector(affectorNr);
    132     else
    133       return 0;
    134   }
    135   void ParticleInterface::removeAffector(unsigned int affectorNr)
    136   {
    137     if (affectorNr < this->particleSystem_->getNumAffectors())
    138       this->particleSystem_->removeAffector(affectorNr);
    139   }
    140   void ParticleInterface::removeAllAffectors()
    141   {
    142     this->particleSystem_->removeAllAffectors();
    143   }
    144   unsigned int ParticleInterface::getNumAffectors() const
    145   {
    146     return this->particleSystem_->getNumAffectors();
    147   }
    148 
    149   void ParticleInterface::setEnabled(bool enable)
    150   {
    151     this->bEnabled_ = enable;
    152     this->updateVisibility();
    153   }
    154 
    155   void ParticleInterface::detailLevelChanged(unsigned int newlevel)
    156   {
    157     if (newlevel >= (unsigned int)this->detaillevel_)
    158       this->bVisible_ = true;
    159     else
    160       this->bVisible_ = false;
    161 
    162     this->updateVisibility();
    163   }
    164 
    165   void ParticleInterface::updateVisibility()
    166   {
    167     for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
    168       this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_);
    169   }
    170 
    171   void ParticleInterface::setSpeedFactor(float factor)
    172   {
    173     //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
    174     this->particleSystem_->setSpeedFactor(1.0f * factor);
    175   }
    176   float ParticleInterface::getSpeedFactor() const
    177   {
    178     //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
    179     return (this->particleSystem_->getSpeedFactor() / 1.0f);
    180   }
    181 
    182   bool ParticleInterface::getKeepParticlesInLocalSpace() const
    183   {
    184     return this->particleSystem_->getKeepParticlesInLocalSpace();
    185   }
    186   void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
    187   {
    188     this->particleSystem_->setKeepParticlesInLocalSpace(keep);
    189   }
     48    unsigned int ParticleInterface::counter_s = 0;
     49    ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
     50
     51    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
     52    {
     53        RegisterRootObject(ParticleInterface);
     54
     55        assert(scenemanager);
     56
     57        this->scenemanager_ = scenemanager;
     58        this->sceneNode_ = 0;
     59
     60        this->bEnabled_ = true;
     61        this->bVisible_ = true;
     62        this->bAllowedByLOD_ = true;
     63
     64        this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     65        this->particleSystem_->setSpeedFactor(1.0f);
     66        //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     67
     68        this->setDetailLevel((unsigned int)detaillevel);
     69    }
     70
     71    ParticleInterface::~ParticleInterface()
     72    {
     73        this->particleSystem_->removeAllEmitters();
     74        this->detachFromSceneNode();
     75        this->scenemanager_->destroyParticleSystem(particleSystem_);
     76    }
     77
     78    void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
     79    {
     80        if (this->sceneNode_)
     81            this->detachFromSceneNode();
     82
     83        this->sceneNode_ = sceneNode;
     84        this->sceneNode_->attachObject(this->particleSystem_);
     85    }
     86
     87    void ParticleInterface::detachFromSceneNode()
     88    {
     89        if (this->sceneNode_)
     90        {
     91            this->sceneNode_->detachObject(this->particleSystem_);
     92            this->sceneNode_ = 0;
     93        }
     94    }
     95
     96    Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
     97    {
     98        if (this->particleSystem_->getNumEmitters() > 0)
     99        {
     100            Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
     101            this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter);
     102            return newemitter;
     103        }
     104        else
     105            return 0;
     106    }
     107    Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
     108    {
     109        if (emitterNr < this->particleSystem_->getNumEmitters())
     110            return this->particleSystem_->getEmitter(emitterNr);
     111        else
     112            return 0;
     113    }
     114    void ParticleInterface::removeEmitter(unsigned int emitterNr)
     115    {
     116        if (emitterNr < this->particleSystem_->getNumEmitters())
     117            this->particleSystem_->removeEmitter(emitterNr);
     118    }
     119    void ParticleInterface::removeAllEmitters()
     120    {
     121        this->particleSystem_->removeAllEmitters();
     122    }
     123    unsigned int ParticleInterface::getNumEmitters() const
     124    {
     125        return this->particleSystem_->getNumEmitters();
     126    }
     127
     128    Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
     129    {
     130        return this->particleSystem_->addAffector(name);
     131    }
     132    Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
     133    {
     134        if (affectorNr < this->particleSystem_->getNumAffectors())
     135            return this->particleSystem_->getAffector(affectorNr);
     136        else
     137            return 0;
     138    }
     139    void ParticleInterface::removeAffector(unsigned int affectorNr)
     140    {
     141        if (affectorNr < this->particleSystem_->getNumAffectors())
     142            this->particleSystem_->removeAffector(affectorNr);
     143    }
     144    void ParticleInterface::removeAllAffectors()
     145    {
     146        this->particleSystem_->removeAllAffectors();
     147    }
     148    unsigned int ParticleInterface::getNumAffectors() const
     149    {
     150        return this->particleSystem_->getNumAffectors();
     151    }
     152
     153    void ParticleInterface::setEnabled(bool enable)
     154    {
     155        this->bEnabled_ = enable;
     156
     157        for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
     158            this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_);
     159    }
     160
     161    void ParticleInterface::setVisible(bool visible)
     162    {
     163        this->bVisible_ = visible;
     164
     165        this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_);
     166    }
     167
     168    void ParticleInterface::setDetailLevel(unsigned int level)
     169    {
     170        this->detaillevel_ = level;
     171        this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
     172    }
     173
     174    void ParticleInterface::detailLevelChanged(unsigned int newlevel)
     175    {
     176        if (newlevel >= (unsigned int)this->detaillevel_)
     177            this->bAllowedByLOD_ = true;
     178        else
     179            this->bAllowedByLOD_ = false;
     180
     181        this->updateVisibility();
     182    }
     183
     184    void ParticleInterface::updateVisibility()
     185    {
     186        this->setEnabled(this->isEnabled());
     187        this->setVisible(this->isVisible());
     188    }
     189
     190    void ParticleInterface::setSpeedFactor(float factor)
     191    {
     192        //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
     193        this->particleSystem_->setSpeedFactor(1.0f * factor);
     194    }
     195    float ParticleInterface::getSpeedFactor() const
     196    {
     197        //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
     198        return (this->particleSystem_->getSpeedFactor() / 1.0f);
     199    }
     200
     201    bool ParticleInterface::getKeepParticlesInLocalSpace() const
     202    {
     203        return this->particleSystem_->getKeepParticlesInLocalSpace();
     204    }
     205    void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
     206    {
     207        this->particleSystem_->setKeepParticlesInLocalSpace(keep);
     208    }
    190209}
  • code/trunk/src/orxonox/tools/ParticleInterface.h

    r1563 r2087  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    4545namespace orxonox
    4646{
    47   class _OrxonoxExport ParticleInterface : public OrxonoxClass
    48   {
    49     public:
    50       ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);
    51       ~ParticleInterface();
     47    class _OrxonoxExport ParticleInterface : public OrxonoxClass
     48    {
     49        public:
     50            ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel);
     51            virtual ~ParticleInterface();
    5252
    53       inline Ogre::ParticleSystem* getParticleSystem() const
    54         { return this->particleSystem_; }
     53            inline Ogre::ParticleSystem* getParticleSystem() const
     54                { return this->particleSystem_; }
    5555
    56       void addToSceneNode(Ogre::SceneNode* sceneNode);
    57       void detachFromSceneNode();
     56            void addToSceneNode(Ogre::SceneNode* sceneNode);
     57            void detachFromSceneNode();
    5858
    59       Ogre::ParticleEmitter* createNewEmitter();
    60       Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;
    61       void removeEmitter(unsigned int emitterNr);
    62       void removeAllEmitters();
    63       unsigned int getNumEmitters() const;
     59            Ogre::ParticleEmitter* createNewEmitter();
     60            Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;
     61            void removeEmitter(unsigned int emitterNr);
     62            void removeAllEmitters();
     63            unsigned int getNumEmitters() const;
    6464
    65       Ogre::ParticleAffector* addAffector(const std::string& name);
    66       Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;
    67       void removeAffector(unsigned int affectorNr);
    68       void removeAllAffectors();
    69       unsigned int getNumAffectors() const;
     65            Ogre::ParticleAffector* addAffector(const std::string& name);
     66            Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;
     67            void removeAffector(unsigned int affectorNr);
     68            void removeAllAffectors();
     69            unsigned int getNumAffectors() const;
    7070
    71       float getSpeedFactor() const;
    72       void setSpeedFactor(float factor);
    73       bool getKeepParticlesInLocalSpace() const;
    74       void setKeepParticlesInLocalSpace(bool keep);
     71            float getSpeedFactor() const;
     72            void setSpeedFactor(float factor);
     73            bool getKeepParticlesInLocalSpace() const;
     74            void setKeepParticlesInLocalSpace(bool keep);
    7575
    76       void setEnabled(bool enable);
    77       void detailLevelChanged(unsigned int newlevel);
     76            void setEnabled(bool enable);
     77            inline bool isEnabled() const
     78                { return this->bEnabled_; }
    7879
    79       inline void storeThisAsCurrentParticleInterface()
    80         { ParticleInterface::currentParticleInterface_s = this; }
    81       inline static ParticleInterface* getCurrentParticleInterface()
    82         { return ParticleInterface::currentParticleInterface_s; }
     80            void setVisible(bool visible);
     81            inline bool isVisible() const
     82                { return this->bVisible_; }
    8383
    84     private:
    85       void updateVisibility();
     84            void detailLevelChanged(unsigned int newlevel);
     85            void setDetailLevel(unsigned int level);
    8686
    87       static ParticleInterface* currentParticleInterface_s;
    88       static unsigned int counter_s;
    89       Ogre::SceneNode* sceneNode_;
    90       Ogre::ParticleSystem* particleSystem_;
    91       bool bVisible_;
    92       bool bEnabled_;
    93       unsigned int detaillevel_;                            //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
    94   };
     87            inline void storeThisAsCurrentParticleInterface()
     88                { ParticleInterface::currentParticleInterface_s = this; }
     89            inline static ParticleInterface* getCurrentParticleInterface()
     90                { return ParticleInterface::currentParticleInterface_s; }
     91
     92        private:
     93            void updateVisibility();
     94
     95            static ParticleInterface* currentParticleInterface_s;
     96            static unsigned int       counter_s;
     97
     98            Ogre::SceneNode*          sceneNode_;
     99            Ogre::ParticleSystem*     particleSystem_;
     100            bool                      bVisible_;
     101            bool                      bEnabled_;
     102            bool                      bAllowedByLOD_;
     103            unsigned int              detaillevel_;     //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
     104            Ogre::SceneManager*       scenemanager_;
     105    };
    95106}
    96107
  • code/trunk/src/orxonox/tools/Timer.cc

    r1755 r2087  
    9292        this->bLoop_ = false;
    9393        this->bActive_ = false;
     94        this->bKillAfterCall_ = false;
    9495
    9596        this->time_ = 0;
     
    111112    void TimerBase::run() const
    112113    {
     114        bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
     115
    113116        (*this->executor_)();
     117
     118        if (temp)
     119            delete this;
    114120    }
    115121
     
    136142            {
    137143                // It's time to call the function
    138                 if (this->bLoop_)
     144                if (this->bLoop_ && !this->bKillAfterCall_)
    139145                {
    140146                    this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
  • code/trunk/src/orxonox/tools/Timer.h

    r1755 r2087  
    116116            TimerBase();
    117117
    118             Executor* executor_; //!< The executor of the function that should be called when the time expires
    119 
    120             long long interval_; //!< The time-interval in micro seconds
    121             bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
    122             bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
    123 
    124             long long time_;     //!< Internal variable, counting the time till the next function-call
     118            Executor* executor_;  //!< The executor of the function that should be called when the time expires
     119
     120            long long interval_;  //!< The time-interval in micro seconds
     121            bool bLoop_;          //!< If true, the function gets called every 'interval' seconds
     122            bool bActive_;        //!< If true, the Timer ticks and calls the function if the time's up
     123            bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function
     124
     125            long long time_;      //!< Internal variable, counting the time till the next function-call
    125126    };
    126127
     
    139140                @param exeuctor A executor of the function to call
    140141            */
    141             Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor)
    142             {
    143                 this->setTimer(interval, bLoop, object, exeuctor);
     142            Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false)
     143            {
     144                this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall);
    144145            }
    145146
     
    151152                @param exeuctor A executor of the function to call
    152153            */
    153             void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor)
     154            void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false)
    154155            {
    155156                this->deleteExecutor();
     
    162163
    163164                this->time_ = this->interval_;
     165                this->bKillAfterCall_ = bKillAfterCall;
    164166            }
    165167    };
     
    177179                @param exeuctor A executor of the function to call
    178180            */
    179             StaticTimer(float interval, bool bLoop, ExecutorStatic* executor)
    180             {
    181                 this->setTimer(interval, bLoop, executor);
     181            StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
     182            {
     183                this->setTimer(interval, bLoop, executor, bKillAfterCall);
    182184            }
    183185
     
    189191                @param executor A executor of the function to call
    190192            */
    191             void setTimer(float interval, bool bLoop, ExecutorStatic* executor)
     193            void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    192194            {
    193195                this->deleteExecutor();
     
    199201
    200202                this->time_ = this->interval_;
     203                this->bKillAfterCall_ = bKillAfterCall;
    201204            }
    202205    };
  • code/trunk/src/tinyxml/ticpp.h

    r1639 r2087  
    11841184                T* m_tiXmlPointer;              /**< Internal pointer to the TiXml Class which is being wrapped */
    11851185
     1186    public:
    11861187                /**
    11871188                @internal
     
    11951196                        return m_tiXmlPointer;
    11961197                }
     1198    protected:
    11971199
    11981200                /**
  • code/trunk/src/tolua/lua/array.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/basic.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/class.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/clean.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/code.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/compat-5.1.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/compat.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/container.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/custom.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/custom_hide.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/declaration.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/define.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/doit.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/enumerate.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/feature.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/function.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/module.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/namespace.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/operator.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/package.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/typedef.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/variable.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/lua/verbatim.lua

    • Property svn:eol-style set to native
  • code/trunk/src/tolua/tolua-5.1.pkg

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util

  • code/trunk/src/util/CMakeLists.txt

    r1844 r2087  
    88  OutputBuffer.cc
    99  OutputHandler.cc
     10  SignalHandler.cc
    1011  String.cc
    1112  SubString.cc
  • code/trunk/src/util/Convert.h

    r1889 r2087  
    2121 *
    2222 *   Author:
     23 *      Reto Grieder
    2324 *      Fabian 'x3n' Landau
    2425 *      Benjamin Grauer
     
    2829
    2930/*!
    30     @file Convert.h
     31    @file
    3132    @brief Definition and Implementation of the Convert class.
    3233*/
    3334
    34 #ifndef _Convert_H__
    35 #define _Convert_H__
     35#ifndef _Converter_H__
     36#define _Converter_H__
    3637
    3738#include "UtilPrereqs.h"
     
    3940#include <string>
    4041#include <sstream>
     42#include <istream>
     43#include <ostream>
    4144#include <typeinfo>
    4245
    43 #include "Math.h"
    4446#include "Debug.h"
    45 #include "SubString.h"
    4647#include "String.h"
    4748
    48 // disable annoying warning about forcing value to boolean
     49// GCC generates warnings when implicitely casting from float to int for instance.
     50// This is however exactly what convertValue does, so we need to suppress these warnings.
     51// They only occur when using the ImplicitConversion template.
     52#if ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC
     53#  pragma GCC system_header
     54#endif
     55
     56
     57///////////////////////////////////////////////
     58// Static detection for conversion functions //
     59///////////////////////////////////////////////
     60
     61/* The idea to use the sizeof() operator on return functions to determine function existance
     62   is described in 'Modern C++ design' by Alexandrescu (2001). */
     63
     64// disable warnings about possible loss of data
    4965#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    50 #pragma warning(push)
    51 #pragma warning(disable:4100 4800)
     66#  pragma warning(push)
     67#  pragma warning(disable:4244)
    5268#endif
    5369
    54 
    55 //////////
    56 // MAIN //
    57 //////////
    58 
    59 // Enum to declare the wanted conversion preference in case of equal type-levels
    60 enum ConversionPreference
    61 {
    62     CP_PreferToType,
    63     CP_PreferFromType,
    64 };
    65 
    66 // Helper classes to determine the preferred partial template specialization
    67 class _ToType_   {};
    68 class _FromType_ {};
    69 class _Explicit_ {};
    70 
    71 
    72 // The default convert functions
    73 template <class FromType, class ToType, class Type>
    74 struct ConverterSpecialized
    75 {
    76     enum { specialized = false };
     70template <class FromType, class ToType>
     71class ImplicitConversion
     72{
     73private:
     74    ImplicitConversion(); ImplicitConversion(const ImplicitConversion&); ~ImplicitConversion();
     75    // Gets chosen only if there is an implicit conversion from FromType to ToType.
     76    static char test(ToType);
     77    // Accepts any argument. Why do we not use a template? The reason is that with templates,
     78    // the function above is only taken iff it is an exact type match. But since we want to
     79    // check for implicit conversion, we have to use the ellipsis.
     80    static long long test(...);
     81    static FromType object; // helper object to handle private c'tor and d'tor
     82public:
     83    // test(object) only has 'long long' return type iff the compiler doesn't choose test(...)
     84    enum { exists = (sizeof(test(object)) == sizeof(char)) };
     85};
     86
     87#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     88#  pragma warning(pop)
     89#endif
     90
     91
     92////////////////////////////////////
     93//// ACTUAL CONVERSION SEQUENCE ////
     94////////////////////////////////////
     95/*
     96    There is a distinct priority when choosing the right conversion function:
     97    Overwrite:
     98    1. (Partial) template specialisation of ConverterExplicit::convert()
     99    Fallbacks:
     100    2. Any possible implicit conversion. This includes 'FooBar' --> 'int' if FooBar defines operator float().
     101    3. Global or member operators for stringstream when converting from or to std::string (or FROM const char*)
     102    4. (Partial) template specialisation of ConverterFallback::convert()
     103    5. Function that simply displays "Could not convert value" with type information obtained from typeid().
     104
     105    Notes:
     106    There has to be an exact type match when using template specialisations.
     107    Template specialisations can be defined after including this file. Any implicit cast function or iostream
     108    operator has to be declared BEFORE this file gets parsed.
     109
     110    Defining your own functions:
     111    There are obviously 4 ways to specifiy a user defined conversion. What should I use?
     112
     113    Usually, ConverterFallback fits quite well. You won't have to deal with the conversion from
     114    'MyClass' to 'MyClass' by using another explicit template specialisation to avoid ambiguities.
     115
     116    However if you want to overwrite an implicit conversion or an iostream operator, you really need to
     117    make use of ConverterExplicit.
     118*/
     119
     120namespace
     121{
     122    //! Little template that maps integers to entire types (Alexandrescu 2001)
     123    template <int I>
     124    struct Int2Type { };
     125}
     126
     127
     128///////////////////
     129// No Conversion //
     130///////////////////
     131
     132// Default template. No conversion available at all.
     133template <class FromType, class ToType>
     134struct ConverterFallback
     135{
    77136    static bool convert(ToType* output, const FromType& input)
    78137    {
    79         COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl;
     138        COUT(2) << "Could not convert value of type " << typeid(FromType).name()
     139                << " to type " << typeid(ToType).name() << std::endl;
    80140        return false;
    81141    }
    82142};
    83143
    84 
    85 // The default convert function if both types are the same
    86 template <class BothTypes>
    87 struct ConverterSpecialized<BothTypes, BothTypes, _Explicit_>
    88 {
    89     enum { specialized = true };
    90     static bool convert(BothTypes* output, const BothTypes& input)
    91     { (*output) = input; return true; }
    92 };
    93 
    94 
    95 // The possible levels
    96 #define __low__  0 // Everything that is or behaves like a primitive type (an can be converted with a typecast to every other low-level type)
    97 #define __mid__  1 // Everything that has overloaded << and >> operators to operate on a std::stream
    98 #define __high__ 2 // Everything that doesn't fullfill the lowerlevel-requirements and therefore needs specialized conversions
    99 
    100 // Defines the levels of all types: Default is __high__ so you don't have to define every high-level type
    101 template <class T> struct ConverterLevel              { enum { level = __high__ }; };
    102 template <> struct ConverterLevel<std::string>        { enum { level = __mid__ }; };
    103 template <> struct ConverterLevel<orxonox::Radian>    { enum { level = __mid__ }; };
    104 template <> struct ConverterLevel<orxonox::Degree>    { enum { level = __mid__ }; };
    105 template <> struct ConverterLevel<int>                { enum { level = __low__ }; };
    106 template <> struct ConverterLevel<unsigned int>       { enum { level = __low__ }; };
    107 template <> struct ConverterLevel<char>               { enum { level = __low__ }; };
    108 template <> struct ConverterLevel<unsigned char>      { enum { level = __low__ }; };
    109 template <> struct ConverterLevel<short>              { enum { level = __low__ }; };
    110 template <> struct ConverterLevel<unsigned short>     { enum { level = __low__ }; };
    111 template <> struct ConverterLevel<long>               { enum { level = __low__ }; };
    112 template <> struct ConverterLevel<unsigned long>      { enum { level = __low__ }; };
    113 template <> struct ConverterLevel<long long>          { enum { level = __low__ }; };
    114 template <> struct ConverterLevel<unsigned long long> { enum { level = __low__ }; };
    115 template <> struct ConverterLevel<float>              { enum { level = __low__ }; };
    116 template <> struct ConverterLevel<double>             { enum { level = __low__ }; };
    117 template <> struct ConverterLevel<long double>        { enum { level = __low__ }; };
    118 template <> struct ConverterLevel<bool>               { enum { level = __low__ }; };
    119 
    120 
    121 // Calculates the preference based on the levels of FromType and ToType
    122 template <int from, int to>
    123 struct ConverterPreference
    124 {
    125     enum
    126     {
    127         // The maximum of both levels: element of {0, 1, 2}
    128         // max 0: Both types are primitives or have a similar behaviour
    129         // max 1: At least one type is not a primitive, but both can be put on a std::stream
    130         // max 2: There is at least one generic type that needs specialized conversions
    131         max = (from > to) ? from : to,
    132 
    133         // The difference between both levels limited to +-1: element of {-1, 0, 1}
    134         // diff -1: The FromType has higher level than the ToType
    135         // diff  0: Both types have the same level
    136         // diff  1: The ToType has higher level than the FromType
    137         diff = ((to - from) > 1) ? 1 : (((to - from) < -1) ? -1 : to - from)
    138     };
    139 };
    140 
    141 
    142 // The default conversion: This usually does nothing
    143 template <int max, class FromType, class ToType>
    144 struct ConverterDefault
     144// If all else fails, try a dynamic_cast for pointer types.
     145template <class FromType, class ToType>
     146struct ConverterFallback<FromType*, ToType*>
     147{
     148    static bool convert(ToType** output, FromType* const input)
     149    {
     150        ToType* temp = dynamic_cast<ToType*>(input);
     151        if (temp)
     152        {
     153            *output = temp;
     154            return true;
     155        }
     156        else
     157            return false;
     158    }
     159};
     160
     161
     162///////////////////////
     163// ConverterFallback //
     164///////////////////////
     165
     166// Default template for stringstream
     167template <class FromType, class ToType>
     168struct ConverterStringStream
    145169{
    146170    static bool convert(ToType* output, const FromType& input)
    147171    {
    148         COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl;
    149         return false;
    150     }
    151 };
    152 // The default conversion for primitives: A typecast (defined over two partial specialized templates to exclude all non-primitive types and classes)    template <int max, class FromType, class ToType>
    153 template <class FromType, class ToType>
    154 struct ConverterDefault<0, FromType, ToType>
    155 {
    156     static bool convert(ToType* output, const FromType& input)
    157     {
    158         (*output) = (ToType)input;
    159         return true;
    160     }
    161 };
    162 
    163 
    164 // Converter: Converts input of FromType into output of ToType
    165 template <int diff, int max, class FromType, class ToType, ConversionPreference pref>
    166 struct Converter
    167 {
    168     static bool convert(ToType* output, const FromType& input)
    169     {
    170         return false;
    171     }
    172 };
    173 // Converter: level{FromType} > level{ToType}
    174 template <int max, class FromType, class ToType, ConversionPreference pref>
    175 struct Converter<-1, max, FromType, ToType, pref>
    176 {   static bool convert(ToType* output, const FromType& input)
    177     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    178 // Converter: level{FromType} < level{ToType}
    179 template <int max, class FromType, class ToType, ConversionPreference pref>
    180 struct Converter<1, max, FromType, ToType, pref>
    181 {   static bool convert(ToType* output, const FromType& input)
    182     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    183 // Converter: level{FromType} = level{ToType}
    184 // CP_PreferToType
    185 template <int max, class FromType, class ToType>
    186 struct Converter<0, max, FromType, ToType, CP_PreferToType>
    187 {   static bool convert(ToType* output, const FromType& input)
    188     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    189 // CP_PreferFromType
    190 template <int max, class FromType, class ToType>
    191 struct Converter<0, max, FromType, ToType, CP_PreferFromType>
    192 {   static bool convert(ToType* output, const FromType& input)
    193     { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
    194 
    195 
    196 // Calls the Converter::convertValue function with the correct template type parameters calculated by ConverterPreference
    197 template <class FromType, class ToType>
    198 static bool convertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
    199 {
    200     return (preference == CP_PreferToType) ?
    201            Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
    202                      ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
    203                      FromType,
    204                      ToType,
    205                      CP_PreferToType>::convert(output, input)
    206          : Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
    207                      ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
    208                      FromType,
    209                      ToType,
    210                      CP_PreferFromType>::convert(output, input);
    211 }
    212 
    213 
    214 //////////////////////
    215 // HELPER FUNCTIONS //
    216 //////////////////////
    217 
    218 // Helper function: Calls convertValue with and without default value and returns true if the conversion was successful
    219 template<class FromType, class ToType>
    220 static bool ConvertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
    221 {
    222     return convertValue(output, input, preference);
    223 }
    224 template<class FromType, class ToType>
    225 static bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
    226 {
    227     if (convertValue(output, input, preference))
    228         return true;
    229 
    230     (*output) = fallback;
    231     return false;
    232 }
    233 
    234 // Helper function: Calls convertValue with and without default value and returns the converted value
    235 template<class FromType, class ToType>
    236 static ToType getConvertedValue(const FromType& input, ConversionPreference preference = CP_PreferToType)
    237 {
    238     ToType output = ToType();
    239     ConvertValue(&output, input, preference);
    240     return output;
    241 }
    242 template<class FromType, class ToType>
    243 static ToType getConvertedValue(const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
    244 {
    245     ToType output = fallback;
    246     ConvertValue(&output, input, fallback, preference);
    247     return output;
    248 }
    249 
    250 
    251 /////////////////////
    252 // SPECIALIZATIONS //
    253 /////////////////////
     172        return ConverterFallback<FromType, ToType>::convert(output, input);
     173    }
     174};
     175
    254176
    255177/////////////
    256 // SAMPLES //
     178// OStream //
    257179/////////////
    258 /*
    259 // convert everything to xyz
     180
     181namespace fallbackTemplates
     182{
     183    template <class FromType>
     184    inline bool operator <<(std::ostream& outstream,  const FromType& input)
     185    {
     186        std::string temp;
     187        if (ConverterFallback<FromType, std::string>::convert(&temp, input))
     188        {
     189            std::operator <<(outstream, temp);
     190            return true;
     191        }
     192        else
     193            return false;
     194    }
     195}
     196
     197// template that evaluates whether we can convert to std::string via ostringstream
    260198template <class FromType>
    261 struct ConverterSpecialized<FromType, xyz, _ToType_>
    262 {
    263     enum { specialized = true };
    264     static bool convert(xyz* output, const FromType& input)
    265     { return ...; }
    266 };
    267 
    268 // convert xyz to everything
    269 template <class ToType>
    270 struct ConverterSpecialized<xyz, ToType, _FromType_>
    271 {
    272     enum { specialized = true };
    273     static bool convert(ToType* output, const xyz& input)
    274     { return ...; }
    275 };
    276 
    277 // convert abc to xyz
    278 template <>
    279 struct ConverterSpecialized<abc, xyz, _Explicit_>
    280 {
    281     enum { specialized = true };
    282     static bool convert(xyz* output, const abc& input)
    283     { return ...; }
    284 };
    285 */
    286 
    287 ////////////
    288 // STRING //
    289 ////////////
    290 
    291 // convert to string
    292 template <class FromType>
    293 struct ConverterSpecialized<FromType, std::string, _ToType_>
    294 {
    295     enum { specialized = true };
     199struct ConverterStringStream<FromType, std::string>
     200{
    296201    static bool convert(std::string* output, const FromType& input)
    297202    {
     203        using namespace fallbackTemplates;
     204        // this operator call only chooses fallbackTemplates::operator<< if there's no other fitting function
    298205        std::ostringstream oss;
    299206        if (oss << input)
     
    307214};
    308215
     216
     217/////////////
     218// IStream //
     219/////////////
     220
     221namespace fallbackTemplates
     222{
     223    template <class ToType>
     224    inline bool operator >>(std::istream& instream, ToType& output)
     225    {
     226        return ConverterFallback<std::string, ToType>
     227            ::convert(&output, static_cast<std::istringstream&>(instream).str());
     228    }
     229}
     230
     231// template that evaluates whether we can convert from std::string via ostringstream
     232template <class ToType>
     233struct ConverterStringStream<std::string, ToType>
     234{
     235    static bool convert(ToType* output, const std::string& input)
     236    {
     237        using namespace fallbackTemplates;
     238        std::istringstream iss(input);
     239        // this operator call only chooses fallbackTemplates::operator>> if there's no other fitting function
     240        if (iss >> (*output))
     241        {
     242            return true;
     243        }
     244        else
     245            return false;
     246    }
     247};
     248
     249
     250///////////////////
     251// Implicit Cast //
     252///////////////////
     253
     254// implicit cast not possible, try stringstream conversion next
     255template <class FromType, class ToType>
     256inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<false>)
     257{
     258    return ConverterStringStream<FromType, ToType>::convert(output, input);
     259}
     260
     261// We can cast implicitely
     262template <class FromType, class ToType>
     263inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<true>)
     264{
     265    (*output) = static_cast<ToType>(input);
     266    return true;
     267}
     268
     269
     270////////////////////////////////
     271// ConverterExplicit Fallback //
     272////////////////////////////////
     273
     274// Default template if no specialisation is available
     275template <class FromType, class ToType>
     276struct ConverterExplicit
     277{
     278    static bool convert(ToType* output, const FromType& input)
     279    {
     280        // Try implict cast and probe first. If a simple cast is not possible, it will not compile
     281        // We therefore have to out source it into another template function
     282        const bool probe = ImplicitConversion<FromType, ToType>::exists;
     283        return convertImplicitely(output, input, ::Int2Type<probe>());
     284    }
     285};
     286
     287
     288//////////////////////
     289// Public Functions //
     290//////////////////////
     291
     292/**
     293@brief
     294    Converts any value to any other as long as there exists a conversion.
     295    Otherwise, the conversion will generate a runtime warning and return false.
     296    For information about the different conversion methods (user defined too), see the section
     297    'Actual conversion sequence' in this file above.
     298*/
     299template <class FromType, class ToType>
     300inline bool convertValue(ToType* output, const FromType& input)
     301{
     302    return ConverterExplicit<FromType, ToType>::convert(output, input);
     303}
     304
     305// For compatibility reasons. The same, but with capital ConvertValue
     306template<class FromType, class ToType>
     307inline bool ConvertValue(ToType* output, const FromType& input)
     308{
     309    return convertValue(output, input);
     310}
     311
     312// Calls convertValue and returns true if the conversion was successful.
     313// Otherwise the fallback is used.
     314/**
     315@brief
     316    Converts any value to any other as long as there exists a conversion.
     317    Otherwise, the conversion will generate a runtime warning and return false.
     318    For information about the different conversion methods (user defined too), see the section
     319    'Actual conversion sequence' in this file above.
     320    If the conversion doesn't succeed, 'fallback' is written to '*output'.
     321@param fallback
     322    A default value that gets written to '*output' if there is no conversion.
     323*/
     324template<class FromType, class ToType>
     325inline bool convertValue(ToType* output, const FromType& input, const ToType& fallback)
     326{
     327    if (convertValue(output, input))
     328        return true;
     329    else
     330    {
     331        (*output) = fallback;
     332        return false;
     333    }
     334}
     335
     336// for compatibility reason. (capital 'c' in ConvertValue)
     337template<class FromType, class ToType>
     338inline bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)
     339{
     340    return convertValue(output, input, fallback);
     341}
     342
     343// Directly returns the converted value, even if the conversion was not successful.
     344template<class FromType, class ToType>
     345inline ToType getConvertedValue(const FromType& input)
     346{
     347    ToType output;
     348    convertValue(&output, input);
     349    return output;
     350}
     351
     352// Directly returns the converted value, but uses the fallback on failure.
     353template<class FromType, class ToType>
     354inline ToType getConvertedValue(const FromType& input, const ToType& fallback)
     355{
     356    ToType output;
     357    convertValue(&output, input, fallback);
     358    return output;
     359}
     360
     361// Like getConvertedValue, but the template argument order is in reverse.
     362// That means you can call it exactly like static_cast<ToType>(fromTypeValue).
     363template<class ToType, class FromType>
     364inline ToType omni_cast(const FromType& input)
     365{
     366    ToType output;
     367    convertValue(&output, input);
     368    return output;
     369}
     370
    309371// convert to string Shortcut
    310372template <class FromType>
    311 std::string convertToString(FromType value)
     373inline std::string convertToString(FromType value)
    312374{
    313375  return getConvertedValue<FromType, std::string>(value);
    314376}
    315377
    316 // convert from string
     378// convert from string Shortcut
    317379template <class ToType>
    318 struct ConverterSpecialized<std::string, ToType, _FromType_>
    319 {
    320     enum { specialized = true };
    321     static bool convert(ToType* output, const std::string& input)
    322     {
     380inline ToType convertFromString(std::string str)
     381{
     382  return getConvertedValue<std::string, ToType>(str);
     383}
     384
     385////////////////////////////////
     386// Special string conversions //
     387////////////////////////////////
     388
     389// Delegate conversion from const char* to std::string
     390template <class ToType>
     391struct ConverterExplicit<const char*, ToType>
     392{
     393    static bool convert(ToType* output, const char* input)
     394    {
     395        return convertValue<std::string, ToType>(output, input);
     396    }
     397};
     398
     399// These conversions would exhibit ambiguous << or >> operators when using stringstream
     400template <>
     401struct ConverterExplicit<char, std::string>
     402{
     403    static bool convert(std::string* output, const char input)
     404    {
     405        *output = std::string(1, input);
     406        return true;
     407    }
     408};
     409template <>
     410struct ConverterExplicit<unsigned char, std::string>
     411{
     412    static bool convert(std::string* output, const unsigned char input)
     413    {
     414        *output = std::string(1, input);
     415        return true;
     416    }
     417};
     418template <>
     419struct ConverterExplicit<std::string, char>
     420{
     421    static bool convert(char* output, const std::string input)
     422    {
     423        if (input != "")
     424            *output = input[0];
     425        else
     426            *output = '\0';
     427        return true;
     428    }
     429};
     430template <>
     431struct ConverterExplicit<std::string, unsigned char>
     432{
     433    static bool convert(unsigned char* output, const std::string input)
     434    {
     435        if (input != "")
     436            *output = input[0];
     437        else
     438            *output = '\0';
     439        return true;
     440    }
     441};
     442
     443
     444// bool to std::string
     445template <>
     446struct ConverterExplicit<bool, std::string>
     447{
     448    static bool convert(std::string* output, const bool& input)
     449    {
     450        if (input)
     451          *output = "true";
     452        else
     453          *output = "false";
     454        return false;
     455    }
     456};
     457
     458// std::string to bool
     459template <>
     460struct ConverterExplicit<std::string, bool>
     461{
     462    static bool convert(bool* output, const std::string& input)
     463    {
     464        std::string stripped = getLowercase(removeTrailingWhitespaces(input));
     465        if (stripped == "true" || stripped == "on" || stripped == "yes")
     466        {
     467          *output = true;
     468          return true;
     469        }
     470        else if (stripped == "false" || stripped == "off" || stripped == "no")
     471        {
     472          *output = false;
     473          return true;
     474        }
     475
    323476        std::istringstream iss(input);
    324477        if (iss >> (*output))
     
    329482};
    330483
    331 // convert from string Shortcut
    332 template <class ToType>
    333 ToType convertFromString(std::string str)
    334 {
    335   return getConvertedValue<std::string, ToType>(str);
    336 }
    337 
    338 
    339 //////////
    340 // MATH //
    341 //////////
    342 // convert everything to Degree
    343 template <class FromType>
    344 struct ConverterSpecialized<FromType, Ogre::Degree, _ToType_>
    345 {
    346     enum { specialized = true };
    347     static bool convert(Ogre::Degree* output, const FromType& input)
    348     {
    349         float angle = 0;
    350         bool success = ConvertValue<FromType, float>(&angle, input);
    351         (*output) = angle;
    352         return success;
    353     }
    354 };
    355 
    356 // convert everything to Radian
    357 template <class FromType>
    358 struct ConverterSpecialized<FromType, Ogre::Radian, _ToType_>
    359 {
    360     enum { specialized = true };
    361     static bool convert(Ogre::Radian* output, const FromType& input)
    362     {
    363         float angle = 0;
    364         bool success = ConvertValue<FromType, float>(&angle, input);
    365         (*output) = angle;
    366         return success;
    367     }
    368 };
    369 
    370 
    371 ////////////////////
    372 // MATH TO STRING //
    373 ////////////////////
    374 
    375 // bool to std::string
    376 template <>
    377 struct ConverterSpecialized<bool, std::string, _Explicit_>
    378 {
    379     enum { specialized = true };
    380     static bool convert(std::string* output, const bool& input)
    381     {
    382         if (input)
    383           *output = "true";
    384         else
    385           *output = "false";
    386         return false;
    387     }
    388 };
    389 
    390 // Vector2 to std::string
    391 template <>
    392 struct ConverterSpecialized<orxonox::Vector2, std::string, _Explicit_>
    393 {
    394     enum { specialized = true };
    395     static bool convert(std::string* output, const orxonox::Vector2& input)
    396     {
    397         std::ostringstream ostream;
    398         if (ostream << input.x << "," << input.y)
    399         {
    400             (*output) = ostream.str();
    401             return true;
    402         }
    403         return false;
    404     }
    405 };
    406 
    407 // Vector3 to std::string
    408 template <>
    409 struct ConverterSpecialized<orxonox::Vector3, std::string, _Explicit_>
    410 {
    411     enum { specialized = true };
    412     static bool convert(std::string* output, const orxonox::Vector3& input)
    413     {
    414         std::ostringstream ostream;
    415         if (ostream << input.x << "," << input.y << "," << input.z)
    416         {
    417             (*output) = ostream.str();
    418             return true;
    419         }
    420         return false;
    421     }
    422 };
    423 
    424 // Vector4 to std::string
    425 template <>
    426 struct ConverterSpecialized<orxonox::Vector4, std::string, _Explicit_>
    427 {
    428     enum { specialized = true };
    429     static bool convert(std::string* output, const orxonox::Vector4& input)
    430     {
    431         std::ostringstream ostream;
    432         if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
    433         {
    434             (*output) = ostream.str();
    435             return true;
    436         }
    437         return false;
    438     }
    439 };
    440 
    441 // Quaternion to std::string
    442 template <>
    443 struct ConverterSpecialized<orxonox::Quaternion, std::string, _Explicit_>
    444 {
    445     enum { specialized = true };
    446     static bool convert(std::string* output, const orxonox::Quaternion& input)
    447     {
    448         std::ostringstream ostream;
    449         if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
    450         {
    451             (*output) = ostream.str();
    452             return true;
    453         }
    454         return false;
    455     }
    456 };
    457 
    458 // ColourValue to std::string
    459 template <>
    460 struct ConverterSpecialized<orxonox::ColourValue, std::string, _Explicit_>
    461 {
    462     enum { specialized = true };
    463     static bool convert(std::string* output, const orxonox::ColourValue& input)
    464     {
    465         std::ostringstream ostream;
    466         if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
    467         {
    468             (*output) = ostream.str();
    469             return true;
    470         }
    471         return false;
    472     }
    473 };
    474 
    475 
    476 ////////////////////
    477 // STRING TO MATH //
    478 ////////////////////
    479 
    480 // std::string to bool
    481 template <>
    482 struct ConverterSpecialized<std::string, bool, _Explicit_>
    483 {
    484     enum { specialized = true };
    485     static bool convert(bool* output, const std::string& input)
    486     {
    487         std::string stripped = getLowercase(removeTrailingWhitespaces(input));
    488         if (stripped == "true" || stripped == "on" || stripped == "yes")
    489         {
    490           *output = true;
    491           return true;
    492         }
    493         else if (stripped == "false" || stripped == "off" || stripped == "no")
    494         {
    495           *output = false;
    496           return true;
    497         }
    498 
    499         std::istringstream iss(input);
    500         if (iss >> (*output))
    501             return true;
    502         else
    503             return false;
    504     }
    505 };
    506 
    507 // std::string to Vector2
    508 template <>
    509 struct ConverterSpecialized<std::string, orxonox::Vector2, _Explicit_>
    510 {
    511     enum { specialized = true };
    512     static bool convert(orxonox::Vector2* output, const std::string& input)
    513     {
    514         size_t opening_parenthesis, closing_parenthesis = input.find(')');
    515         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    516 
    517         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    518         if (tokens.size() >= 2)
    519         {
    520             if (!ConvertValue(&(output->x), tokens[0]))
    521                 return false;
    522             if (!ConvertValue(&(output->y), tokens[1]))
    523                 return false;
    524 
    525             return true;
    526         }
    527         return false;
    528     }
    529 };
    530 
    531 // std::string to Vector3
    532 template <>
    533 struct ConverterSpecialized<std::string, orxonox::Vector3, _Explicit_>
    534 {
    535     enum { specialized = true };
    536     static bool convert(orxonox::Vector3* output, const std::string& input)
    537     {
    538         size_t opening_parenthesis, closing_parenthesis = input.find(')');
    539         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    540 
    541         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    542         if (tokens.size() >= 3)
    543         {
    544             if (!ConvertValue(&(output->x), tokens[0]))
    545                 return false;
    546             if (!ConvertValue(&(output->y), tokens[1]))
    547                 return false;
    548             if (!ConvertValue(&(output->z), tokens[2]))
    549                 return false;
    550 
    551             return true;
    552         }
    553         return false;
    554     }
    555 };
    556 
    557 // std::string to Vector4
    558 template <>
    559 struct ConverterSpecialized<std::string, orxonox::Vector4, _Explicit_>
    560 {
    561     enum { specialized = true };
    562     static bool convert(orxonox::Vector4* output, const std::string& input)
    563     {
    564         size_t opening_parenthesis, closing_parenthesis = input.find(')');
    565         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    566 
    567         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    568         if (tokens.size() >= 4)
    569         {
    570             if (!ConvertValue(&(output->x), tokens[0]))
    571                 return false;
    572             if (!ConvertValue(&(output->y), tokens[1]))
    573                 return false;
    574             if (!ConvertValue(&(output->z), tokens[2]))
    575                 return false;
    576             if (!ConvertValue(&(output->w), tokens[3]))
    577                 return false;
    578 
    579             return true;
    580         }
    581         return false;
    582     }
    583 };
    584 
    585 // std::string to Quaternion
    586 template <>
    587 struct ConverterSpecialized<std::string, orxonox::Quaternion, _Explicit_>
    588 {
    589     enum { specialized = true };
    590     static bool convert(orxonox::Quaternion* output, const std::string& input)
    591     {
    592         size_t opening_parenthesis, closing_parenthesis = input.find(')');
    593         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    594 
    595         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    596         if (tokens.size() >= 4)
    597         {
    598             if (!ConvertValue(&(output->w), tokens[0]))
    599                 return false;
    600             if (!ConvertValue(&(output->x), tokens[1]))
    601                 return false;
    602             if (!ConvertValue(&(output->y), tokens[2]))
    603                 return false;
    604             if (!ConvertValue(&(output->z), tokens[3]))
    605                 return false;
    606 
    607             return true;
    608         }
    609         return false;
    610     }
    611 };
    612 
    613 // std::string to ColourValue
    614 template <>
    615 struct ConverterSpecialized<std::string, orxonox::ColourValue, _Explicit_>
    616 {
    617     enum { specialized = true };
    618     static bool convert(orxonox::ColourValue* output, const std::string& input)
    619     {
    620         size_t opening_parenthesis, closing_parenthesis = input.find(')');
    621         if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
    622 
    623         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    624         if (tokens.size() >= 3)
    625         {
    626             if (!ConvertValue(&(output->r), tokens[0]))
    627                 return false;
    628             if (!ConvertValue(&(output->g), tokens[1]))
    629                 return false;
    630             if (!ConvertValue(&(output->b), tokens[2]))
    631                 return false;
    632             if (tokens.size() >= 4)
    633             {
    634                 if (!ConvertValue(&(output->a), tokens[3]))
    635                     return false;
    636             }
    637             else
    638                 output->a = 1.0;
    639 
    640             return true;
    641         }
    642         return false;
    643     }
    644 };
    645 
    646 
    647 ///////////////////////////
    648 // Static type detection //
    649 ///////////////////////////
    650 
    651 /**
    652     Template class that determines whether type T converts implicitly to type U.
    653 @note
    654     This allows to detect type conversion at compile time.
    655     From 'Modern C++ Design' (Alexandrescu 2001).
    656 */
    657 template <class T, class U>
    658 class StaticConversion
    659 {
    660     class Small { char dummy[1]; };
    661     class Big   { char dummy[1024]; };
    662     static Small Test(U);
    663     static Big   Test(...);
    664     static T MakeT();
    665 public:
    666     enum { exists = sizeof(Test(MakeT())) == sizeof(Small) };
    667 };
    668 
    669 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
    670 #pragma warning(pop)
    671 #endif
    672 
    673484#endif /* _Convert_H__ */
  • code/trunk/src/util/Debug.h

    r1791 r2087  
    7777}
    7878
     79namespace orxonox
     80{
     81    using std::endl;
     82}
    7983
    8084// DEFINE ERROR MODES
  • code/trunk/src/util/Exception.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/Exception.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/util/Math.cc

    r1791 r2087  
    2828
    2929/**
    30     @file Math.cc
     30    @file
    3131    @brief Implementation of several math-functions.
    3232*/
    3333
     34#include "Math.h"
     35
    3436#include <OgrePlane.h>
    35 
    36 #include "Math.h"
    37 #include "Convert.h"
     37#include "MathConvert.h"
     38#include "SubString.h"
    3839
    3940/**
     
    201202}
    202203
    203 std::string getUniqueNumberStr()
    204 {
    205     return convertToString(getUniqueNumber());
    206 }
     204
     205//////////////////////////
     206// Conversion functions //
     207//////////////////////////
     208
     209// std::string to Vector2
     210bool ConverterFallback<std::string, orxonox::Vector2>::convert(orxonox::Vector2* output, const std::string& input)
     211{
     212    size_t opening_parenthesis, closing_parenthesis = input.find(')');
     213    if ((opening_parenthesis = input.find('(')) == std::string::npos)
     214        opening_parenthesis = 0;
     215    else
     216        opening_parenthesis++;
     217
     218    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
     219                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
     220    if (tokens.size() >= 2)
     221    {
     222        if (!ConvertValue(&(output->x), tokens[0]))
     223            return false;
     224        if (!ConvertValue(&(output->y), tokens[1]))
     225            return false;
     226
     227        return true;
     228    }
     229    return false;
     230}
     231
     232// std::string to Vector3
     233bool ConverterFallback<std::string, orxonox::Vector3>::convert(orxonox::Vector3* output, const std::string& input)
     234{
     235    size_t opening_parenthesis, closing_parenthesis = input.find(')');
     236    if ((opening_parenthesis = input.find('(')) == std::string::npos)
     237        opening_parenthesis = 0;
     238    else
     239        opening_parenthesis++;
     240
     241    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
     242                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
     243    if (tokens.size() >= 3)
     244    {
     245        if (!ConvertValue(&(output->x), tokens[0]))
     246            return false;
     247        if (!ConvertValue(&(output->y), tokens[1]))
     248            return false;
     249        if (!ConvertValue(&(output->z), tokens[2]))
     250            return false;
     251
     252        return true;
     253    }
     254    return false;
     255}
     256
     257// std::string to Vector4
     258bool ConverterFallback<std::string, orxonox::Vector4>::convert(orxonox::Vector4* output, const std::string& input)
     259{
     260    size_t opening_parenthesis, closing_parenthesis = input.find(')');
     261    if ((opening_parenthesis = input.find('(')) == std::string::npos)
     262        opening_parenthesis = 0;
     263    else
     264        opening_parenthesis++;
     265
     266    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
     267                     ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
     268    if (tokens.size() >= 4)
     269    {
     270        if (!ConvertValue(&(output->x), tokens[0]))
     271            return false;
     272        if (!ConvertValue(&(output->y), tokens[1]))
     273            return false;
     274        if (!ConvertValue(&(output->z), tokens[2]))
     275            return false;
     276        if (!ConvertValue(&(output->w), tokens[3]))
     277            return false;
     278
     279        return true;
     280    }
     281    return false;
     282}
     283
     284// std::string to Quaternion
     285bool ConverterFallback<std::string, orxonox::Quaternion>::convert(orxonox::Quaternion* output, const std::string& input)
     286{
     287    size_t opening_parenthesis, closing_parenthesis = input.find(')');
     288    if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
     289
     290    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
     291    if (tokens.size() >= 4)
     292    {
     293        if (!ConvertValue(&(output->w), tokens[0]))
     294            return false;
     295        if (!ConvertValue(&(output->x), tokens[1]))
     296            return false;
     297        if (!ConvertValue(&(output->y), tokens[2]))
     298            return false;
     299        if (!ConvertValue(&(output->z), tokens[3]))
     300            return false;
     301
     302        return true;
     303    }
     304    return false;
     305}
     306
     307// std::string to ColourValue
     308bool ConverterFallback<std::string, orxonox::ColourValue>::convert(orxonox::ColourValue* output, const std::string& input)
     309{
     310    size_t opening_parenthesis, closing_parenthesis = input.find(')');
     311    if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
     312
     313    SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
     314    if (tokens.size() >= 3)
     315    {
     316        if (!ConvertValue(&(output->r), tokens[0]))
     317            return false;
     318        if (!ConvertValue(&(output->g), tokens[1]))
     319            return false;
     320        if (!ConvertValue(&(output->b), tokens[2]))
     321            return false;
     322        if (tokens.size() >= 4)
     323        {
     324            if (!ConvertValue(&(output->a), tokens[3]))
     325                return false;
     326        }
     327        else
     328            output->a = 1.0;
     329
     330        return true;
     331    }
     332    return false;
     333}
  • code/trunk/src/util/Math.h

    r1840 r2087  
    3939#include <ostream>
    4040#include <string>
     41#include <boost/static_assert.hpp>
    4142
    4243#include <OgreMath.h>
     
    189190}
    190191
     192template <typename T>
     193inline T zeroise()
     194{
     195    BOOST_STATIC_ASSERT(sizeof(T) == 0);
     196    return T();
     197}
     198
     199template <> inline char                 zeroise<char>()                 { return 0; }
     200template <> inline unsigned char        zeroise<unsigned char>()        { return 0; }
     201template <> inline short                zeroise<short>()                { return 0; }
     202template <> inline unsigned short       zeroise<unsigned short>()       { return 0; }
     203template <> inline int                  zeroise<int>()                  { return 0; }
     204template <> inline unsigned int         zeroise<unsigned int>()         { return 0; }
     205template <> inline long                 zeroise<long>()                 { return 0; }
     206template <> inline unsigned long        zeroise<unsigned long>()        { return 0; }
     207template <> inline long long            zeroise<long long>()            { return 0; }
     208template <> inline unsigned long long   zeroise<unsigned long long>()   { return 0; }
     209template <> inline float                zeroise<float>()                { return 0; }
     210template <> inline double               zeroise<double>()               { return 0; }
     211template <> inline long double          zeroise<long double>()          { return 0; }
     212template <> inline bool                 zeroise<bool>()                 { return 0; }
     213template <> inline void*                zeroise<void*>()                { return 0; }
     214template <> inline std::string          zeroise<std::string>()          { return ""; }
     215template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
     216template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
     217template <> inline orxonox::Vector2     zeroise<orxonox::Vector2>()     { return orxonox::Vector2    (0, 0)      ; }
     218template <> inline orxonox::Vector3     zeroise<orxonox::Vector3>()     { return orxonox::Vector3    (0, 0, 0)   ; }
     219template <> inline orxonox::Vector4     zeroise<orxonox::Vector4>()     { return orxonox::Vector4    (0, 0, 0, 0); }
     220template <> inline orxonox::ColourValue zeroise<orxonox::ColourValue>() { return orxonox::ColourValue(0, 0, 0, 0); }
     221template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
     222
    191223/**
    192224    @brief Interpolates between two values for a time between 0 and 1.
     
    243275
    244276_UtilExport unsigned long getUniqueNumber();
    245 _UtilExport std::string getUniqueNumberStr();
    246277
    247278class _UtilExport IntVector2
  • code/trunk/src/util/MultiType.cc

    r1791 r2087  
    3939    @param type The type
    4040*/
    41 void MultiType::convert(MT_Type type)
     41bool MultiType::convert(MT_Type type)
    4242{
    4343    switch (type)
    4444    {
    4545        case MT_char:
    46             this->convert<char>(); break;
     46            return this->convert<char>(); break;
    4747        case MT_uchar:
    48             this->convert<unsigned char>(); break;
     48            return this->convert<unsigned char>(); break;
    4949        case MT_short:
    50             this->convert<short>(); break;
     50            return this->convert<short>(); break;
    5151        case MT_ushort:
    52             this->convert<unsigned short>(); break;
     52            return this->convert<unsigned short>(); break;
    5353        case MT_int:
    54             this->convert<int>(); break;
     54            return this->convert<int>(); break;
    5555        case MT_uint:
    56             this->convert<unsigned int>(); break;
     56            return this->convert<unsigned int>(); break;
    5757        case MT_long:
    58             this->convert<long>(); break;
     58            return this->convert<long>(); break;
    5959        case MT_ulong:
    60             this->convert<unsigned long>(); break;
     60            return this->convert<unsigned long>(); break;
    6161        case MT_longlong:
    62             this->convert<long long>(); break;
     62            return this->convert<long long>(); break;
    6363        case MT_ulonglong:
    64             this->convert<unsigned long long>(); break;
     64            return this->convert<unsigned long long>(); break;
    6565        case MT_float:
    66             this->convert<float>(); break;
     66            return this->convert<float>(); break;
    6767        case MT_double:
    68             this->convert<double>(); break;
     68            return this->convert<double>(); break;
    6969        case MT_longdouble:
    70             this->convert<long double>(); break;
     70            return this->convert<long double>(); break;
    7171        case MT_bool:
    72             this->convert<bool>(); break;
     72            return this->convert<bool>(); break;
    7373        case MT_void:
    74             this->convert<void*>(); break;
     74            return this->convert<void*>(); break;
    7575        case MT_string:
    76             this->convert<std::string>(); break;
     76            return this->convert<std::string>(); break;
    7777        case MT_vector2:
    78             this->convert<orxonox::Vector2>(); break;
     78            return this->convert<orxonox::Vector2>(); break;
    7979        case MT_vector3:
    80             this->convert<orxonox::Vector3>(); break;
     80            return this->convert<orxonox::Vector3>(); break;
    8181        case MT_vector4:
    82             this->convert<orxonox::Vector4>(); break;
     82            return this->convert<orxonox::Vector4>(); break;
    8383        case MT_colourvalue:
    84             this->convert<orxonox::ColourValue>(); break;
     84            return this->convert<orxonox::ColourValue>(); break;
    8585        case MT_quaternion:
    86             this->convert<orxonox::Quaternion>(); break;
     86            return this->convert<orxonox::Quaternion>(); break;
    8787        case MT_radian:
    88             this->convert<orxonox::Radian>(); break;
     88            return this->convert<orxonox::Radian>(); break;
    8989        case MT_degree:
    90             this->convert<orxonox::Degree>(); break;
     90            return this->convert<orxonox::Degree>(); break;
    9191        default:
    92             this->reset(); break;
     92            this->reset(); return false; break;
    9393    };
    9494}
     
    168168MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_double     ) ? ((MT_Value<double>              *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
    169169MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double>         *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
    170 MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : false;                  } /** @brief Returns the current value, converted to the requested type. */
    171 MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : (void*)0;               } /** @brief Returns the current value, converted to the requested type. */
    172 MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : std::string();          } /** @brief Returns the current value, converted to the requested type. */
    173 MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
    174 MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
    175 MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
    176 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
    177 MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
    178 MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
    179 MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
     170MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     171MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
     172MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : zeroise<std::string>();          } /** @brief Returns the current value, converted to the requested type. */
     173MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector2>();     } /** @brief Returns the current value, converted to the requested type. */
     174MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector3>();     } /** @brief Returns the current value, converted to the requested type. */
     175MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector4>();     } /** @brief Returns the current value, converted to the requested type. */
     176MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::ColourValue>(); } /** @brief Returns the current value, converted to the requested type. */
     177MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Quaternion>();  } /** @brief Returns the current value, converted to the requested type. */
     178MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Radian>();      } /** @brief Returns the current value, converted to the requested type. */
     179MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Degree>();      } /** @brief Returns the current value, converted to the requested type. */
    180180
    181181template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_char       ); } /** @brief Creates a new value container for the given type. */
  • code/trunk/src/util/MultiType.h

    r1854 r2087  
    5858    a.convert<bool>();         // converts 3.14 to bool, which is true
    5959    a = false;                 // assigns false, this is equivalent to a.setValue(false)
     60
     61    @note
     62    Whenever a value gets converted, there is a boolean return value telling you whether it was
     63    successful or not. If it wasn't a zero value is assigned with the help of zeroise<T>().
    6064*/
    6165
     
    128132    struct _UtilExport MT_ValueBase
    129133    {
    130         MT_ValueBase(MT_Type type) : type_(type) {}
     134        MT_ValueBase(MT_Type type) : type_(type), bHasDefaultValue_(false) {}
    131135        virtual ~MT_ValueBase() {}
    132136
     
    134138
    135139        virtual void reset() = 0;
    136         virtual void assimilate(const MultiType& other) = 0;
     140        virtual bool assimilate(const MultiType& other) = 0;
    137141
    138142        /** @brief Returns the type of the current value. */
    139143        const MT_Type& getType() const { return this->type_; }
    140144
    141         virtual void setValue(const char& value)                 = 0;
    142         virtual void setValue(const unsigned char& value)        = 0;
    143         virtual void setValue(const short& value)                = 0;
    144         virtual void setValue(const unsigned short& value)       = 0;
    145         virtual void setValue(const int& value)                  = 0;
    146         virtual void setValue(const unsigned int& value)         = 0;
    147         virtual void setValue(const long& value)                 = 0;
    148         virtual void setValue(const unsigned long& value)        = 0;
    149         virtual void setValue(const long long& value)            = 0;
    150         virtual void setValue(const unsigned long long& value)   = 0;
    151         virtual void setValue(const float& value)                = 0;
    152         virtual void setValue(const double& value)               = 0;
    153         virtual void setValue(const long double& value)          = 0;
    154         virtual void setValue(const bool& value)                 = 0;
    155         virtual void setValue(      void* const& value)          = 0;
    156         virtual void setValue(const std::string& value)          = 0;
    157         virtual void setValue(const orxonox::Vector2& value)     = 0;
    158         virtual void setValue(const orxonox::Vector3& value)     = 0;
    159         virtual void setValue(const orxonox::Vector4& value)     = 0;
    160         virtual void setValue(const orxonox::ColourValue& value) = 0;
    161         virtual void setValue(const orxonox::Quaternion& value)  = 0;
    162         virtual void setValue(const orxonox::Radian& value)      = 0;
    163         virtual void setValue(const orxonox::Degree& value)      = 0;
     145        /** @brief Checks whether the value is a default one. */
     146        bool hasDefaultValue()   const { return this->bHasDefaultValue_; }
     147
     148        virtual bool setValue(const char& value)                 = 0;
     149        virtual bool setValue(const unsigned char& value)        = 0;
     150        virtual bool setValue(const short& value)                = 0;
     151        virtual bool setValue(const unsigned short& value)       = 0;
     152        virtual bool setValue(const int& value)                  = 0;
     153        virtual bool setValue(const unsigned int& value)         = 0;
     154        virtual bool setValue(const long& value)                 = 0;
     155        virtual bool setValue(const unsigned long& value)        = 0;
     156        virtual bool setValue(const long long& value)            = 0;
     157        virtual bool setValue(const unsigned long long& value)   = 0;
     158        virtual bool setValue(const float& value)                = 0;
     159        virtual bool setValue(const double& value)               = 0;
     160        virtual bool setValue(const long double& value)          = 0;
     161        virtual bool setValue(const bool& value)                 = 0;
     162        virtual bool setValue(      void* const& value)          = 0;
     163        virtual bool setValue(const std::string& value)          = 0;
     164        virtual bool setValue(const orxonox::Vector2& value)     = 0;
     165        virtual bool setValue(const orxonox::Vector3& value)     = 0;
     166        virtual bool setValue(const orxonox::Vector4& value)     = 0;
     167        virtual bool setValue(const orxonox::ColourValue& value) = 0;
     168        virtual bool setValue(const orxonox::Quaternion& value)  = 0;
     169        virtual bool setValue(const orxonox::Radian& value)      = 0;
     170        virtual bool setValue(const orxonox::Degree& value)      = 0;
     171
     172        virtual bool getValue(char*                 value) const = 0;
     173        virtual bool getValue(unsigned char*        value) const = 0;
     174        virtual bool getValue(short*                value) const = 0;
     175        virtual bool getValue(unsigned short*       value) const = 0;
     176        virtual bool getValue(int*                  value) const = 0;
     177        virtual bool getValue(unsigned int*         value) const = 0;
     178        virtual bool getValue(long*                 value) const = 0;
     179        virtual bool getValue(unsigned long*        value) const = 0;
     180        virtual bool getValue(long long*            value) const = 0;
     181        virtual bool getValue(unsigned long long*   value) const = 0;
     182        virtual bool getValue(float*                value) const = 0;
     183        virtual bool getValue(double*               value) const = 0;
     184        virtual bool getValue(long double*          value) const = 0;
     185        virtual bool getValue(bool*                 value) const = 0;
     186        virtual bool getValue(void**                value) const = 0;
     187        virtual bool getValue(std::string*          value) const = 0;
     188        virtual bool getValue(orxonox::Vector2*     value) const = 0;
     189        virtual bool getValue(orxonox::Vector3*     value) const = 0;
     190        virtual bool getValue(orxonox::Vector4*     value) const = 0;
     191        virtual bool getValue(orxonox::ColourValue* value) const = 0;
     192        virtual bool getValue(orxonox::Quaternion*  value) const = 0;
     193        virtual bool getValue(orxonox::Radian*      value) const = 0;
     194        virtual bool getValue(orxonox::Degree*      value) const = 0;
    164195
    165196        virtual operator char()                 const = 0;
     
    189220        virtual void toString(std::ostream& outstream) const = 0;
    190221
    191         MT_Type type_; //!< The type of the current value
     222        MT_Type type_;          //!< The type of the current value
     223        bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
    192224    };
    193225
     
    229261        inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
    230262
    231         inline void                                   setValue(const char& value);
    232         inline void                                   setValue(const unsigned char& value);
    233         inline void                                   setValue(const short& value);
    234         inline void                                   setValue(const unsigned short& value);
    235         inline void                                   setValue(const int& value);
    236         inline void                                   setValue(const unsigned int& value);
    237         inline void                                   setValue(const long& value);
    238         inline void                                   setValue(const unsigned long& value);
    239         inline void                                   setValue(const long long& value);
    240         inline void                                   setValue(const unsigned long long& value);
    241         inline void                                   setValue(const float& value);
    242         inline void                                   setValue(const double& value);
    243         inline void                                   setValue(const long double& value);
    244         inline void                                   setValue(const bool& value);
    245         inline void                                   setValue(      void* const& value);
    246         inline void                                   setValue(const std::string& value);
    247         inline void                                   setValue(const orxonox::Vector2& value);
    248         inline void                                   setValue(const orxonox::Vector3& value);
    249         inline void                                   setValue(const orxonox::Vector4& value);
    250         inline void                                   setValue(const orxonox::ColourValue& value);
    251         inline void                                   setValue(const orxonox::Quaternion& value);
    252         inline void                                   setValue(const orxonox::Radian& value);
    253         inline void                                   setValue(const orxonox::Degree& value);
    254         inline void                                   setValue(const char* value);
     263        inline bool                                   setValue(const char& value);
     264        inline bool                                   setValue(const unsigned char& value);
     265        inline bool                                   setValue(const short& value);
     266        inline bool                                   setValue(const unsigned short& value);
     267        inline bool                                   setValue(const int& value);
     268        inline bool                                   setValue(const unsigned int& value);
     269        inline bool                                   setValue(const long& value);
     270        inline bool                                   setValue(const unsigned long& value);
     271        inline bool                                   setValue(const long long& value);
     272        inline bool                                   setValue(const unsigned long long& value);
     273        inline bool                                   setValue(const float& value);
     274        inline bool                                   setValue(const double& value);
     275        inline bool                                   setValue(const long double& value);
     276        inline bool                                   setValue(const bool& value);
     277        inline bool                                   setValue(      void* const& value);
     278        inline bool                                   setValue(const std::string& value);
     279        inline bool                                   setValue(const orxonox::Vector2& value);
     280        inline bool                                   setValue(const orxonox::Vector3& value);
     281        inline bool                                   setValue(const orxonox::Vector4& value);
     282        inline bool                                   setValue(const orxonox::ColourValue& value);
     283        inline bool                                   setValue(const orxonox::Quaternion& value);
     284        inline bool                                   setValue(const orxonox::Radian& value);
     285        inline bool                                   setValue(const orxonox::Degree& value);
     286        inline bool                                   setValue(const char* value);
    255287        /** @brief Assigns a pointer. */
    256         template <typename V> inline void             setValue(V* value)               { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } }
     288        template <typename V> inline bool             setValue(V* value)               { if (this->value_) { return this->value_->setValue((void*)value); } else { return this->assignValue((void*)value); } }
    257289        /** @brief Assigns the value of the other MultiType and converts it to the current type. */
    258         void                                          setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } } }
     290        bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
    259291        /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
    260         template <typename T, typename V> inline void setValue(const V& value)         { this->setType<T>(); this->setValue(value); }
     292        template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
    261293
    262294
     
    264296        inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
    265297
    266         template <typename T> inline void convert()                       { this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
    267         inline void                       convert(const MultiType& other) { this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
    268         void                              convert(MT_Type type);
    269 
    270         /** @brief Resets the value to the defaultvalue of the current type. */
    271         inline void                       reset()                         { if (this->value_) { delete this->value_; this->value_ = 0; } }
     298        template <typename T> inline bool convert()                       { return this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
     299        inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
     300        bool                              convert(MT_Type type);
     301
     302        /** @brief Current content gets deleted. New type is MT_null */
     303        inline void                       reset()                         { if (this->value_) this->value_->reset(); }
    272304
    273305        template <typename T> inline void setType()                       { this->assignValue(T());                            } /** @brief Resets the value and changes the internal type to T. */
     
    282314        template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
    283315        std::string                       getTypename()             const;
     316
     317        /** @brief Checks whether the value is a default one. */
     318        bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }
    284319
    285320        operator char()                  const;
     
    309344        template <class T> operator T*() const { return ((T*)this->operator void*()); }
    310345
    311         inline void getValue(char*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    312         inline void getValue(unsigned char*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    313         inline void getValue(short*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    314         inline void getValue(unsigned short*       value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    315         inline void getValue(int*                  value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    316         inline void getValue(unsigned int*         value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    317         inline void getValue(long*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    318         inline void getValue(unsigned long*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    319         inline void getValue(long long*            value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    320         inline void getValue(unsigned long long*   value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    321         inline void getValue(float*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    322         inline void getValue(double*               value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    323         inline void getValue(long double*          value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    324         inline void getValue(bool*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    325         inline void getValue(void*                 value) const { if (this->value_) {   value  = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    326         inline void getValue(std::string*          value) const { if (this->value_) { (*value) = this->value_->operator std::string();          } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    327         inline void getValue(orxonox::Vector2*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    328         inline void getValue(orxonox::Vector3*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    329         inline void getValue(orxonox::Vector4*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    330         inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    331         inline void getValue(orxonox::Quaternion*  value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion();  } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    332         inline void getValue(orxonox::Radian*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    333         inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     346        inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     347        inline bool getValue(unsigned char*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     348        inline bool getValue(short*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     349        inline bool getValue(unsigned short*       value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     350        inline bool getValue(int*                  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     351        inline bool getValue(unsigned int*         value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     352        inline bool getValue(long*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     353        inline bool getValue(unsigned long*        value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     354        inline bool getValue(long long*            value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     355        inline bool getValue(unsigned long long*   value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     356        inline bool getValue(float*                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     357        inline bool getValue(double*               value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     358        inline bool getValue(long double*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     359        inline bool getValue(bool*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     360        inline bool getValue(void**                value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     361        inline bool getValue(std::string*          value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     362        inline bool getValue(orxonox::Vector2*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     363        inline bool getValue(orxonox::Vector3*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     364        inline bool getValue(orxonox::Vector4*     value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     365        inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     366        inline bool getValue(orxonox::Quaternion*  value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     367        inline bool getValue(orxonox::Radian*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     368        inline bool getValue(orxonox::Degree*      value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
    334369
    335370        inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */
     
    359394
    360395    private:
    361         inline void assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    362         inline void assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
    363         inline void assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    364         inline void assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
    365         inline void assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  } } /** @brief Assigns a new value by changing type and creating a new container. */
    366         inline void assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
    367         inline void assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    368         inline void assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
    369         inline void assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            } } /** @brief Assigns a new value by changing type and creating a new container. */
    370         inline void assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);  } } /** @brief Assigns a new value by changing type and creating a new container. */
    371         inline void assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    372         inline void assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);              } } /** @brief Assigns a new value by changing type and creating a new container. */
    373         inline void assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
    374         inline void assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    375         inline void assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
    376         inline void assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
    377         inline void assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);    } } /** @brief Assigns a new value by changing type and creating a new container. */
    378         inline void assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);    } } /** @brief Assigns a new value by changing type and creating a new container. */
    379         inline void assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);    } } /** @brief Assigns a new value by changing type and creating a new container. */
    380         inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */
    381         inline void assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */
    382         inline void assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
    383         inline void assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
     396        inline bool assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     397        inline bool assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     398        inline bool assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     399        inline bool assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     400        inline bool assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     401        inline bool assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     402        inline bool assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     403        inline bool assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     404        inline bool assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     405        inline bool assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     406        inline bool assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     407        inline bool assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     408        inline bool assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     409        inline bool assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     410        inline bool assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     411        inline bool assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     412        inline bool assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     413        inline bool assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     414        inline bool assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     415        inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     416        inline bool assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     417        inline bool assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
     418        inline bool assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
    384419
    385420        /** @brief Changes the value container. */
    386421        template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
    387422        /** @brief Creates a new value container (works only with specialized types). */
    388         template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
     423        template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); return false; }
    389424
    390425        MT_ValueBase* value_; //!< A pointer to the value container
     
    419454
    420455// Specialization to avoid ambiguities with the conversion operator
    421 template <> inline void MultiType::convert<std::string>()          { this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
    422 template <> inline void MultiType::convert<orxonox::Vector2>()     { this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
    423 template <> inline void MultiType::convert<orxonox::Vector3>()     { this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
    424 template <> inline void MultiType::convert<orxonox::Vector4>()     { this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
    425 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
    426 template <> inline void MultiType::convert<orxonox::Quaternion>()  { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
    427 template <> inline void MultiType::convert<orxonox::Radian>()      { this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
    428 template <> inline void MultiType::convert<orxonox::Degree>()      { this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
     456template <> inline bool MultiType::convert<std::string>()          { return this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
     457template <> inline bool MultiType::convert<orxonox::Vector2>()     { return this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
     458template <> inline bool MultiType::convert<orxonox::Vector3>()     { return this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
     459template <> inline bool MultiType::convert<orxonox::Vector4>()     { return this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
     460template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
     461template <> inline bool MultiType::convert<orxonox::Quaternion>()  { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
     462template <> inline bool MultiType::convert<orxonox::Radian>()      { return this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
     463template <> inline bool MultiType::convert<orxonox::Degree>()      { return this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
    429464
    430465// Specialization to avoid ambiguities with the conversion operator
    431 template <> inline void MultiType::convert<const std::string&>()          { this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
    432 template <> inline void MultiType::convert<const orxonox::Vector2&>()     { this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
    433 template <> inline void MultiType::convert<const orxonox::Vector3&>()     { this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
    434 template <> inline void MultiType::convert<const orxonox::Vector4&>()     { this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
    435 template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
    436 template <> inline void MultiType::convert<const orxonox::Quaternion&>()  { this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
    437 template <> inline void MultiType::convert<const orxonox::Radian&>()      { this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
    438 template <> inline void MultiType::convert<const orxonox::Degree&>()      { this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
     466template <> inline bool MultiType::convert<const std::string&>()          { return this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
     467template <> inline bool MultiType::convert<const orxonox::Vector2&>()     { return this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
     468template <> inline bool MultiType::convert<const orxonox::Vector3&>()     { return this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
     469template <> inline bool MultiType::convert<const orxonox::Vector4&>()     { return this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
     470template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
     471template <> inline bool MultiType::convert<const orxonox::Quaternion&>()  { return this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
     472template <> inline bool MultiType::convert<const orxonox::Radian&>()      { return this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
     473template <> inline bool MultiType::convert<const orxonox::Degree&>()      { return this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
    439474
    440475template <> void MultiType::createNewValueContainer(const char& value);
     
    462497template <> void MultiType::createNewValueContainer(const orxonox::Degree& value);
    463498
    464 inline void MultiType::setValue(const char& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    465 inline void MultiType::setValue(const unsigned char& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    466 inline void MultiType::setValue(const short& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    467 inline void MultiType::setValue(const unsigned short& value)        { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    468 inline void MultiType::setValue(const int& value)                   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    469 inline void MultiType::setValue(const unsigned int& value)          { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    470 inline void MultiType::setValue(const long& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    471 inline void MultiType::setValue(const unsigned long& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    472 inline void MultiType::setValue(const long long& value)             { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    473 inline void MultiType::setValue(const unsigned long long& value)    { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    474 inline void MultiType::setValue(const float& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    475 inline void MultiType::setValue(const double& value)                { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    476 inline void MultiType::setValue(const long double& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    477 inline void MultiType::setValue(const bool& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    478 inline void MultiType::setValue(      void* const& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    479 inline void MultiType::setValue(const std::string& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    480 inline void MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    481 inline void MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    482 inline void MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    483 inline void MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    484 inline void MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    485 inline void MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    486 inline void MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
    487 
    488 inline void MultiType::setValue(const char* value)                  { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
     499inline bool MultiType::setValue(const char& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     500inline bool MultiType::setValue(const unsigned char& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     501inline bool MultiType::setValue(const short& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     502inline bool MultiType::setValue(const unsigned short& value)        { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     503inline bool MultiType::setValue(const int& value)                   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     504inline bool MultiType::setValue(const unsigned int& value)          { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     505inline bool MultiType::setValue(const long& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     506inline bool MultiType::setValue(const unsigned long& value)         { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     507inline bool MultiType::setValue(const long long& value)             { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     508inline bool MultiType::setValue(const unsigned long long& value)    { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     509inline bool MultiType::setValue(const float& value)                 { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     510inline bool MultiType::setValue(const double& value)                { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     511inline bool MultiType::setValue(const long double& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     512inline bool MultiType::setValue(const bool& value)                  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     513inline bool MultiType::setValue(      void* const& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     514inline bool MultiType::setValue(const std::string& value)           { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     515inline bool MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     516inline bool MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     517inline bool MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     518inline bool MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     519inline bool MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     520inline bool MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     521inline bool MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
     522
     523inline bool MultiType::setValue(const char* value)                  { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
    489524
    490525#endif /* _MultiType_H__ */
  • code/trunk/src/util/MultiTypeValue.h

    r1854 r2087  
    3838
    3939#include "UtilPrereqs.h"
    40 #include "Convert.h"
     40#include "MathConvert.h"
    4141#include "MultiType.h"
    4242
     
    5454
    5555    /** @brief Resets the current value to the default. */
    56     inline void reset() { this->value_ = T(); }
     56    inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
    5757
    5858    /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
    59     inline void assimilate(const MultiType& other) { if (other.value_) { T temp; other.getValue(&temp); this->value_ = temp; } else { this->value_ = T(); } }
     59    inline bool assimilate(const MultiType& other)
     60    {
     61        if (other.value_)
     62        {
     63            return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
     64        }
     65        else
     66        {
     67            this->value_ = zeroise<T>();
     68            return !(bHasDefaultValue_ = true);
     69        }
     70    }
    6071
    61     inline void setValue(const char& value)                 { this->value_ = getConvertedValue<char,                 T>(value); } /** @brief Assigns the value by converting it to T. */
    62     inline void setValue(const unsigned char& value)        { this->value_ = getConvertedValue<unsigned char,        T>(value); } /** @brief Assigns the value by converting it to T. */
    63     inline void setValue(const short& value)                { this->value_ = getConvertedValue<short,                T>(value); } /** @brief Assigns the value by converting it to T. */
    64     inline void setValue(const unsigned short& value)       { this->value_ = getConvertedValue<unsigned short,       T>(value); } /** @brief Assigns the value by converting it to T. */
    65     inline void setValue(const int& value)                  { this->value_ = getConvertedValue<int,                  T>(value); } /** @brief Assigns the value by converting it to T. */
    66     inline void setValue(const unsigned int& value)         { this->value_ = getConvertedValue<unsigned int,         T>(value); } /** @brief Assigns the value by converting it to T. */
    67     inline void setValue(const long& value)                 { this->value_ = getConvertedValue<long,                 T>(value); } /** @brief Assigns the value by converting it to T. */
    68     inline void setValue(const unsigned long& value)        { this->value_ = getConvertedValue<unsigned long,        T>(value); } /** @brief Assigns the value by converting it to T. */
    69     inline void setValue(const long long& value)            { this->value_ = getConvertedValue<long long,            T>(value); } /** @brief Assigns the value by converting it to T. */
    70     inline void setValue(const unsigned long long& value)   { this->value_ = getConvertedValue<unsigned long long,   T>(value); } /** @brief Assigns the value by converting it to T. */
    71     inline void setValue(const float& value)                { this->value_ = getConvertedValue<float,                T>(value); } /** @brief Assigns the value by converting it to T. */
    72     inline void setValue(const double& value)               { this->value_ = getConvertedValue<double,               T>(value); } /** @brief Assigns the value by converting it to T. */
    73     inline void setValue(const long double& value)          { this->value_ = getConvertedValue<long double,          T>(value); } /** @brief Assigns the value by converting it to T. */
    74     inline void setValue(const bool& value)                 { this->value_ = getConvertedValue<bool,                 T>(value); } /** @brief Assigns the value by converting it to T. */
    75     inline void setValue(      void* const& value)          { this->value_ = getConvertedValue<void*,                T>(value); } /** @brief Assigns the value by converting it to T. */
    76     inline void setValue(const std::string& value)          { this->value_ = getConvertedValue<std::string,          T>(value); } /** @brief Assigns the value by converting it to T. */
    77     inline void setValue(const orxonox::Vector2& value)     { this->value_ = getConvertedValue<orxonox::Vector2,     T>(value); } /** @brief Assigns the value by converting it to T. */
    78     inline void setValue(const orxonox::Vector3& value)     { this->value_ = getConvertedValue<orxonox::Vector3,     T>(value); } /** @brief Assigns the value by converting it to T. */
    79     inline void setValue(const orxonox::Vector4& value)     { this->value_ = getConvertedValue<orxonox::Vector4,     T>(value); } /** @brief Assigns the value by converting it to T. */
    80     inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } /** @brief Assigns the value by converting it to T. */
    81     inline void setValue(const orxonox::Quaternion& value)  { this->value_ = getConvertedValue<orxonox::Quaternion,  T>(value); } /** @brief Assigns the value by converting it to T. */
    82     inline void setValue(const orxonox::Radian& value)      { this->value_ = getConvertedValue<orxonox::Radian,      T>(value); } /** @brief Assigns the value by converting it to T. */
    83     inline void setValue(const orxonox::Degree& value)      { this->value_ = getConvertedValue<orxonox::Degree,      T>(value); } /** @brief Assigns the value by converting it to T. */
     72    inline bool getValue(char*                 value) const { return ConvertValue<T, char                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     73    inline bool getValue(unsigned char*        value) const { return ConvertValue<T, unsigned char       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     74    inline bool getValue(short*                value) const { return ConvertValue<T, short               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     75    inline bool getValue(unsigned short*       value) const { return ConvertValue<T, unsigned short      >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     76    inline bool getValue(int*                  value) const { return ConvertValue<T, int                 >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     77    inline bool getValue(unsigned int*         value) const { return ConvertValue<T, unsigned int        >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     78    inline bool getValue(long*                 value) const { return ConvertValue<T, long                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     79    inline bool getValue(unsigned long*        value) const { return ConvertValue<T, unsigned long       >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     80    inline bool getValue(long long*            value) const { return ConvertValue<T, long long           >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     81    inline bool getValue(unsigned long long*   value) const { return ConvertValue<T, unsigned long long  >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     82    inline bool getValue(float*                value) const { return ConvertValue<T, float               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     83    inline bool getValue(double*               value) const { return ConvertValue<T, double              >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     84    inline bool getValue(long double*          value) const { return ConvertValue<T, long double         >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     85    inline bool getValue(bool*                 value) const { return ConvertValue<T, bool                >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     86    inline bool getValue(void**                value) const { return ConvertValue<T, void*               >(value, value_, 0); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     87    inline bool getValue(std::string*          value) const { return ConvertValue<T, std::string         >(value, value_, zeroise<std::string>         ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     88    inline bool getValue(orxonox::Vector2*     value) const { return ConvertValue<T, orxonox::Vector2    >(value, value_, zeroise<orxonox::Vector2>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     89    inline bool getValue(orxonox::Vector3*     value) const { return ConvertValue<T, orxonox::Vector3    >(value, value_, zeroise<orxonox::Vector3>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     90    inline bool getValue(orxonox::Vector4*     value) const { return ConvertValue<T, orxonox::Vector4    >(value, value_, zeroise<orxonox::Vector4>    ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     91    inline bool getValue(orxonox::ColourValue* value) const { return ConvertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     92    inline bool getValue(orxonox::Quaternion*  value) const { return ConvertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     93    inline bool getValue(orxonox::Radian*      value) const { return ConvertValue<T, orxonox::Radian     >(value, value_, zeroise<orxonox::Radian>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     94    inline bool getValue(orxonox::Degree*      value) const { return ConvertValue<T, orxonox::Degree     >(value, value_, zeroise<orxonox::Degree>     ()); } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     95
     96    inline bool setValue(const char& value)                 { return !(bHasDefaultValue_ = !ConvertValue<char                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     97    inline bool setValue(const unsigned char& value)        { return !(bHasDefaultValue_ = !ConvertValue<unsigned char       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     98    inline bool setValue(const short& value)                { return !(bHasDefaultValue_ = !ConvertValue<short               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     99    inline bool setValue(const unsigned short& value)       { return !(bHasDefaultValue_ = !ConvertValue<unsigned short      , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     100    inline bool setValue(const int& value)                  { return !(bHasDefaultValue_ = !ConvertValue<int                 , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     101    inline bool setValue(const unsigned int& value)         { return !(bHasDefaultValue_ = !ConvertValue<unsigned int        , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     102    inline bool setValue(const long& value)                 { return !(bHasDefaultValue_ = !ConvertValue<long                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     103    inline bool setValue(const unsigned long& value)        { return !(bHasDefaultValue_ = !ConvertValue<unsigned long       , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     104    inline bool setValue(const long long& value)            { return !(bHasDefaultValue_ = !ConvertValue<long long           , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     105    inline bool setValue(const unsigned long long& value)   { return !(bHasDefaultValue_ = !ConvertValue<unsigned long long  , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     106    inline bool setValue(const float& value)                { return !(bHasDefaultValue_ = !ConvertValue<float               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     107    inline bool setValue(const double& value)               { return !(bHasDefaultValue_ = !ConvertValue<double              , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     108    inline bool setValue(const long double& value)          { return !(bHasDefaultValue_ = !ConvertValue<long double         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     109    inline bool setValue(const bool& value)                 { return !(bHasDefaultValue_ = !ConvertValue<bool                , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     110    inline bool setValue(      void* const& value)          { return !(bHasDefaultValue_ = !ConvertValue<void*               , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     111    inline bool setValue(const std::string& value)          { return !(bHasDefaultValue_ = !ConvertValue<std::string         , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     112    inline bool setValue(const orxonox::Vector2& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector2    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     113    inline bool setValue(const orxonox::Vector3& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector3    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     114    inline bool setValue(const orxonox::Vector4& value)     { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Vector4    , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     115    inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !ConvertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     116    inline bool setValue(const orxonox::Quaternion& value)  { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     117    inline bool setValue(const orxonox::Radian& value)      { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Radian     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
     118    inline bool setValue(const orxonox::Degree& value)      { return !(bHasDefaultValue_ = !ConvertValue<orxonox::Degree     , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
    84119
    85120    inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
     
    96131    inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    97132    inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    98     inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, false); } /** @brief Returns the current value, converted to the requested type. */
     133    inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }    /** @brief Returns the current value, converted to the requested type. */
    99134    inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    100     inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    101     inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    102     inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    103     inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    104     inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    105     inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    106     inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
    107     inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
     135    inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, zeroise<std::string         >()); } /** @brief Returns the current value, converted to the requested type. */
     136    inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, zeroise<orxonox::Vector2    >()); } /** @brief Returns the current value, converted to the requested type. */
     137    inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, zeroise<orxonox::Vector3    >()); } /** @brief Returns the current value, converted to the requested type. */
     138    inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, zeroise<orxonox::Vector4    >()); } /** @brief Returns the current value, converted to the requested type. */
     139    inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, zeroise<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
     140    inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, zeroise<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
     141    inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, zeroise<orxonox::Radian     >()); } /** @brief Returns the current value, converted to the requested type. */
     142    inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, zeroise<orxonox::Degree     >()); } /** @brief Returns the current value, converted to the requested type. */
    108143
    109144    /** @brief Puts the current value on the stream */
  • code/trunk/src/util/OutputHandler.cc

    r1791 r2087  
    3333
    3434#include "OutputHandler.h"
     35#include <time.h>
    3536
    3637namespace orxonox
     
    4647        this->logfilename_ = logfilename;
    4748        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
    48         this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl; // Todo: Get date and time
     49
     50        time_t rawtime;
     51        struct tm* timeinfo;
     52        time(&rawtime);
     53        timeinfo = localtime(&rawtime);
     54
     55        this->logfile_ << "Started log at " << asctime(timeinfo) << std::endl;
    4956        this->logfile_.flush();
    5057    }
  • code/trunk/src/util/String.cc

    r1894 r2087  
    3737#include <iostream>
    3838
    39 /**
    40     @brief Blank string as variable so you can use const std::string& even if you have to return "".
    41 */
    42 std::string blankString = "";
     39#include "Convert.h"
     40#include "Math.h"
     41
     42std::string BLANKSTRING("");
     43
     44std::string getUniqueNumberString()
     45{
     46    return convertToString(getUniqueNumber());
     47}
    4348
    4449/**
  • code/trunk/src/util/String.h

    r1889 r2087  
    4040#include <sstream>
    4141
    42 extern _UtilExport std::string blankString;
     42extern _UtilExport std::string BLANKSTRING;
     43_UtilExport std::string getUniqueNumberString();
    4344
    4445_UtilExport void        strip(std::string* str);
  • code/trunk/updateMedia.sh

    r1506 r2087  
    11#!/bin/bash
    22dir=${pwd}
    3 cd ../Media
     3cd ../media
    44svn up
    55cd $dir
  • code/trunk/visual_studio/vc8/audio.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/audio.vsprops

  • code/trunk/visual_studio/vc8/base.vsprops

  • code/trunk/visual_studio/vc8/ceguilua.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/ceguilua.vsprops

  • code/trunk/visual_studio/vc8/core.vcproj

    • Property svn:eol-style set to native
    r1896 r2087  
    165165                        </File>
    166166                        <File
     167                                RelativePath="..\..\src\core\Event.cc"
     168                                >
     169                        </File>
     170                        <File
    167171                                RelativePath="..\..\src\core\GameState.cc"
    168172                                >
     
    173177                        </File>
    174178                        <File
     179                                RelativePath="..\..\src\core\LuaBind.cc"
     180                                >
     181                        </File>
     182                        <File
    175183                                RelativePath="..\..\src\core\OrxonoxClass.cc"
    176184                                >
     
    181189                        </File>
    182190                        <File
    183                                 RelativePath="..\..\src\core\Script.cc"
     191                                RelativePath="..\..\src\core\Template.cc"
     192                                >
     193                        </File>
     194                        <File
     195                                RelativePath="..\..\src\core\XMLNameListener.cc"
    184196                                >
    185197                        </File>
     
    397409                        </File>
    398410                        <File
     411                                RelativePath="..\..\src\core\Event.h"
     412                                >
     413                        </File>
     414                        <File
     415                                RelativePath="..\..\src\core\EventIncludes.h"
     416                                >
     417                        </File>
     418                        <File
    399419                                RelativePath="..\..\src\core\GameState.h"
    400420                                >
     
    405425                        </File>
    406426                        <File
     427                                RelativePath="..\..\src\core\LuaBind.h"
     428                                >
     429                        </File>
     430                        <File
    407431                                RelativePath="..\..\src\core\OrxonoxClass.h"
    408432                                >
     
    413437                        </File>
    414438                        <File
    415                                 RelativePath="..\..\src\core\Script.h"
    416                                 >
    417                         </File>
    418                         <File
    419439                                RelativePath="..\..\src\core\Super.h"
    420440                                >
    421441                        </File>
    422442                        <File
     443                                RelativePath="..\..\src\core\Template.h"
     444                                >
     445                        </File>
     446                        <File
    423447                                RelativePath="..\..\src\core\XMLIncludes.h"
    424448                                >
    425449                        </File>
     450                        <File
     451                                RelativePath="..\..\src\core\XMLNameListener.h"
     452                                >
     453                        </File>
    426454                        <Filter
    427455                                Name="input"
     
    596624                                </File>
    597625                                <File
    598                                         RelativePath="..\..\src\core\Level.h"
    599                                         >
    600                                 </File>
    601                                 <File
    602626                                        RelativePath="..\..\src\core\Loader.h"
    603627                                        >
     
    609633                                <File
    610634                                        RelativePath="..\..\src\core\NamespaceNode.h"
     635                                        >
     636                                </File>
     637                                <File
     638                                        RelativePath="..\..\src\core\XMLFile.h"
    611639                                        >
    612640                                </File>
  • code/trunk/visual_studio/vc8/core.vsprops

  • code/trunk/visual_studio/vc8/cpptcl.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/cpptcl.vsprops

  • code/trunk/visual_studio/vc8/debug.vsprops

  • code/trunk/visual_studio/vc8/directories.vsprops

  • code/trunk/visual_studio/vc8/lua.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/lua.vsprops

  • code/trunk/visual_studio/vc8/lua_static.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/lua_static.vsprops

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/network.vcproj

    • Property svn:eol-style set to native
    r1909 r2087  
    1818                <Configuration
    1919                        Name="Debug|Win32"
    20                         ConfigurationType="4"
     20                        ConfigurationType="2"
    2121                        InheritedPropertySheets=".\debug.vsprops;.\network.vsprops"
    2222                        CharacterSet="1"
     
    5050                        />
    5151                        <Tool
    52                                 Name="VCLibrarianTool"
     52                                Name="VCLinkerTool"
    5353                        />
    5454                        <Tool
     
    5656                        />
    5757                        <Tool
     58                                Name="VCManifestTool"
     59                        />
     60                        <Tool
    5861                                Name="VCXDCMakeTool"
    5962                        />
     
    6366                        <Tool
    6467                                Name="VCFxCopTool"
     68                        />
     69                        <Tool
     70                                Name="VCAppVerifierTool"
     71                        />
     72                        <Tool
     73                                Name="VCWebDeploymentTool"
    6574                        />
    6675                        <Tool
     
    7079                <Configuration
    7180                        Name="Release|Win32"
    72                         ConfigurationType="4"
     81                        ConfigurationType="2"
    7382                        InheritedPropertySheets=".\release.vsprops;.\network.vsprops"
    7483                        CharacterSet="1"
     
    103112                        />
    104113                        <Tool
    105                                 Name="VCLibrarianTool"
     114                                Name="VCLinkerTool"
    106115                        />
    107116                        <Tool
     
    109118                        />
    110119                        <Tool
     120                                Name="VCManifestTool"
     121                        />
     122                        <Tool
    111123                                Name="VCXDCMakeTool"
    112124                        />
     
    116128                        <Tool
    117129                                Name="VCFxCopTool"
     130                        />
     131                        <Tool
     132                                Name="VCAppVerifierTool"
     133                        />
     134                        <Tool
     135                                Name="VCWebDeploymentTool"
    118136                        />
    119137                        <Tool
     
    131149                        >
    132150                        <File
     151                                RelativePath="..\..\src\network\ChatListener.cc"
     152                                >
     153                        </File>
     154                        <File
    133155                                RelativePath="..\..\src\network\Client.cc"
    134156                                >
     
    136158                        <File
    137159                                RelativePath="..\..\src\network\ClientConnection.cc"
     160                                >
     161                        </File>
     162                        <File
     163                                RelativePath="..\..\src\network\ClientConnectionListener.cc"
    138164                                >
    139165                        </File>
     
    213239                        >
    214240                        <File
     241                                RelativePath="..\..\src\network\ChatListener.h"
     242                                >
     243                        </File>
     244                        <File
    215245                                RelativePath="..\..\src\network\Client.h"
    216246                                >
     
    218248                        <File
    219249                                RelativePath="..\..\src\network\ClientConnection.h"
     250                                >
     251                        </File>
     252                        <File
     253                                RelativePath="..\..\src\network\ClientConnectionListener.h"
    220254                                >
    221255                        </File>
  • code/trunk/visual_studio/vc8/network.vsprops

    r1842 r2087  
    99                Name="VCCLCompilerTool"
    1010                AdditionalOptions="/MP2"
    11                 PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD"
     11                PreprocessorDefinitions="NETWORK_SHARED_BUILD"
    1212        />
    1313        <Tool
  • code/trunk/visual_studio/vc8/ois.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/ois.vsprops

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/orxonox.vcproj

    • Property svn:eol-style set to native
    r1896 r2087  
    3939                        <Tool
    4040                                Name="VCCLCompilerTool"
    41                                 AdditionalOptions="/Zm200"
    4241                        />
    4342                        <Tool
     
    103102                        <Tool
    104103                                Name="VCCLCompilerTool"
    105                                 AdditionalOptions="/Zm200"
    106104                        />
    107105                        <Tool
     
    153151                        >
    154152                        <File
     153                                RelativePath="..\..\src\orxonox\CameraManager.cc"
     154                                >
     155                        </File>
     156                        <File
    155157                                RelativePath="..\..\src\orxonox\GraphicsEngine.cc"
     158                                >
     159                        </File>
     160                        <File
     161                                RelativePath="..\..\src\orxonox\LevelManager.cc"
    156162                                >
    157163                        </File>
     
    184190                                >
    185191                        </File>
    186                         <File
    187                                 RelativePath="..\..\src\orxonox\SignalHandler.cc"
    188                                 >
    189                         </File>
    190192                        <Filter
    191193                                Name="objects"
    192194                                >
    193195                                <File
    194                                         RelativePath="..\..\src\orxonox\objects\Ambient.cc"
    195                                         >
    196                                 </File>
    197                                 <File
    198                                         RelativePath="..\..\src\orxonox\objects\Backlight.cc"
    199                                         >
    200                                 </File>
    201                                 <File
    202                                         RelativePath="..\..\src\orxonox\objects\BillboardProjectile.cc"
    203                                         >
    204                                 </File>
    205                                 <File
    206                                         RelativePath="..\..\src\orxonox\objects\Camera.cc"
    207                                         >
    208                                 </File>
    209                                 <File
    210                                         RelativePath="..\..\src\orxonox\objects\CameraHandler.cc"
    211                                         >
    212                                 </File>
    213                                 <File
    214                                         RelativePath="..\..\src\orxonox\objects\Model.cc"
    215                                         >
    216                                 </File>
    217                                 <File
    218                                         RelativePath="..\..\src\orxonox\objects\NPC.cc"
    219                                         >
    220                                 </File>
    221                                 <File
    222                                         RelativePath="..\..\src\orxonox\objects\ParticleProjectile.cc"
    223                                         >
    224                                 </File>
    225                                 <File
    226                                         RelativePath="..\..\src\orxonox\objects\ParticleSpawner.cc"
    227                                         >
    228                                 </File>
    229                                 <File
    230                                         RelativePath="..\..\src\orxonox\objects\Projectile.cc"
     196                                        RelativePath="..\..\src\orxonox\objects\EventDispatcher.cc"
     197                                        >
     198                                </File>
     199                                <File
     200                                        RelativePath="..\..\src\orxonox\objects\EventListener.cc"
     201                                        >
     202                                </File>
     203                                <File
     204                                        RelativePath="..\..\src\orxonox\objects\EventTarget.cc"
    231205                                        >
    232206                                </File>
     
    234208                                        RelativePath="..\..\src\orxonox\objects\Radar.cc"
    235209                                        >
    236                                         <FileConfiguration
    237                                                 Name="Debug|Win32"
    238                                                 >
    239                                                 <Tool
    240                                                         Name="VCCLCompilerTool"
    241                                                         ObjectFile="$(IntDir)\$(InputName)1.obj"
    242                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
    243                                                 />
    244                                         </FileConfiguration>
    245                                         <FileConfiguration
    246                                                 Name="Release|Win32"
    247                                                 >
    248                                                 <Tool
    249                                                         Name="VCCLCompilerTool"
    250                                                         ObjectFile="$(IntDir)\$(InputName)1.obj"
    251                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
    252                                                 />
    253                                         </FileConfiguration>
    254210                                </File>
    255211                                <File
    256212                                        RelativePath="..\..\src\orxonox\objects\RadarListener.cc"
    257213                                        >
    258                                         <FileConfiguration
    259                                                 Name="Debug|Win32"
    260                                                 >
    261                                                 <Tool
    262                                                         Name="VCCLCompilerTool"
    263                                                         ObjectFile="$(IntDir)\$(InputName)1.obj"
    264                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
    265                                                 />
    266                                         </FileConfiguration>
    267                                         <FileConfiguration
    268                                                 Name="Release|Win32"
    269                                                 >
    270                                                 <Tool
    271                                                         Name="VCCLCompilerTool"
    272                                                         ObjectFile="$(IntDir)\$(InputName)1.obj"
    273                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
    274                                                 />
    275                                         </FileConfiguration>
    276214                                </File>
    277215                                <File
     
    280218                                </File>
    281219                                <File
    282                                         RelativePath="..\..\src\orxonox\objects\RotatingProjectile.cc"
    283                                         >
    284                                 </File>
    285                                 <File
    286                                         RelativePath="..\..\src\orxonox\objects\Skybox.cc"
    287                                         >
    288                                 </File>
    289                                 <File
    290                                         RelativePath="..\..\src\orxonox\objects\SpaceShip.cc"
    291                                         >
    292                                 </File>
    293                                 <File
    294                                         RelativePath="..\..\src\orxonox\objects\SpaceShipAI.cc"
     220                                        RelativePath="..\..\src\orxonox\objects\Scene.cc"
     221                                        >
     222                                </File>
     223                                <File
     224                                        RelativePath="..\..\src\orxonox\objects\Script.cc"
     225                                        >
     226                                </File>
     227                                <File
     228                                        RelativePath="..\..\src\orxonox\objects\Test.cc"
    295229                                        >
    296230                                </File>
     
    299233                                        >
    300234                                </File>
    301                                 <File
    302                                         RelativePath="..\..\src\orxonox\objects\WorldEntity.cc"
    303                                         >
    304                                 </File>
     235                                <Filter
     236                                        Name="worldentities"
     237                                        >
     238                                        <File
     239                                                RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.cc"
     240                                                >
     241                                                <FileConfiguration
     242                                                        Name="Debug|Win32"
     243                                                        ExcludedFromBuild="true"
     244                                                        >
     245                                                        <Tool
     246                                                                Name="VCCLCompilerTool"
     247                                                        />
     248                                                </FileConfiguration>
     249                                                <FileConfiguration
     250                                                        Name="Release|Win32"
     251                                                        ExcludedFromBuild="true"
     252                                                        >
     253                                                        <Tool
     254                                                                Name="VCCLCompilerTool"
     255                                                        />
     256                                                </FileConfiguration>
     257                                        </File>
     258                                        <File
     259                                                RelativePath="..\..\src\orxonox\objects\worldentities\Billboard.cc"
     260                                                >
     261                                        </File>
     262                                        <File
     263                                                RelativePath="..\..\src\orxonox\objects\worldentities\BlinkingBillboard.cc"
     264                                                >
     265                                        </File>
     266                                        <File
     267                                                RelativePath="..\..\src\orxonox\objects\worldentities\Camera.cc"
     268                                                >
     269                                        </File>
     270                                        <File
     271                                                RelativePath="..\..\src\orxonox\objects\worldentities\CameraPosition.cc"
     272                                                >
     273                                        </File>
     274                                        <File
     275                                                RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.cc"
     276                                                >
     277                                        </File>
     278                                        <File
     279                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.cc"
     280                                                >
     281                                        </File>
     282                                        <File
     283                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.cc"
     284                                                >
     285                                        </File>
     286                                        <File
     287                                                RelativePath="..\..\src\orxonox\objects\worldentities\MovableEntity.cc"
     288                                                >
     289                                        </File>
     290                                        <File
     291                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleEmitter.cc"
     292                                                >
     293                                        </File>
     294                                        <File
     295                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.cc"
     296                                                >
     297                                        </File>
     298                                        <File
     299                                                RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.cc"
     300                                                >
     301                                        </File>
     302                                        <File
     303                                                RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.cc"
     304                                                >
     305                                        </File>
     306                                        <File
     307                                                RelativePath="..\..\src\orxonox\objects\worldentities\WorldEntity.cc"
     308                                                >
     309                                        </File>
     310                                        <Filter
     311                                                Name="pawns"
     312                                                >
     313                                                <File
     314                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Pawn.cc"
     315                                                        >
     316                                                </File>
     317                                                <File
     318                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\SpaceShip.cc"
     319                                                        >
     320                                                </File>
     321                                                <File
     322                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Spectator.cc"
     323                                                        >
     324                                                </File>
     325                                        </Filter>
     326                                        <Filter
     327                                                Name="triggers"
     328                                                >
     329                                                <File
     330                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\DistanceTrigger.cc"
     331                                                        >
     332                                                </File>
     333                                                <File
     334                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\EventTrigger.cc"
     335                                                        >
     336                                                </File>
     337                                                <File
     338                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.cc"
     339                                                        >
     340                                                </File>
     341                                        </Filter>
     342                                </Filter>
     343                                <Filter
     344                                        Name="gametypes"
     345                                        >
     346                                        <File
     347                                                RelativePath="..\..\src\orxonox\objects\gametypes\Gametype.cc"
     348                                                >
     349                                        </File>
     350                                </Filter>
     351                                <Filter
     352                                        Name="infos"
     353                                        >
     354                                        <File
     355                                                RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.cc"
     356                                                >
     357                                        </File>
     358                                        <File
     359                                                RelativePath="..\..\src\orxonox\objects\infos\Info.cc"
     360                                                >
     361                                        </File>
     362                                        <File
     363                                                RelativePath="..\..\src\orxonox\objects\infos\Level.cc"
     364                                                >
     365                                        </File>
     366                                        <File
     367                                                RelativePath="..\..\src\orxonox\objects\infos\PlayerInfo.cc"
     368                                                >
     369                                        </File>
     370                                </Filter>
     371                                <Filter
     372                                        Name="controllers"
     373                                        >
     374                                        <File
     375                                                RelativePath="..\..\src\orxonox\objects\controllers\Controller.cc"
     376                                                >
     377                                        </File>
     378                                        <File
     379                                                RelativePath="..\..\src\orxonox\objects\controllers\HumanController.cc"
     380                                                >
     381                                        </File>
     382                                </Filter>
    305383                        </Filter>
    306384                        <Filter
     
    309387                                <File
    310388                                        RelativePath="..\..\src\orxonox\tools\BillboardSet.cc"
    311                                         >
    312                                 </File>
    313                                 <File
    314                                         RelativePath="..\..\src\orxonox\tools\Light.cc"
    315389                                        >
    316390                                </File>
     
    413487                                        >
    414488                                        <File
     489                                                RelativePath="..\..\src\orxonox\overlays\hud\ChatOverlay.cc"
     490                                                >
     491                                        </File>
     492                                        <File
    415493                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc"
    416494                                                >
     
    452530                                        RelativePath="..\..\src\orxonox\gui\OgreCEGUIRenderer.cpp"
    453531                                        >
    454                                         <FileConfiguration
    455                                                 Name="Debug|Win32"
    456                                                 >
    457                                                 <Tool
    458                                                         Name="VCCLCompilerTool"
    459                                                         UsePrecompiledHeader="0"
    460                                                 />
    461                                         </FileConfiguration>
    462                                         <FileConfiguration
    463                                                 Name="Release|Win32"
    464                                                 >
    465                                                 <Tool
    466                                                         Name="VCCLCompilerTool"
    467                                                         UsePrecompiledHeader="0"
    468                                                 />
    469                                         </FileConfiguration>
    470532                                </File>
    471533                                <File
    472534                                        RelativePath="..\..\src\orxonox\gui\OgreCEGUIResourceProvider.cpp"
    473535                                        >
    474                                         <FileConfiguration
    475                                                 Name="Debug|Win32"
    476                                                 >
    477                                                 <Tool
    478                                                         Name="VCCLCompilerTool"
    479                                                         UsePrecompiledHeader="0"
    480                                                 />
    481                                         </FileConfiguration>
    482                                         <FileConfiguration
    483                                                 Name="Release|Win32"
    484                                                 >
    485                                                 <Tool
    486                                                         Name="VCCLCompilerTool"
    487                                                         UsePrecompiledHeader="0"
    488                                                 />
    489                                         </FileConfiguration>
    490536                                </File>
    491537                                <File
    492538                                        RelativePath="..\..\src\orxonox\gui\OgreCEGUITexture.cpp"
    493539                                        >
    494                                         <FileConfiguration
    495                                                 Name="Debug|Win32"
    496                                                 >
    497                                                 <Tool
    498                                                         Name="VCCLCompilerTool"
    499                                                         UsePrecompiledHeader="0"
    500                                                 />
    501                                         </FileConfiguration>
    502                                         <FileConfiguration
    503                                                 Name="Release|Win32"
    504                                                 >
    505                                                 <Tool
    506                                                         Name="VCCLCompilerTool"
    507                                                         UsePrecompiledHeader="0"
    508                                                 />
    509                                         </FileConfiguration>
    510540                                </File>
    511541                        </Filter>
     
    557587                        >
    558588                        <File
     589                                RelativePath="..\..\src\orxonox\CameraManager.h"
     590                                >
     591                        </File>
     592                        <File
    559593                                RelativePath="..\..\src\orxonox\GraphicsEngine.h"
    560594                                >
    561595                        </File>
    562596                        <File
     597                                RelativePath="..\..\src\orxonox\LevelManager.h"
     598                                >
     599                        </File>
     600                        <File
    563601                                RelativePath="..\..\src\orxonox\OrxonoxPrereqs.h"
    564602                                >
     
    572610                                >
    573611                        </File>
    574                         <File
    575                                 RelativePath="..\..\src\orxonox\SignalHandler.h"
    576                                 >
    577                         </File>
    578612                        <Filter
    579613                                Name="objects"
    580614                                >
    581615                                <File
    582                                         RelativePath="..\..\src\orxonox\objects\Ambient.h"
    583                                         >
    584                                 </File>
    585                                 <File
    586                                         RelativePath="..\..\src\orxonox\objects\Backlight.h"
    587                                         >
    588                                 </File>
    589                                 <File
    590                                         RelativePath="..\..\src\orxonox\objects\BillboardProjectile.h"
    591                                         >
    592                                 </File>
    593                                 <File
    594                                         RelativePath="..\..\src\orxonox\objects\Camera.h"
    595                                         >
    596                                 </File>
    597                                 <File
    598                                         RelativePath="..\..\src\orxonox\objects\CameraHandler.h"
    599                                         >
    600                                 </File>
    601                                 <File
    602                                         RelativePath="..\..\src\orxonox\objects\Model.h"
    603                                         >
    604                                 </File>
    605                                 <File
    606                                         RelativePath="..\..\src\orxonox\objects\NPC.h"
    607                                         >
    608                                 </File>
    609                                 <File
    610                                         RelativePath="..\..\src\orxonox\objects\ParticleProjectile.h"
    611                                         >
    612                                 </File>
    613                                 <File
    614                                         RelativePath="..\..\src\orxonox\objects\ParticleSpawner.h"
    615                                         >
    616                                 </File>
    617                                 <File
    618                                         RelativePath="..\..\src\orxonox\objects\Projectile.h"
     616                                        RelativePath="..\..\src\orxonox\objects\EventDispatcher.h"
     617                                        >
     618                                </File>
     619                                <File
     620                                        RelativePath="..\..\src\orxonox\objects\EventListener.h"
     621                                        >
     622                                </File>
     623                                <File
     624                                        RelativePath="..\..\src\orxonox\objects\EventTarget.h"
    619625                                        >
    620626                                </File>
     
    632638                                </File>
    633639                                <File
    634                                         RelativePath="..\..\src\orxonox\objects\RotatingProjectile.h"
    635                                         >
    636                                 </File>
    637                                 <File
    638                                         RelativePath="..\..\src\orxonox\objects\Skybox.h"
    639                                         >
    640                                 </File>
    641                                 <File
    642                                         RelativePath="..\..\src\orxonox\objects\SpaceShip.h"
    643                                         >
    644                                 </File>
    645                                 <File
    646                                         RelativePath="..\..\src\orxonox\objects\SpaceShipAI.h"
     640                                        RelativePath="..\..\src\orxonox\objects\Scene.h"
     641                                        >
     642                                </File>
     643                                <File
     644                                        RelativePath="..\..\src\orxonox\objects\Script.h"
     645                                        >
     646                                </File>
     647                                <File
     648                                        RelativePath="..\..\src\orxonox\objects\Test.h"
    647649                                        >
    648650                                </File>
     
    651653                                        >
    652654                                </File>
    653                                 <File
    654                                         RelativePath="..\..\src\orxonox\objects\WorldEntity.h"
    655                                         >
    656                                 </File>
     655                                <Filter
     656                                        Name="worldentities"
     657                                        >
     658                                        <File
     659                                                RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.h"
     660                                                >
     661                                        </File>
     662                                        <File
     663                                                RelativePath="..\..\src\orxonox\objects\worldentities\Billboard.h"
     664                                                >
     665                                        </File>
     666                                        <File
     667                                                RelativePath="..\..\src\orxonox\objects\worldentities\BlinkingBillboard.h"
     668                                                >
     669                                        </File>
     670                                        <File
     671                                                RelativePath="..\..\src\orxonox\objects\worldentities\Camera.h"
     672                                                >
     673                                        </File>
     674                                        <File
     675                                                RelativePath="..\..\src\orxonox\objects\worldentities\CameraPosition.h"
     676                                                >
     677                                        </File>
     678                                        <File
     679                                                RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.h"
     680                                                >
     681                                        </File>
     682                                        <File
     683                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.h"
     684                                                >
     685                                        </File>
     686                                        <File
     687                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.h"
     688                                                >
     689                                        </File>
     690                                        <File
     691                                                RelativePath="..\..\src\orxonox\objects\worldentities\MovableEntity.h"
     692                                                >
     693                                        </File>
     694                                        <File
     695                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleEmitter.h"
     696                                                >
     697                                        </File>
     698                                        <File
     699                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.h"
     700                                                >
     701                                        </File>
     702                                        <File
     703                                                RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.h"
     704                                                >
     705                                        </File>
     706                                        <File
     707                                                RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.h"
     708                                                >
     709                                        </File>
     710                                        <File
     711                                                RelativePath="..\..\src\orxonox\objects\worldentities\WorldEntity.h"
     712                                                >
     713                                        </File>
     714                                        <Filter
     715                                                Name="pawns"
     716                                                >
     717                                                <File
     718                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Pawn.h"
     719                                                        >
     720                                                </File>
     721                                                <File
     722                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\SpaceShip.h"
     723                                                        >
     724                                                </File>
     725                                                <File
     726                                                        RelativePath="..\..\src\orxonox\objects\worldentities\pawns\Spectator.h"
     727                                                        >
     728                                                </File>
     729                                        </Filter>
     730                                        <Filter
     731                                                Name="triggers"
     732                                                >
     733                                                <File
     734                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\DistanceTrigger.h"
     735                                                        >
     736                                                </File>
     737                                                <File
     738                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\EventTrigger.h"
     739                                                        >
     740                                                </File>
     741                                                <File
     742                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.h"
     743                                                        >
     744                                                </File>
     745                                        </Filter>
     746                                </Filter>
     747                                <Filter
     748                                        Name="gametypes"
     749                                        >
     750                                        <File
     751                                                RelativePath="..\..\src\orxonox\objects\gametypes\Gametype.h"
     752                                                >
     753                                        </File>
     754                                </Filter>
     755                                <Filter
     756                                        Name="infos"
     757                                        >
     758                                        <File
     759                                                RelativePath="..\..\src\orxonox\objects\infos\Info.h"
     760                                                >
     761                                        </File>
     762                                        <File
     763                                                RelativePath="..\..\src\orxonox\objects\infos\Level.h"
     764                                                >
     765                                        </File>
     766                                        <File
     767                                                RelativePath="..\..\src\orxonox\objects\infos\PlayerInfo.h"
     768                                                >
     769                                        </File>
     770                                </Filter>
     771                                <Filter
     772                                        Name="controllers"
     773                                        >
     774                                        <File
     775                                                RelativePath="..\..\src\orxonox\objects\controllers\Controller.h"
     776                                                >
     777                                        </File>
     778                                        <File
     779                                                RelativePath="..\..\src\orxonox\objects\controllers\HumanController.h"
     780                                                >
     781                                        </File>
     782                                </Filter>
    657783                        </Filter>
    658784                        <Filter
     
    664790                                </File>
    665791                                <File
    666                                         RelativePath="..\..\src\orxonox\tools\Light.h"
    667                                         >
    668                                 </File>
    669                                 <File
    670792                                        RelativePath="..\..\src\orxonox\tools\Mesh.h"
    671793                                        >
     
    714836                                        Name="hud"
    715837                                        >
     838                                        <File
     839                                                RelativePath="..\..\src\orxonox\overlays\hud\ChatOverlay.h"
     840                                                >
     841                                        </File>
    716842                                        <File
    717843                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h"
  • code/trunk/visual_studio/vc8/orxonox.vcproj.user

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/orxonox.vsprops

    r1897 r2087  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2"
    11                 PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;LUA_BUILD_AS_DLL"
     10                AdditionalOptions="/MP2 /Zm200"
     11                PreprocessorDefinitions="ORXONOX_NO_EXPORTS;ORXONOX_ENABLE_PCH;LUA_BUILD_AS_DLL"
    1212                UsePrecompiledHeader="2"
    1313                PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
     
    2222                Name="VCPostBuildEventTool"
    2323                Description="Copying files from init folder..."
    24                 CommandLine="for %%a in ($(RootDir)\init\$(SolutionName)\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\init\common\*) do replace %%a $(OutDir). /A &gt;nul"
     24                CommandLine="for %%a in ($(RootDir)\init\$(SolutionName)\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\init\common\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
    2525        />
    2626</VisualStudioPropertySheet>
  • code/trunk/visual_studio/vc8/orxonox_vc8.sln

  • code/trunk/visual_studio/vc8/release.vsprops

  • code/trunk/visual_studio/vc8/tinyxml.vcproj

  • code/trunk/visual_studio/vc8/tinyxml.vsprops

  • code/trunk/visual_studio/vc8/tolua.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/tolua.vsprops

  • code/trunk/visual_studio/vc8/tolua_static.vcproj

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/tolua_static.vsprops

    • Property svn:eol-style set to native
  • code/trunk/visual_studio/vc8/toluagen.vcproj

  • code/trunk/visual_studio/vc8/toluagen.vsprops

  • code/trunk/visual_studio/vc8/toluagen_orxonox.vcproj

  • code/trunk/visual_studio/vc8/toluagen_orxonox.vsprops

  • code/trunk/visual_studio/vc8/util.vcproj

    • Property svn:eol-style set to native
    r1841 r2087  
    181181                        </File>
    182182                        <File
     183                                RelativePath="..\..\src\util\SignalHandler.cc"
     184                                >
     185                        </File>
     186                        <File
    183187                                RelativePath="..\..\src\util\String.cc"
    184188                                >
     
    227231                        </File>
    228232                        <File
     233                                RelativePath="..\..\src\util\MathConvert.h"
     234                                >
     235                        </File>
     236                        <File
    229237                                RelativePath="..\..\src\util\MultiType.h"
    230238                                >
     
    244252                        <File
    245253                                RelativePath="..\..\src\util\OutputHandler.h"
     254                                >
     255                        </File>
     256                        <File
     257                                RelativePath="..\..\src\util\SignalHandler.h"
    246258                                >
    247259                        </File>
  • code/trunk/visual_studio/vc8/util.vsprops

Note: See TracChangeset for help on using the changeset viewer.