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:
2 deleted
66 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r5781 r5929  
    2727################ Sub Directories ################
    2828
    29 ADD_SUBDIRECTORY(gamestates)
    3029ADD_SUBDIRECTORY(objects)
    3130ADD_SUBDIRECTORY(overlays)
  • 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
  • code/trunk/src/modules/overlays/FadeoutText.cc

    r5781 r5929  
    4646
    4747        this->bFadingOut_ = false;
    48         this->fadeouttimer_.setTimer(3.0f, false, this, createExecutor(createFunctor(&FadeoutText::fadeout)));
     48        this->fadeouttimer_.setTimer(3.0f, false, createExecutor(createFunctor(&FadeoutText::fadeout, this)));
    4949        this->fadeouttimer_.stopTimer();
    5050
  • code/trunk/src/modules/overlays/FadeoutText.h

    r5781 r5929  
    6868
    6969            bool bFadingOut_;
    70             Timer<FadeoutText> fadeouttimer_;
     70            Timer fadeouttimer_;
    7171
    7272            float initialAlpha_;
  • code/trunk/src/modules/overlays/OverlaysPrereqs.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 overlays module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
     39#include "OrxonoxPrereqs.h"
    3840
    3941//-----------------------------------------------------------------------
    4042// Shared library settings
    4143//-----------------------------------------------------------------------
     44
    4245#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4346#  ifdef OVERLAYS_SHARED_BUILD
     
    6265namespace orxonox
    6366{
    64     class BarColour;
     67    class FadeoutText;
     68    class GUIOverlay;
     69    class OverlayText;
     70
     71    // debugging
    6572    class DebugFPSText;
    6673    class DebugRTRText;
    67     class GUIOverlay;
     74
     75    // hud
     76    class AnnounceMessage;
     77    class BarColour;
     78    class ChatOverlay;
     79    class DeathMessage;
     80    class GametypeStatus;
    6881    class HUDBar;
     82    class HUDHealthBar;
    6983    class HUDNavigation;
    7084    class HUDRadar;
    7185    class HUDSpeedBar;
    72     class HUDHealthBar;
    7386    class HUDTimer;
    74     class OrxonoxOverlay;
    75     class OverlayGroup;
    76     class OverlayText;
    77     class FadeoutText;
    78     class GametypeStatus;
    79     class AnnounceMessage;
    8087    class KillMessage;
    81     class DeathMessage;
     88    class TeamBaseMatchScore;
     89    class UnderAttackHealthBar;
    8290
     91    // stats
    8392    class CreateLines;
    8493    class Scoreboard;
  • code/trunk/src/modules/overlays/hud/ChatOverlay.cc

    r5781 r5929  
    5858    ChatOverlay::~ChatOverlay()
    5959    {
     60        for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it)
     61            delete (*it);
    6062    }
    6163
     
    8789        COUT(0) << "Chat: " << text << std::endl;
    8890
    89         new Timer<ChatOverlay>(this->displayTime_, false, this, createExecutor(createFunctor(&ChatOverlay::dropMessage)), true);
     91        Timer* timer = new Timer();
     92        this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
     93        Executor* executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
     94        executor->setDefaultValues(timer);
     95        timer->setTimer(this->displayTime_, false, executor, true);
    9096
    9197        this->updateOverlayText();
    9298    }
    9399
    94     void ChatOverlay::dropMessage()
     100    void ChatOverlay::dropMessage(Timer* timer)
    95101    {
    96102        if (this->messages_.size() > 0)
    97103            this->messages_.pop_front();
    98104        this->updateOverlayText();
     105        this->timers_.erase(timer); // the timer destroys itself, but we have to remove it from the set
    99106    }
    100107
  • code/trunk/src/modules/overlays/hud/ChatOverlay.h

    r5781 r5929  
    5555        private:
    5656            void updateOverlayText();
    57             void dropMessage();
     57            void dropMessage(Timer* timer);
    5858
    5959            float displayTime_;
     60            std::set<Timer*> timers_;
    6061    };
    6162}
  • code/trunk/src/modules/overlays/hud/HUDBar.cc

    r5781 r5929  
    9696    {
    9797        if (this->isInitialized())
     98        {
    9899            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
     100            for (std::vector<BarColour*>::const_iterator it = this->barColours_.begin(); it != this->barColours_.end(); )
     101                (*it++)->destroy();
     102        }
    99103    }
    100104
  • code/trunk/src/modules/overlays/hud/HUDHealthBar.cc

    r5781 r5929  
    5656    {
    5757        if (this->isInitialized())
    58             delete this->textoverlay_;
     58            this->textoverlay_->destroy();
    5959    }
    6060
     
    8484            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
    8585            this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
     86        }
     87        else
     88        {
     89            this->setValue(0);
     90            this->textoverlay_->setCaption("0");
    8691        }
    8792
  • code/trunk/src/modules/overlays/hud/HUDHealthBar.h

    r5781 r5929  
    111111
    112112        private:
    113             Pawn* owner_;
     113            WeakPtr<Pawn> owner_;
    114114            OverlayText* textoverlay_;
    115115            bool bUseBarColour_;
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r5781 r5929  
    3939#include "core/CoreIncludes.h"
    4040#include "core/XMLPort.h"
     41#include "Scene.h"
    4142#include "Radar.h"
    4243
     
    130131        SUPER(HUDNavigation, tick, dt);
    131132
    132         if (!Radar::getInstance().getFocus())
     133        // Get radar
     134        Radar* radar = this->getOwner()->getScene()->getRadar();
     135
     136        if (!radar->getFocus())
    133137        {
    134138            this->overlay_->hide();
     
    150154*/
    151155        // transform to screen coordinates
    152         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
     156        Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();
    153157
    154158        bool outOfView;
  • code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc

    r5781 r5929  
    118118
    119119        if (this->getOwner() && this->getOwner()->getGametype())
    120             this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
     120            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get());
    121121        else
    122122            this->owner_ = 0;
  • code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc

    r5781 r5929  
    5252        this->text_->setPickPoint(Vector2(0.5, 0));
    5353
    54         this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init)));
     54        this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this)));
    5555    }
    5656
     
    5858    {
    5959        if (this->isInitialized())
    60             delete this->text_;
     60            this->text_->destroy();
    6161    }
    6262
     
    7878            this->owner_ = player;
    7979
    80             UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype());
     80            UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get());
    8181            if (ua)
    8282            {
  • code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h

    r5781 r5929  
    6262            PlayerInfo* owner_;
    6363            OverlayText* text_;
    64             Timer<UnderAttackHealthBar> inittimer_;
     64            Timer inittimer_;
    6565    };
    6666}
  • code/trunk/src/modules/overlays/stats/CreateLines.cc

    r5781 r5929  
    5959    CreateLines::~CreateLines()
    6060    {
    61         delete this->playerNameText_;
    62         delete this->scoreText_;
    63         delete this->deathsText_;
    64         delete this->background_;
     61        this->playerNameText_->destroy();
     62        this->scoreText_->destroy();
     63        this->deathsText_->destroy();
     64        this->background_->destroy();
    6565    }
    6666
  • code/trunk/src/modules/overlays/stats/Scoreboard.cc

    r5781 r5929  
    4444    {
    4545        RegisterObject(Scoreboard);
     46    }
     47
     48    Scoreboard::~Scoreboard()
     49    {
     50        while (this->lines_.size() > 0)
     51        {
     52            // destroy lines
     53            delete this->lines_.back();
     54            this->lines_.pop_back();
     55        }
    4656    }
    4757
  • code/trunk/src/modules/overlays/stats/Scoreboard.h

    r5781 r5929  
    4242    public: // functions
    4343        Scoreboard(BaseObject* creator);
    44         virtual ~Scoreboard() {}
     44        virtual ~Scoreboard();
    4545
    4646        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
  • code/trunk/src/modules/pong/CMakeLists.txt

    r5781 r5929  
    11SET_SOURCE_FILES(PONG_SRC_FILES
     2COMPILATION_BEGIN PongCompilation.cc
    23  Pong.cc
    34  PongAI.cc
     
    78  PongCenterpoint.cc
    89  PongScore.cc
     10COMPILATION_END
    911)
    1012
     
    1214  MODULE
    1315  FIND_HEADER_FILES
    14   PCH_FILE
    15     PongPrecompiledHeaders.h
    16   PCH_NO_DEFAULT
    1716  DEFINE_SYMBOL
    1817    "PONG_SHARED_BUILD"
  • code/trunk/src/modules/pong/Pong.cc

    r5781 r5929  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/EventIncludes.h"
    3233#include "core/Executor.h"
    3334#include "PongCenterpoint.h"
     
    3940namespace orxonox
    4041{
     42    CreateEventName(PongCenterpoint, right);
     43    CreateEventName(PongCenterpoint, left);
     44   
    4145    CreateUnloadableFactory(Pong);
    4246
     
    5256        this->setHUDTemplate("PongHUD");
    5357
    54         this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall)));
     58        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this)));
    5559        this->starttimer_.stopTimer();
    5660
     
    7276            this->ball_->setFieldDimension(this->center_->getFieldDimension());
    7377            this->ball_->setSpeed(0);
     78            this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());
    7479            this->ball_->setBatLength(this->center_->getBatLength());
    7580
     
    120125        if (this->ball_)
    121126        {
    122             delete this->ball_;
     127            this->ball_->destroy();
    123128            this->ball_ = 0;
    124129        }
     
    155160        if (this->center_)
    156161        {
    157             this->center_->fireEvent();
    158 
     162            if (player == this->getRightPlayer())
     163                this->center_->fireEvent(FireEventName(PongCenterpoint, right));
     164            else if (player == this->getLeftPlayer())
     165                this->center_->fireEvent(FireEventName(PongCenterpoint, left));
     166           
    159167            if (player)
    160                 this->gtinfo_.sendAnnounceMessage(player->getName() + " scored");
     168                this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
    161169        }
    162170
     
    165173            this->ball_->setPosition(Vector3::ZERO);
    166174            this->ball_->setVelocity(Vector3::ZERO);
     175            this->ball_->setAcceleration(Vector3::ZERO);
    167176            this->ball_->setSpeed(0);
    168177        }
  • code/trunk/src/modules/pong/Pong.h

    r5781 r5929  
    6262            PongBall* ball_;
    6363            PongBat* bat_[2];
    64             Timer<Pong> starttimer_;
     64            Timer starttimer_;
    6565    };
    6666}
  • code/trunk/src/modules/pong/PongAI.cc

    r5781 r5929  
    4949        this->ballEndPosition_ = 0;
    5050        this->randomOffset_ = 0;
     51        this->bChangedRandomOffset_ = false;
    5152        this->relHysteresisOffset_ = 0.02f;
    5253        this->strength_ = 0.5f;
     
    6061    PongAI::~PongAI()
    6162    {
    62         for (std::list<std::pair<Timer<PongAI>*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
    63             delete (*it).first;
     63        for (std::list<std::pair<Timer*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
     64            (*it).first->destroy();
    6465    }
    6566
     
    113114                this->ballEndPosition_ = 0;
    114115                this->randomOffset_ = 0;
     116                this->bChangedRandomOffset_ = false;
    115117
    116118                this->calculateRandomOffset();
     
    129131                this->bOscillationAvoidanceActive_ = false;
    130132            }
     133           
     134            // If the ball is close enough, calculate another random offset to accelerate the ball
     135            if (!this->bChangedRandomOffset_)
     136            {
     137                float timetohit = (-this->ball_->getPosition().x + this->ball_->getFieldDimension().x / 2 * sgn(this->ball_->getVelocity().x)) / this->ball_->getVelocity().x;
     138                if (timetohit < 0.05)
     139                {
     140                    this->bChangedRandomOffset_ = true;
     141                    if (rnd() < this->strength_)
     142                        this->calculateRandomOffset();
     143                }
     144            }
    131145
    132146            // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat)
     
    184198        Vector3 position = this->ball_->getPosition();
    185199        Vector3 velocity = this->ball_->getVelocity();
     200        Vector3 acceleration = this->ball_->getAcceleration();
    186201        Vector2 dimension = this->ball_->getFieldDimension();
    187202
    188         // calculate end-height: current height + slope * distance
    189         this->ballEndPosition_ = position.z + velocity.z / velocity.x * (-position.x + dimension.x / 2 * sgn(velocity.x));
    190 
    191         // Calculate bounces
    192         for (float limit = 0.35f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
    193         {
    194             // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
    195             float randomError = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
    196 
    197             // Bounce from the lower bound
    198             if (this->ballEndPosition_ > dimension.y / 2)
    199             {
    200                 // Mirror the predicted position at the upper bound and add some random error
    201                 this->ballEndPosition_ = dimension.y - this->ballEndPosition_ + randomError;
    202                 continue;
    203             }
    204             // Bounce from the upper bound
    205             if (this->ballEndPosition_ < -dimension.y / 2)
    206             {
    207                 // Mirror the predicted position at the lower bound and add some random error
    208                 this->ballEndPosition_ = -dimension.y - this->ballEndPosition_ + randomError;
    209                 continue;
    210             }
    211             // No bounce - break
    212             break;
     203        // Calculate bounces. The number of predicted bounces is limited by the AIs strength
     204        for (float limit = -0.05f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
     205        {
     206            // calculate the time until the ball reaches the other side
     207            float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x;
     208           
     209            // calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2)
     210            float bouncetime = totaltime;
     211            bool bUpperWall = false;
     212           
     213            if (acceleration.z == 0)
     214            {
     215                if (velocity.z > 0)
     216                {
     217                    bUpperWall = true;
     218                    bouncetime = (dimension.y/2 - position.z) / velocity.z;
     219                }
     220                else if (velocity.z < 0)
     221                {
     222                    bUpperWall = false;
     223                    bouncetime = (-dimension.y/2 - position.z) / velocity.z;
     224                }
     225            }
     226            else
     227            {
     228                // upper wall
     229                float temp = velocity.z*velocity.z + 2*acceleration.z*(dimension.y/2 - position.z);
     230                if (temp >= 0)
     231                {
     232                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
     233                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
     234                    if (t1 > 0 && t1 < bouncetime)
     235                    {
     236                        bouncetime = t1;
     237                        bUpperWall = true;
     238                    }
     239                    if (t2 > 0 && t2 < bouncetime)
     240                    {
     241                        bouncetime = t2;
     242                        bUpperWall = true;
     243                    }
     244                }
     245                // lower wall
     246                temp = velocity.z*velocity.z - 2*acceleration.z*(dimension.y/2 + position.z);
     247                if (temp >= 0)
     248                {
     249                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
     250                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
     251                    if (t1 > 0 && t1 < bouncetime)
     252                    {
     253                        bouncetime = t1;
     254                        bUpperWall = false;
     255                    }
     256                    if (t2 > 0 && t2 < bouncetime)
     257                    {
     258                        bouncetime = t2;
     259                        bUpperWall = false;
     260                    }
     261                }
     262            }
     263
     264            if (bouncetime < totaltime)
     265            {
     266                // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
     267                float randomErrorX = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
     268                float randomErrorZ = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
     269
     270                // ball bounces after <bouncetime> seconds, update the position and continue
     271                velocity.z = velocity.z + acceleration.z * bouncetime;
     272               
     273                if (bUpperWall)
     274                {
     275                    position.z = dimension.y / 2;
     276                    velocity.z = -fabs(velocity.z) + fabs(randomErrorZ);
     277                }
     278                else
     279                {
     280                    position.z = -dimension.y / 2;
     281                    velocity.z = fabs(velocity.z) - fabs(randomErrorZ);
     282                }
     283                   
     284                position.x = position.x + velocity.x * bouncetime + randomErrorX;
     285                this->ballEndPosition_ = position.z;
     286            }
     287            else
     288            {
     289                // ball doesn't bounce, calculate the end position and return
     290                // calculate end-height: current height + slope * distance incl. acceleration
     291                this->ballEndPosition_ = position.z + velocity.z * totaltime + acceleration.z / 2 * totaltime * totaltime;
     292                return;
     293            }
    213294        }
    214295    }
     
    231312
    232313            // Add a new Timer
    233             Timer<PongAI>* timer = new Timer<PongAI>(delay, false, this, createExecutor(createFunctor(&PongAI::delayedMove)));
    234             this->reactionTimers_.push_back(std::pair<Timer<PongAI>*, char>(timer, direction));
     314            Timer* timer = new Timer(delay, false, createExecutor(createFunctor(&PongAI::delayedMove, this)));
     315            this->reactionTimers_.push_back(std::pair<Timer*, char>(timer, direction));
    235316        }
    236317        else
     
    246327
    247328        // Destroy the timer and remove it from the list
    248         Timer<PongAI>* timer = this->reactionTimers_.front().first;
    249         delete timer;
     329        Timer* timer = this->reactionTimers_.front().first;
     330        timer->destroy();
    250331
    251332        this->reactionTimers_.pop_front();
  • code/trunk/src/modules/pong/PongAI.h

    r5781 r5929  
    6262            float ballEndPosition_;
    6363            float randomOffset_;
     64            bool bChangedRandomOffset_;
    6465            float relHysteresisOffset_;
    6566            float strength_;
    6667
    67             std::list<std::pair<Timer<PongAI>*, char> > reactionTimers_;
     68            std::list<std::pair<Timer*, char> > reactionTimers_;
    6869            char movement_;
    6970            char oldMove_;
  • code/trunk/src/modules/pong/PongBall.cc

    r5781 r5929  
    3333#include "gametypes/Gametype.h"
    3434#include "PongBat.h"
    35 #include "sound/SoundBase.h"
    3635
    3736namespace orxonox
     
    4140    const float PongBall::MAX_REL_Z_VELOCITY = 1.5;
    4241
    43     PongBall::PongBall(BaseObject* creator) : MovableEntity(creator)
     42    PongBall::PongBall(BaseObject* creator)
     43        : MovableEntity(creator)
    4444    {
    4545        RegisterObject(PongBall);
    4646
    4747        this->speed_ = 0;
     48        this->accelerationFactor_ = 1.0f;
    4849        this->bat_ = 0;
    4950        this->batID_ = new unsigned int[2];
     
    5354
    5455        this->registerVariables();
     56    }
    5557
    56         this->sidesound_ = new SoundBase(this);
    57         this->sidesound_->loadFile("sounds/pong_side.wav");
    58 
    59         this->batsound_ = new SoundBase(this);
    60         this->batsound_->loadFile("sounds/pong_bat.wav");
    61 
    62         this->scoresound_ = new SoundBase(this);
    63         this->scoresound_->loadFile("sounds/pong_score.wav");
     58    PongBall::~PongBall()
     59    {
    6460    }
    6561
     
    7975        SUPER(PongBall, tick, dt);
    8076
    81         if (GameMode::isMaster())
     77        Vector3 position = this->getPosition();
     78        Vector3 velocity = this->getVelocity();
     79        Vector3 acceleration = this->getAcceleration();
     80
     81        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    8282        {
    83             Vector3 position = this->getPosition();
    84             Vector3 velocity = this->getVelocity();
     83            velocity.z = -velocity.z;
     84            if (position.z > this->fieldHeight_ / 2)
     85                position.z = this->fieldHeight_ / 2;
     86            if (position.z < -this->fieldHeight_ / 2)
     87                position.z = -this->fieldHeight_ / 2;
    8588
    86             if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     89            this->fireEvent();
     90        }
     91
     92        if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     93        {
     94            float distance = 0;
     95
     96            if (this->bat_)
    8797            {
    88                 velocity.z = -velocity.z;
    89                 this->sidesound_->play();
    90 
    91                 if (position.z > this->fieldHeight_ / 2)
    92                     position.z = this->fieldHeight_ / 2;
    93                 if (position.z < -this->fieldHeight_ / 2)
    94                     position.z = -this->fieldHeight_ / 2;
    95             }
    96 
    97             if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    98             {
    99                 float distance = 0;
    100 
    101                 if (this->bat_)
     98                if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
    10299                {
    103                     if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
     100                    distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     101                    if (fabs(distance) <= 1)
    104102                    {
    105                         distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    106                         if (fabs(distance) <= 1)
     103                        position.x = this->fieldWidth_ / 2;
     104                        velocity.x = -velocity.x;
     105                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     106                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
     107                       
     108                        this->fireEvent();
     109                    }
     110                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     111                    {
     112                        if (this->getGametype() && this->bat_[0])
    107113                        {
    108                             position.x = this->fieldWidth_ / 2;
    109                             velocity.x = -velocity.x;
    110                             velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    111                             this->batsound_->play();
    112                         }
    113                         else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    114                         {
    115                             if (this->getGametype() && this->bat_[0])
    116                             {
    117                                 this->getGametype()->playerScored(this->bat_[0]->getPlayer());
    118                                 this->scoresound_->play();
    119                                 return;
    120                             }
     114                            this->getGametype()->playerScored(this->bat_[0]->getPlayer());
     115                            return;
    121116                        }
    122117                    }
    123                     if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     118                }
     119                if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     120                {
     121                    distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     122                    if (fabs(distance) <= 1)
    124123                    {
    125                         distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    126                         if (fabs(distance) <= 1)
     124                        position.x = -this->fieldWidth_ / 2;
     125                        velocity.x = -velocity.x;
     126                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     127                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
     128
     129                        this->fireEvent();
     130                    }
     131                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     132                    {
     133                        if (this->getGametype() && this->bat_[1])
    127134                        {
    128                             position.x = -this->fieldWidth_ / 2;
    129                             velocity.x = -velocity.x;
    130                             velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    131                             this->batsound_->play();
    132                         }
    133                         else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    134                         {
    135                             if (this->getGametype() && this->bat_[1])
    136                             {
    137                                 this->scoresound_->play();
    138                                 this->getGametype()->playerScored(this->bat_[1]->getPlayer());
    139                                 return;
    140                             }
     135                            this->getGametype()->playerScored(this->bat_[1]->getPlayer());
     136                            return;
    141137                        }
    142138                    }
    143139                }
    144140            }
     141        }
    145142
    146             if (velocity != this->getVelocity())
    147                 this->setVelocity(velocity);
    148             if (position != this->getPosition())
    149                 this->setPosition(position);
    150         }
    151         else
    152         {
    153           Vector3 position = this->getPosition();
    154           Vector3 velocity = this->getVelocity();
    155 
    156           if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    157           {
    158             velocity.z = -velocity.z;
    159             this->sidesound_->play();
    160 
    161             if (position.z > this->fieldHeight_ / 2)
    162               position.z = this->fieldHeight_ / 2;
    163             if (position.z < -this->fieldHeight_ / 2)
    164               position.z = -this->fieldHeight_ / 2;
    165           }
    166 
    167           if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    168           {
    169             float distance = 0;
    170 
    171             if (this->bat_)
    172             {
    173               if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
    174               {
    175                 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    176                 if (fabs(distance) <= 1)
    177                 {
    178                   position.x = this->fieldWidth_ / 2;
    179                   velocity.x = -velocity.x;
    180                   this->batsound_->play();
    181                   velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    182                 }
    183               }
    184               if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
    185               {
    186                 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    187                 if (fabs(distance) <= 1)
    188                 {
    189                   position.x = -this->fieldWidth_ / 2;
    190                   velocity.x = -velocity.x;
    191                   this->batsound_->play();
    192                   velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    193                 }
    194               }
    195             }
    196           }
    197 
    198           if (velocity != this->getVelocity())
     143        if (acceleration != this->getAcceleration())
     144            this->setAcceleration(acceleration);
     145        if (velocity != this->getVelocity())
    199146            this->setVelocity(velocity);
    200           if (position != this->getPosition())
     147        if (position != this->getPosition())
    201148            this->setPosition(position);
    202         }
    203149    }
    204150
  • code/trunk/src/modules/pong/PongBall.h

    r5781 r5929  
    4141        public:
    4242            PongBall(BaseObject* creator);
    43             virtual ~PongBall() {}
     43            virtual ~PongBall();
    4444
    4545            virtual void tick(float dt);
     
    5858                { return this->speed_; }
    5959
     60            void setAccelerationFactor(float factor)
     61                { this->accelerationFactor_ = factor; }
     62            float getAccelerationFactor() const
     63                { return this->accelerationFactor_; }
     64
    6065            void setBatLength(float batlength)
    6166                { this->batlength_ = batlength; }
     
    7277            float fieldHeight_;
    7378            float speed_;
     79            float accelerationFactor_;
    7480            float batlength_;
    7581            PongBat** bat_;
    7682            unsigned int* batID_;
    7783            float relMercyOffset_;
    78 
    79             SoundBase* sidesound_;
    80             SoundBase* batsound_;
    81             SoundBase* scoresound_;
    8284    };
    8385}
  • code/trunk/src/modules/pong/PongCenterpoint.cc

    r5781 r5929  
    4444        this->height_ = 120;
    4545        this->ballspeed_ = 100;
     46        this->ballaccfactor_ = 1.0;
    4647        this->batspeed_ = 60;
    4748        this->batlength_ = 0.25;
     
    5859        XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode);
    5960        XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
     61        XMLPortParam(PongCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
    6062        XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
    6163        XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
     
    7375        if (this->getGametype() && this->getGametype()->isA(Class(Pong)))
    7476        {
    75             Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype());
     77            Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get());
    7678            pong_gametype->setCenterpoint(this);
    7779        }
  • code/trunk/src/modules/pong/PongCenterpoint.h

    r5781 r5929  
    6868                { return this->ballspeed_; }
    6969
     70            void setBallAccelerationFactor(float ballaccfactor)
     71                { this->ballaccfactor_ = ballaccfactor; }
     72            float getBallAccelerationFactor() const
     73                { return this->ballaccfactor_; }
     74
    7075            void setBatSpeed(float batspeed)
    7176                { this->batspeed_ = batspeed; }
     
    8590
    8691            float ballspeed_;
     92            float ballaccfactor_;
    8793            float batspeed_;
    8894            float batlength_;
  • code/trunk/src/modules/pong/PongPrereqs.h

    r5794 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 pong module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
     39#include "OrxonoxPrereqs.h"
    3840
    3941//-----------------------------------------------------------------------
    4042// Shared library settings
    4143//-----------------------------------------------------------------------
     44
    4245#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4346#  ifdef PONG_SHARED_BUILD
  • code/trunk/src/modules/pong/PongScore.cc

    r5781 r5929  
    133133
    134134        if (this->getOwner() && this->getOwner()->getGametype())
    135             this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype());
     135            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    136136        else
    137137            this->owner_ = 0;
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.cc

    r5781 r5929  
    7575        XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode);
    7676
     77        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
     78
    7779        COUT(3) << "New QuestEffectBeacon created." << std::endl;
    7880    }
    7981
    80     /**
    81     @brief
    82         Processes an event for this QuestEffectBeacon.
    83     */
    84     void QuestEffectBeacon::processEvent(Event& event)
    85     {
    86         SUPER(QuestEffectBeacon, processEvent, event);
    87 
    88         ORXONOX_SET_SUBCLASS_EVENT(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
     82    void QuestEffectBeacon::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     83    {
     84        SUPER(QuestEffectBeacon, XMLEventPort, xmlelement, mode);
     85
     86        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
    8987    }
    9088
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.h

    r5781 r5929  
    8686
    8787            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    88 
    89             virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
     88            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    9089
    9190            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
  • code/trunk/src/modules/questsystem/QuestGUI.cc

    r5781 r5929  
    7979       
    8080        if(this->root_ != NULL)
    81             delete this->root_;
     81            this->root_->destroy();
    8282    }
    8383
     
    146146            COUT(3) << "Clearing Node '" << *str << "' ..." << std::endl;
    147147            delete str;
    148             delete node;
     148            node->destroy();
    149149        }
    150150        this->nodes_.clear();
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r5781 r5929  
    4141#include "core/ConsoleCommand.h"
    4242#include "core/LuaState.h"
     43#include "core/ScopedSingletonManager.h"
    4344#include "infos/PlayerInfo.h"
    4445#include "overlays/GUIOverlay.h"
     
    5657    //! Pointer to the current (and single) instance of this class.
    5758    /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
     59    ManageScopedSingleton(QuestManager, ScopeID::Root, false);
    5860
    5961    /**
     
    7678        for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++)
    7779        {
    78             delete (*it).second;
     80            (*it).second->destroy();
    7981        }
    8082        this->questGUIs_.clear();
  • code/trunk/src/modules/questsystem/QuestManager.h

    r5781 r5929  
    4242#include <string>
    4343
    44 #include "util/ScopedSingleton.h"
     44#include "util/Singleton.h"
    4545#include "core/OrxonoxClass.h"
    4646
     
    5050namespace orxonox
    5151{
    52 
    53     typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua
    54 
    5552    /**
    5653    @brief
     
    6057        Damian 'Mozork' Frick
    6158    */
    62     class _QuestsystemExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass
    63     {
     59    class _QuestsystemExport QuestManager
    6460// tolua_end
     61        : public Singleton<QuestManager>, public orxonox::OrxonoxClass
     62    { // tolua_export
    6563
    66             friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
     64            friend class Singleton<QuestManager>;
    6765            friend class QuestGUI;
    6866
     
    7270
    7371            //! Returns a reference to the single instance of the Quest Manager.
    74             static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export
     72            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    7573
    7674            //! Retreive the main window for the GUI.
  • code/trunk/src/modules/questsystem/QuestsystemPrecompiledHeaders.h

    r5781 r5929  
    5151#include <OgreColourValue.h> // 16
    5252
    53 #include <tinyxml/ticpp.h>        // 14
    54 #include "util/ScopedSingleton.h" // 13
     53#include <tinyxml/ticpp.h>   // 14
     54#include "util/Singleton.h" // 13
    5555
    5656///////////////////////////////////////////
  • code/trunk/src/modules/questsystem/QuestsystemPrereqs.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 questsystem 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 QUESTSYSTEM_SHARED_BUILD
     
    7677    class QuestEffect;
    7778    class QuestEffectBeacon;
     79    class QuestGUI;
    7880    class QuestGUINode;
    79     class QuestGUI;
    8081    class QuestHint;
    8182    class QuestItem;
     
    8384    class QuestManager;
    8485    class QuestNotification;
    85     class Rewardable;
    8686
     87    // notifications
    8788    class Notification;
    88     class NotificationListener;
    8989    class NotificationManager;
    9090    class NotificationOverlay;
  • code/trunk/src/modules/questsystem/notifications/NotificationManager.cc

    r5781 r5929  
    3737
    3838#include "core/CoreIncludes.h"
     39#include "core/ScopedSingletonManager.h"
    3940#include "Notification.h"
    4041#include "interfaces/NotificationListener.h"
     
    4748
    4849    NotificationManager* NotificationManager::singletonPtr_s = NULL;
     50    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
    4951
    5052    /**
  • code/trunk/src/modules/questsystem/notifications/NotificationManager.h

    r5781 r5929  
    4141#include <string>
    4242
    43 #include "util/ScopedSingleton.h"
     43#include "util/Singleton.h"
    4444#include "core/OrxonoxClass.h"
    4545
    4646namespace orxonox
    4747{
    48 
    4948    /**
    5049    @brief
     
    5453        Damian 'Mozork' Frick
    5554    */
    56     class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass
     55    class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    5756    {
    58             friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>;
     57            friend class Singleton<NotificationManager>;
    5958        public:
    6059            NotificationManager();
  • code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc

    r5781 r5929  
    426426        this->containers_.erase(container);
    427427        this->overlays_.erase(container->notification);
    428         delete container->overlay;
     428        container->overlay->destroy();
    429429        delete container;
    430430        this->size_= this->size_-1;
  • code/trunk/src/modules/weapons/MuzzleFlash.cc

    r5781 r5929  
    4141        RegisterObject(MuzzleFlash);
    4242        this->setScale(0.1f);
    43        
    44         this->delayTimer_.setTimer(0.1f, false, this, createExecutor(createFunctor(&MuzzleFlash::destroy)));
    4543
     44        this->delayTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&MuzzleFlash::destroy, this)));
    4645    }
    47 
    48     void MuzzleFlash::destroy()
    49     {
    50         delete this;
    51     }
    52  
    5346}
  • code/trunk/src/modules/weapons/MuzzleFlash.h

    r5781 r5929  
    4343            virtual ~MuzzleFlash() {}
    4444
    45 
    46 
    4745        private:
    48             void destroy();
    49             Timer<MuzzleFlash> delayTimer_;
    50 
     46            Timer delayTimer_;
    5147    };
    5248}
  • code/trunk/src/modules/weapons/WeaponsPrereqs.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 weapons 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 WEAPONS_SHARED_BUILD
     
    6465namespace orxonox
    6566{
    66     class LaserFire;
     67    class MuzzleFlash;
     68
     69    // munitions
     70    class FusionMunition;
     71    class LaserMunition;
     72    class ReplenishingMunition;
     73
     74    // projectiles
     75    class BillboardProjectile;
     76    class LightningGunProjectile;
     77    class ParticleProjectile;
     78    class Projectile;
     79
     80    // weaponmodes
     81    class EnergyDrink;
    6782    class FusionFire;
    6883    class HsW01;
     84    class LaserFire;
    6985    class LightningGun;
    70     class EnergyDrink;
    71 
    72     class Projectile;
    73     class BillboardProjectile;
    74     class ParticleProjectile;
    75     class LightningGunProjectile;
    76 
    77     class ReplenishingMunition;
    78     class LaserMunition;
    79     class FusionMunition;
    80 
    81     class MuzzleFlash;
    8286}
    8387
  • code/trunk/src/modules/weapons/munitions/ReplenishingMunition.cc

    r5781 r5929  
    4444        // replenishIntervall_ and replenishMunitionAmount_ will be set in the constructor of the
    4545        // inheriting class, which comes after this constructor)
    46         this->replenishingTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&ReplenishingMunition::initializeTimer)));
     46        this->replenishingTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&ReplenishingMunition::initializeTimer, this)));
    4747    }
    4848
     
    5050    {
    5151        // Initialize the timer
    52         this->replenishingTimer_.setTimer(this->replenishIntervall_, true, this, createExecutor(createFunctor(&ReplenishingMunition::replenish)));
     52        this->replenishingTimer_.setTimer(this->replenishIntervall_, true, createExecutor(createFunctor(&ReplenishingMunition::replenish, this)));
    5353    }
    5454
  • code/trunk/src/modules/weapons/munitions/ReplenishingMunition.h

    r5781 r5929  
    5151            void initializeTimer();
    5252
    53             Timer<ReplenishingMunition> replenishingTimer_;
     53            Timer replenishingTimer_;
    5454    };
    5555}
  • code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r5781 r5929  
    4242        this->textureIndex_ = 1;
    4343        this->maxTextureIndex_ = 8;
    44         this->textureTimer_.setTimer(0.01f, true, this, createExecutor(createFunctor(&LightningGunProjectile::changeTexture)));
     44        this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
    4545       
    4646        registerVariables();
  • code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.h

    r5781 r5929  
    5050            unsigned int textureIndex_;
    5151            unsigned int maxTextureIndex_;
    52             Timer<LightningGunProjectile> textureTimer_;
     52            Timer textureTimer_;
    5353            std::string materialBase_;
    5454      private:
  • code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc

    r5781 r5929  
    5959        {
    6060            this->detachOgreObject(this->particles_->getParticleSystem());
    61             delete this->particles_;
     61            this->particles_->destroy();
    6262        }
    6363    }
  • code/trunk/src/modules/weapons/projectiles/Projectile.cc

    r5781 r5929  
    6161            this->attachCollisionShape(shape);
    6262
    63             this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
     63            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Projectile::destroyObject, this)));
    6464        }
    6565    }
     
    8484
    8585        if (this->bDestroy_)
    86             delete this;
     86            this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
    8787    }
    8888
     
    9090    {
    9191        if (GameMode::isMaster())
    92             delete this;
     92            this->destroy();
    9393    }
    9494
     
    133133    }
    134134
    135     void Projectile::destroyedPawn(Pawn* pawn)
     135    void Projectile::setOwner(Pawn* owner)
    136136    {
    137         if (this->owner_ == pawn)
    138             this->owner_ = 0;
     137        this->owner_ = owner;
    139138    }
    140139}
  • code/trunk/src/modules/weapons/projectiles/Projectile.h

    r5781 r5929  
    3333
    3434#include "tools/Timer.h"
    35 #include "interfaces/PawnListener.h"
    3635#include "worldentities/MovableEntity.h"
    3736
    3837namespace orxonox
    3938{
    40     class _WeaponsExport Projectile : public MovableEntity, public PawnListener
     39    class _WeaponsExport Projectile : public MovableEntity
    4140    {
    4241        public:
     
    4948            virtual void tick(float dt);
    5049            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    51             virtual void destroyedPawn(Pawn* pawn);
    5250
    5351            inline void setDamage(float damage)
     
    5654                { return this->damage_; }
    5755
    58             inline void setOwner(Pawn* owner)
    59                 { this->owner_ = owner; }
     56            void setOwner(Pawn* owner);
    6057            inline Pawn* getOwner() const
    6158                { return this->owner_; }
    6259
    6360        private:
    64             Pawn* owner_;
     61            WeakPtr<Pawn> owner_;
    6562            float lifetime_;
    6663            float damage_;
    6764            bool bDestroy_;
    68             Timer<Projectile> destroyTimer_;
     65            Timer destroyTimer_;
    6966    };
    7067}
  • code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r5781 r5929  
    5454        this->setMunitionName("FusionMunition");
    5555
    56         this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot)));
     56        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
    5757        this->delayTimer_.stopTimer();
    5858    }
  • code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h

    r5781 r5929  
    5959            float speed_;
    6060            float delay_;
    61             Timer<EnergyDrink> delayTimer_;
     61            Timer delayTimer_;
    6262    };
    6363}
  • code/trunk/src/modules/weapons/weaponmodes/HsW01.cc

    r5781 r5929  
    5454        this->setMunitionName("LaserMunition");
    5555
    56         this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot)));
     56        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
    5757        this->delayTimer_.stopTimer();
    5858    }
  • code/trunk/src/modules/weapons/weaponmodes/HsW01.h

    r5781 r5929  
    5757            float speed_;
    5858            float delay_;
    59             Timer<HsW01> delayTimer_;
     59            Timer delayTimer_;
    6060    };
    6161}
Note: See TracChangeset for help on using the changeset viewer.