Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
15 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/objects/Attacher.cc

    r5781 r5929  
    5353    void Attacher::processEvent(Event& event)
    5454    {
    55         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    56             (*it)->fireEvent(event);
     55        if (this->target_)
     56            this->target_->processEvent(event);
    5757    }
    5858
     
    102102
    103103        for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
     104        {
    104105            if (it->getName() == this->targetname_)
     106            {
     107                this->target_ = *it;
    105108                this->attachToParent(*it);
     109            }
     110        }
    106111    }
    107112
  • code/trunk/src/modules/objects/ObjectsPrereqs.h

    r5781 r5929  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the objects module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
    38 
    3939#include "OrxonoxPrereqs.h"
    4040
     
    4242// Shared library settings
    4343//-----------------------------------------------------------------------
     44
    4445#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4546#  ifdef OBJECTS_SHARED_BUILD
     
    7677
    7778    // eventsystem
     79    class EventDispatcher;
     80    class EventFilter;
    7881    class EventListener;
    79     class EventDispatcher;
     82    class EventName;
    8083    class EventTarget;
    8184
    8285    // triggers
    83     class Trigger;
     86    class CheckPoint;
    8487    class DistanceTrigger;
    8588    class EventTrigger;
    86     class CheckPoint;
     89    class Trigger;
    8790}
    8891
  • code/trunk/src/modules/objects/Planet.cc

    r5781 r5929  
    4747     * @brief Constructor
    4848     */
    49     Planet::Planet(BaseObject* creator): MovableEntity(creator)
     49    Planet::Planet(BaseObject* creator) : MovableEntity(creator)
    5050    {
    5151        RegisterObject(Planet);
     
    6464    void Planet::tick(float dt)
    6565    {
    66         if(!this->isVisible())
     66        if (!this->isVisible())
    6767            return;
    6868
     
    7070        {
    7171            Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
    72             if(activeCamera)
     72            if (activeCamera)
    7373            {
    7474                float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
  • code/trunk/src/modules/objects/eventsystem/CMakeLists.txt

    r5781 r5929  
    11ADD_SOURCE_FILES(OBJECTS_SRC_FILES
    22  EventDispatcher.cc
     3  EventFilter.cc
    34  EventListener.cc
     5  EventName.cc
    46  EventTarget.cc
    57)
  • code/trunk/src/modules/objects/eventsystem/EventDispatcher.cc

    r5781 r5929  
    3232#include "core/EventIncludes.h"
    3333#include "core/XMLPort.h"
    34 #include "EventTarget.h"
    3534
    3635namespace orxonox
     
    4645    {
    4746        if (this->isInitialized())
    48             for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    49                 delete (*it);
     47            for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     48                (*it)->destroy();
    5049    }
    5150
     
    5453        SUPER(EventDispatcher, XMLPort, xmlelement, mode);
    5554
    56         XMLPortObject(EventDispatcher, EventTarget, "targets", addTarget, getTarget, xmlelement, mode);
     55        XMLPortObject(EventDispatcher, BaseObject, "targets", addTarget, getTarget, xmlelement, mode);
     56
     57        // since we need event sources mapped to any state, we have to parse XML by ourselves
     58        this->loadAllEventStates(xmlelement, mode, this, Class(EventDispatcher));
    5759    }
    5860
    5961    void EventDispatcher::processEvent(Event& event)
    6062    {
    61         for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    62             (*it)->fireEvent(event);
     63        for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     64            (*it)->processEvent(event);
    6365    }
    6466
    65     void EventDispatcher::addTarget(EventTarget* target)
     67    void EventDispatcher::addTarget(BaseObject* target)
    6668    {
    6769        this->targets_.push_back(target);
    6870    }
    6971
    70     EventTarget* EventDispatcher::getTarget(unsigned int index) const
     72    BaseObject* EventDispatcher::getTarget(unsigned int index) const
    7173    {
    7274        unsigned int i = 0;
    73         for (std::list<EventTarget*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     75        for (std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    7476        {
    7577            if (i == index)
  • code/trunk/src/modules/objects/eventsystem/EventDispatcher.h

    r5781 r5929  
    4747            virtual void processEvent(Event& event);
    4848
    49             void addTarget(EventTarget* target);
    50             EventTarget* getTarget(unsigned int index) const;
     49            void addTarget(BaseObject* target);
     50            BaseObject* getTarget(unsigned int index) const;
    5151
    5252        private:
    53             std::list<EventTarget*> targets_;
     53            std::list<BaseObject*> targets_;
    5454    };
    5555}
  • code/trunk/src/modules/objects/eventsystem/EventListener.cc

    r5781 r5929  
    6363
    6464        this->bActive_ = true;
    65 
    66         this->fireEvent(event.activate_, event.originator_);
    67 
     65        this->fireEvent(event.activate_, event.originator_, event.name_);
    6866        this->bActive_ = false;
    6967    }
     
    7876        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    7977            if (it->getName() == this->eventName_)
    80                 this->registerAsListener(*it);
     78                this->addEventSource(*it, "");
    8179    }
    8280
     
    8785
    8886        if (object->getName() == this->eventName_)
    89             this->registerAsListener(object);
    90     }
    91 
    92     void EventListener::registerAsListener(BaseObject* object)
    93     {
    94         object->registerEventListener(this, "");
     87            this->addEventSource(object, "");
    9588    }
    9689}
  • code/trunk/src/modules/objects/eventsystem/EventListener.h

    r5781 r5929  
    5454        private:
    5555            virtual void loadedNewXMLName(BaseObject* object);
    56             void registerAsListener(BaseObject* object);
    5756
    5857            std::string eventName_;
  • code/trunk/src/modules/objects/eventsystem/EventTarget.cc

    r5781 r5929  
    2929#include "EventTarget.h"
    3030#include "core/CoreIncludes.h"
     31#include "core/XMLPort.h"
    3132
    3233namespace orxonox
     
    3738    {
    3839        RegisterObject(EventTarget);
     40
     41        this->bActive_ = false;
    3942    }
    4043
     
    4245    {
    4346    }
     47   
     48    void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     49    {
     50        SUPER(EventTarget, XMLPort, xmlelement, mode);
    4451
    45     void EventTarget::changedName()
     52        XMLPortParam(EventTarget, "target", setTargetName, getTargetName, xmlelement, mode);
     53
     54        // since we need event sources mapped to any state, we have to parse XML by ourselves
     55        this->loadAllEventStates(xmlelement, mode, this, Class(EventTarget));
     56    }
     57
     58    void EventTarget::processEvent(Event& event)
    4659    {
    47         SUPER(EventTarget, changedName);
     60        if (this->bActive_)
     61        {
     62            COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl;
     63            return;
     64        }
    4865
     66        this->bActive_ = true;
     67        this->fireEvent(event);
     68        this->bActive_ = false;
     69    }
     70
     71    void EventTarget::setTargetName(const std::string& name)
     72    {
     73        this->target_ = name;
     74       
    4975        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    50             if (it->getName() == this->getName())
    51                 this->addAsEvent(*it);
     76            if (it->getName() == this->target_)
     77                this->addEventTarget(*it);
    5278    }
    5379
    5480    void EventTarget::loadedNewXMLName(BaseObject* object)
    5581    {
    56         if (this->getName() == "")
     82        if (this->target_ == "")
    5783            return;
    5884
    59         if (object->getName() == this->getName())
    60             this->addAsEvent(object);
     85        if (object->getName() == this->target_)
     86            this->addEventTarget(object);
    6187    }
    6288
    63     void EventTarget::addAsEvent(BaseObject* object)
     89    void EventTarget::addEventTarget(BaseObject* object)
    6490    {
    6591        if (object != static_cast<BaseObject*>(this))
    66             object->addEvent(this, "");
     92            object->addEventSource(this, "");
    6793    }
    6894}
  • code/trunk/src/modules/objects/eventsystem/EventTarget.h

    r5781 r5929  
    4242            EventTarget(BaseObject* creator);
    4343            virtual ~EventTarget();
     44           
     45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     46           
     47            virtual void processEvent(Event& event);
    4448
    45             virtual void changedName();
     49            void setTargetName(const std::string& name);
     50            inline const std::string& getTargetName() const
     51                { return this->target_; }
    4652
    4753        private:
    4854            virtual void loadedNewXMLName(BaseObject* object);
    49             void addAsEvent(BaseObject* object);
     55            void addEventTarget(BaseObject* object);
     56           
     57            std::string target_;
     58            bool bActive_;
    5059    };
    5160}
  • code/trunk/src/modules/objects/triggers/CheckPoint.cc

    r5781 r5929  
    8585        DistanceTrigger::triggered(bIsTriggered);
    8686
    87         Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype());
     87        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get());
    8888        if (gametype)
    8989        {
  • code/trunk/src/modules/objects/triggers/EventTrigger.cc

    r5781 r5929  
    4747    }
    4848
    49     void EventTrigger::processEvent(Event& event)
     49    void EventTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    5050    {
    51         SUPER(EventTrigger, processEvent, event);
     51        SUPER(EventTrigger, XMLEventPort, xmlelement, mode);
    5252
    53         ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);
     53        XMLPortEventState(EventTrigger, BaseObject, "trigger", trigger, xmlelement, mode);
    5454    }
    5555
  • code/trunk/src/modules/objects/triggers/EventTrigger.h

    r5781 r5929  
    4141            virtual ~EventTrigger();
    4242
    43             virtual void processEvent(Event& event);
     43            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    4444
    4545            inline void trigger(bool bTriggered)
  • code/trunk/src/modules/objects/triggers/Trigger.cc

    r5781 r5929  
    7272    }
    7373
    74     this->setObjectMode(0x0);
     74    this->setSyncMode(0x0);
    7575  }
    7676
Note: See TracChangeset for help on using the changeset viewer.