Changeset 5929 for code/trunk/src/modules
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 66 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/modules/CMakeLists.txt
r5781 r5929 27 27 ################ Sub Directories ################ 28 28 29 ADD_SUBDIRECTORY(gamestates)30 29 ADD_SUBDIRECTORY(objects) 31 30 ADD_SUBDIRECTORY(overlays) -
code/trunk/src/modules/objects/Attacher.cc
r5781 r5929 53 53 void Attacher::processEvent(Event& event) 54 54 { 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); 57 57 } 58 58 … … 102 102 103 103 for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it) 104 { 104 105 if (it->getName() == this->targetname_) 106 { 107 this->target_ = *it; 105 108 this->attachToParent(*it); 109 } 110 } 106 111 } 107 112 -
code/trunk/src/modules/objects/ObjectsPrereqs.h
r5781 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef OBJECTS_SHARED_BUILD … … 76 77 77 78 // eventsystem 79 class EventDispatcher; 80 class EventFilter; 78 81 class EventListener; 79 class Event Dispatcher;82 class EventName; 80 83 class EventTarget; 81 84 82 85 // triggers 83 class Trigger;86 class CheckPoint; 84 87 class DistanceTrigger; 85 88 class EventTrigger; 86 class CheckPoint;89 class Trigger; 87 90 } 88 91 -
code/trunk/src/modules/objects/Planet.cc
r5781 r5929 47 47 * @brief Constructor 48 48 */ 49 Planet::Planet(BaseObject* creator) : MovableEntity(creator)49 Planet::Planet(BaseObject* creator) : MovableEntity(creator) 50 50 { 51 51 RegisterObject(Planet); … … 64 64 void Planet::tick(float dt) 65 65 { 66 if (!this->isVisible())66 if (!this->isVisible()) 67 67 return; 68 68 … … 70 70 { 71 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 72 if (activeCamera)72 if (activeCamera) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); -
code/trunk/src/modules/objects/eventsystem/CMakeLists.txt
r5781 r5929 1 1 ADD_SOURCE_FILES(OBJECTS_SRC_FILES 2 2 EventDispatcher.cc 3 EventFilter.cc 3 4 EventListener.cc 5 EventName.cc 4 6 EventTarget.cc 5 7 ) -
code/trunk/src/modules/objects/eventsystem/EventDispatcher.cc
r5781 r5929 32 32 #include "core/EventIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "EventTarget.h"35 34 36 35 namespace orxonox … … 46 45 { 47 46 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(); 50 49 } 51 50 … … 54 53 SUPER(EventDispatcher, XMLPort, xmlelement, mode); 55 54 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)); 57 59 } 58 60 59 61 void EventDispatcher::processEvent(Event& event) 60 62 { 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); 63 65 } 64 66 65 void EventDispatcher::addTarget( EventTarget* target)67 void EventDispatcher::addTarget(BaseObject* target) 66 68 { 67 69 this->targets_.push_back(target); 68 70 } 69 71 70 EventTarget* EventDispatcher::getTarget(unsigned int index) const72 BaseObject* EventDispatcher::getTarget(unsigned int index) const 71 73 { 72 74 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) 74 76 { 75 77 if (i == index) -
code/trunk/src/modules/objects/eventsystem/EventDispatcher.h
r5781 r5929 47 47 virtual void processEvent(Event& event); 48 48 49 void addTarget( EventTarget* target);50 EventTarget* getTarget(unsigned int index) const;49 void addTarget(BaseObject* target); 50 BaseObject* getTarget(unsigned int index) const; 51 51 52 52 private: 53 std::list< EventTarget*> targets_;53 std::list<BaseObject*> targets_; 54 54 }; 55 55 } -
code/trunk/src/modules/objects/eventsystem/EventListener.cc
r5781 r5929 63 63 64 64 this->bActive_ = true; 65 66 this->fireEvent(event.activate_, event.originator_); 67 65 this->fireEvent(event.activate_, event.originator_, event.name_); 68 66 this->bActive_ = false; 69 67 } … … 78 76 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 79 77 if (it->getName() == this->eventName_) 80 this-> registerAsListener(*it);78 this->addEventSource(*it, ""); 81 79 } 82 80 … … 87 85 88 86 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, ""); 95 88 } 96 89 } -
code/trunk/src/modules/objects/eventsystem/EventListener.h
r5781 r5929 54 54 private: 55 55 virtual void loadedNewXMLName(BaseObject* object); 56 void registerAsListener(BaseObject* object);57 56 58 57 std::string eventName_; -
code/trunk/src/modules/objects/eventsystem/EventTarget.cc
r5781 r5929 29 29 #include "EventTarget.h" 30 30 #include "core/CoreIncludes.h" 31 #include "core/XMLPort.h" 31 32 32 33 namespace orxonox … … 37 38 { 38 39 RegisterObject(EventTarget); 40 41 this->bActive_ = false; 39 42 } 40 43 … … 42 45 { 43 46 } 47 48 void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 { 50 SUPER(EventTarget, XMLPort, xmlelement, mode); 44 51 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) 46 59 { 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 } 48 65 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 49 75 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 50 if (it->getName() == this-> getName())51 this->add AsEvent(*it);76 if (it->getName() == this->target_) 77 this->addEventTarget(*it); 52 78 } 53 79 54 80 void EventTarget::loadedNewXMLName(BaseObject* object) 55 81 { 56 if (this-> getName()== "")82 if (this->target_ == "") 57 83 return; 58 84 59 if (object->getName() == this-> getName())60 this->add AsEvent(object);85 if (object->getName() == this->target_) 86 this->addEventTarget(object); 61 87 } 62 88 63 void EventTarget::add AsEvent(BaseObject* object)89 void EventTarget::addEventTarget(BaseObject* object) 64 90 { 65 91 if (object != static_cast<BaseObject*>(this)) 66 object->addEvent (this, "");92 object->addEventSource(this, ""); 67 93 } 68 94 } -
code/trunk/src/modules/objects/eventsystem/EventTarget.h
r5781 r5929 42 42 EventTarget(BaseObject* creator); 43 43 virtual ~EventTarget(); 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 47 virtual void processEvent(Event& event); 44 48 45 virtual void changedName(); 49 void setTargetName(const std::string& name); 50 inline const std::string& getTargetName() const 51 { return this->target_; } 46 52 47 53 private: 48 54 virtual void loadedNewXMLName(BaseObject* object); 49 void addAsEvent(BaseObject* object); 55 void addEventTarget(BaseObject* object); 56 57 std::string target_; 58 bool bActive_; 50 59 }; 51 60 } -
code/trunk/src/modules/objects/triggers/CheckPoint.cc
r5781 r5929 85 85 DistanceTrigger::triggered(bIsTriggered); 86 86 87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype() );87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get()); 88 88 if (gametype) 89 89 { -
code/trunk/src/modules/objects/triggers/EventTrigger.cc
r5781 r5929 47 47 } 48 48 49 void EventTrigger:: processEvent(Event& event)49 void EventTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 50 50 { 51 SUPER(EventTrigger, processEvent, event);51 SUPER(EventTrigger, XMLEventPort, xmlelement, mode); 52 52 53 ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);53 XMLPortEventState(EventTrigger, BaseObject, "trigger", trigger, xmlelement, mode); 54 54 } 55 55 -
code/trunk/src/modules/objects/triggers/EventTrigger.h
r5781 r5929 41 41 virtual ~EventTrigger(); 42 42 43 virtual void processEvent(Event& event);43 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 44 44 45 45 inline void trigger(bool bTriggered) -
code/trunk/src/modules/objects/triggers/Trigger.cc
r5781 r5929 72 72 } 73 73 74 this->set ObjectMode(0x0);74 this->setSyncMode(0x0); 75 75 } 76 76 -
code/trunk/src/modules/overlays/FadeoutText.cc
r5781 r5929 46 46 47 47 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))); 49 49 this->fadeouttimer_.stopTimer(); 50 50 -
code/trunk/src/modules/overlays/FadeoutText.h
r5781 r5929 68 68 69 69 bool bFadingOut_; 70 Timer <FadeoutText>fadeouttimer_;70 Timer fadeouttimer_; 71 71 72 72 float initialAlpha_; -
code/trunk/src/modules/overlays/OverlaysPrereqs.h
r5781 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 39 #include "OrxonoxPrereqs.h" 38 40 39 41 //----------------------------------------------------------------------- 40 42 // Shared library settings 41 43 //----------------------------------------------------------------------- 44 42 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 46 # ifdef OVERLAYS_SHARED_BUILD … … 62 65 namespace orxonox 63 66 { 64 class BarColour; 67 class FadeoutText; 68 class GUIOverlay; 69 class OverlayText; 70 71 // debugging 65 72 class DebugFPSText; 66 73 class DebugRTRText; 67 class GUIOverlay; 74 75 // hud 76 class AnnounceMessage; 77 class BarColour; 78 class ChatOverlay; 79 class DeathMessage; 80 class GametypeStatus; 68 81 class HUDBar; 82 class HUDHealthBar; 69 83 class HUDNavigation; 70 84 class HUDRadar; 71 85 class HUDSpeedBar; 72 class HUDHealthBar;73 86 class HUDTimer; 74 class OrxonoxOverlay;75 class OverlayGroup;76 class OverlayText;77 class FadeoutText;78 class GametypeStatus;79 class AnnounceMessage;80 87 class KillMessage; 81 class DeathMessage; 88 class TeamBaseMatchScore; 89 class UnderAttackHealthBar; 82 90 91 // stats 83 92 class CreateLines; 84 93 class Scoreboard; -
code/trunk/src/modules/overlays/hud/ChatOverlay.cc
r5781 r5929 58 58 ChatOverlay::~ChatOverlay() 59 59 { 60 for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it) 61 delete (*it); 60 62 } 61 63 … … 87 89 COUT(0) << "Chat: " << text << std::endl; 88 90 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); 90 96 91 97 this->updateOverlayText(); 92 98 } 93 99 94 void ChatOverlay::dropMessage( )100 void ChatOverlay::dropMessage(Timer* timer) 95 101 { 96 102 if (this->messages_.size() > 0) 97 103 this->messages_.pop_front(); 98 104 this->updateOverlayText(); 105 this->timers_.erase(timer); // the timer destroys itself, but we have to remove it from the set 99 106 } 100 107 -
code/trunk/src/modules/overlays/hud/ChatOverlay.h
r5781 r5929 55 55 private: 56 56 void updateOverlayText(); 57 void dropMessage( );57 void dropMessage(Timer* timer); 58 58 59 59 float displayTime_; 60 std::set<Timer*> timers_; 60 61 }; 61 62 } -
code/trunk/src/modules/overlays/hud/HUDBar.cc
r5781 r5929 96 96 { 97 97 if (this->isInitialized()) 98 { 98 99 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 } 99 103 } 100 104 -
code/trunk/src/modules/overlays/hud/HUDHealthBar.cc
r5781 r5929 56 56 { 57 57 if (this->isInitialized()) 58 delete this->textoverlay_;58 this->textoverlay_->destroy(); 59 59 } 60 60 … … 84 84 this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth()); 85 85 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"); 86 91 } 87 92 -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r5781 r5929 111 111 112 112 private: 113 Pawn*owner_;113 WeakPtr<Pawn> owner_; 114 114 OverlayText* textoverlay_; 115 115 bool bUseBarColour_; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r5781 r5929 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/XMLPort.h" 41 #include "Scene.h" 41 42 #include "Radar.h" 42 43 … … 130 131 SUPER(HUDNavigation, tick, dt); 131 132 132 if (!Radar::getInstance().getFocus()) 133 // Get radar 134 Radar* radar = this->getOwner()->getScene()->getRadar(); 135 136 if (!radar->getFocus()) 133 137 { 134 138 this->overlay_->hide(); … … 150 154 */ 151 155 // transform to screen coordinates 152 Vector3 pos = /*transformationMatrix * */ Radar::getInstance().getFocus()->getRVWorldPosition();156 Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition(); 153 157 154 158 bool outOfView; -
code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
r5781 r5929 118 118 119 119 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()); 121 121 else 122 122 this->owner_ = 0; -
code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc
r5781 r5929 52 52 this->text_->setPickPoint(Vector2(0.5, 0)); 53 53 54 this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init)));54 this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this))); 55 55 } 56 56 … … 58 58 { 59 59 if (this->isInitialized()) 60 delete this->text_;60 this->text_->destroy(); 61 61 } 62 62 … … 78 78 this->owner_ = player; 79 79 80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype() );80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get()); 81 81 if (ua) 82 82 { -
code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h
r5781 r5929 62 62 PlayerInfo* owner_; 63 63 OverlayText* text_; 64 Timer <UnderAttackHealthBar>inittimer_;64 Timer inittimer_; 65 65 }; 66 66 } -
code/trunk/src/modules/overlays/stats/CreateLines.cc
r5781 r5929 59 59 CreateLines::~CreateLines() 60 60 { 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(); 65 65 } 66 66 -
code/trunk/src/modules/overlays/stats/Scoreboard.cc
r5781 r5929 44 44 { 45 45 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 } 46 56 } 47 57 -
code/trunk/src/modules/overlays/stats/Scoreboard.h
r5781 r5929 42 42 public: // functions 43 43 Scoreboard(BaseObject* creator); 44 virtual ~Scoreboard() {}44 virtual ~Scoreboard(); 45 45 46 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); -
code/trunk/src/modules/pong/CMakeLists.txt
r5781 r5929 1 1 SET_SOURCE_FILES(PONG_SRC_FILES 2 COMPILATION_BEGIN PongCompilation.cc 2 3 Pong.cc 3 4 PongAI.cc … … 7 8 PongCenterpoint.cc 8 9 PongScore.cc 10 COMPILATION_END 9 11 ) 10 12 … … 12 14 MODULE 13 15 FIND_HEADER_FILES 14 PCH_FILE15 PongPrecompiledHeaders.h16 PCH_NO_DEFAULT17 16 DEFINE_SYMBOL 18 17 "PONG_SHARED_BUILD" -
code/trunk/src/modules/pong/Pong.cc
r5781 r5929 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/EventIncludes.h" 32 33 #include "core/Executor.h" 33 34 #include "PongCenterpoint.h" … … 39 40 namespace orxonox 40 41 { 42 CreateEventName(PongCenterpoint, right); 43 CreateEventName(PongCenterpoint, left); 44 41 45 CreateUnloadableFactory(Pong); 42 46 … … 52 56 this->setHUDTemplate("PongHUD"); 53 57 54 this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall)));58 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this))); 55 59 this->starttimer_.stopTimer(); 56 60 … … 72 76 this->ball_->setFieldDimension(this->center_->getFieldDimension()); 73 77 this->ball_->setSpeed(0); 78 this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor()); 74 79 this->ball_->setBatLength(this->center_->getBatLength()); 75 80 … … 120 125 if (this->ball_) 121 126 { 122 delete this->ball_;127 this->ball_->destroy(); 123 128 this->ball_ = 0; 124 129 } … … 155 160 if (this->center_) 156 161 { 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 159 167 if (player) 160 this->gtinfo_ .sendAnnounceMessage(player->getName() + " scored");168 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored"); 161 169 } 162 170 … … 165 173 this->ball_->setPosition(Vector3::ZERO); 166 174 this->ball_->setVelocity(Vector3::ZERO); 175 this->ball_->setAcceleration(Vector3::ZERO); 167 176 this->ball_->setSpeed(0); 168 177 } -
code/trunk/src/modules/pong/Pong.h
r5781 r5929 62 62 PongBall* ball_; 63 63 PongBat* bat_[2]; 64 Timer <Pong>starttimer_;64 Timer starttimer_; 65 65 }; 66 66 } -
code/trunk/src/modules/pong/PongAI.cc
r5781 r5929 49 49 this->ballEndPosition_ = 0; 50 50 this->randomOffset_ = 0; 51 this->bChangedRandomOffset_ = false; 51 52 this->relHysteresisOffset_ = 0.02f; 52 53 this->strength_ = 0.5f; … … 60 61 PongAI::~PongAI() 61 62 { 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(); 64 65 } 65 66 … … 113 114 this->ballEndPosition_ = 0; 114 115 this->randomOffset_ = 0; 116 this->bChangedRandomOffset_ = false; 115 117 116 118 this->calculateRandomOffset(); … … 129 131 this->bOscillationAvoidanceActive_ = false; 130 132 } 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 } 131 145 132 146 // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat) … … 184 198 Vector3 position = this->ball_->getPosition(); 185 199 Vector3 velocity = this->ball_->getVelocity(); 200 Vector3 acceleration = this->ball_->getAcceleration(); 186 201 Vector2 dimension = this->ball_->getFieldDimension(); 187 202 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 } 213 294 } 214 295 } … … 231 312 232 313 // 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)); 235 316 } 236 317 else … … 246 327 247 328 // 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(); 250 331 251 332 this->reactionTimers_.pop_front(); -
code/trunk/src/modules/pong/PongAI.h
r5781 r5929 62 62 float ballEndPosition_; 63 63 float randomOffset_; 64 bool bChangedRandomOffset_; 64 65 float relHysteresisOffset_; 65 66 float strength_; 66 67 67 std::list<std::pair<Timer <PongAI>*, char> > reactionTimers_;68 std::list<std::pair<Timer*, char> > reactionTimers_; 68 69 char movement_; 69 70 char oldMove_; -
code/trunk/src/modules/pong/PongBall.cc
r5781 r5929 33 33 #include "gametypes/Gametype.h" 34 34 #include "PongBat.h" 35 #include "sound/SoundBase.h"36 35 37 36 namespace orxonox … … 41 40 const float PongBall::MAX_REL_Z_VELOCITY = 1.5; 42 41 43 PongBall::PongBall(BaseObject* creator) : MovableEntity(creator) 42 PongBall::PongBall(BaseObject* creator) 43 : MovableEntity(creator) 44 44 { 45 45 RegisterObject(PongBall); 46 46 47 47 this->speed_ = 0; 48 this->accelerationFactor_ = 1.0f; 48 49 this->bat_ = 0; 49 50 this->batID_ = new unsigned int[2]; … … 53 54 54 55 this->registerVariables(); 56 } 55 57 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 { 64 60 } 65 61 … … 79 75 SUPER(PongBall, tick, dt); 80 76 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) 82 82 { 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; 85 88 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_) 87 97 { 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]) 102 99 { 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) 104 102 { 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]) 107 113 { 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; 121 116 } 122 117 } 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) 124 123 { 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]) 127 134 { 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; 141 137 } 142 138 } 143 139 } 144 140 } 141 } 145 142 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()) 199 146 this->setVelocity(velocity); 200 147 if (position != this->getPosition()) 201 148 this->setPosition(position); 202 }203 149 } 204 150 -
code/trunk/src/modules/pong/PongBall.h
r5781 r5929 41 41 public: 42 42 PongBall(BaseObject* creator); 43 virtual ~PongBall() {}43 virtual ~PongBall(); 44 44 45 45 virtual void tick(float dt); … … 58 58 { return this->speed_; } 59 59 60 void setAccelerationFactor(float factor) 61 { this->accelerationFactor_ = factor; } 62 float getAccelerationFactor() const 63 { return this->accelerationFactor_; } 64 60 65 void setBatLength(float batlength) 61 66 { this->batlength_ = batlength; } … … 72 77 float fieldHeight_; 73 78 float speed_; 79 float accelerationFactor_; 74 80 float batlength_; 75 81 PongBat** bat_; 76 82 unsigned int* batID_; 77 83 float relMercyOffset_; 78 79 SoundBase* sidesound_;80 SoundBase* batsound_;81 SoundBase* scoresound_;82 84 }; 83 85 } -
code/trunk/src/modules/pong/PongCenterpoint.cc
r5781 r5929 44 44 this->height_ = 120; 45 45 this->ballspeed_ = 100; 46 this->ballaccfactor_ = 1.0; 46 47 this->batspeed_ = 60; 47 48 this->batlength_ = 0.25; … … 58 59 XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode); 59 60 XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode); 61 XMLPortParam(PongCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode); 60 62 XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode); 61 63 XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode); … … 73 75 if (this->getGametype() && this->getGametype()->isA(Class(Pong))) 74 76 { 75 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype() );77 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get()); 76 78 pong_gametype->setCenterpoint(this); 77 79 } -
code/trunk/src/modules/pong/PongCenterpoint.h
r5781 r5929 68 68 { return this->ballspeed_; } 69 69 70 void setBallAccelerationFactor(float ballaccfactor) 71 { this->ballaccfactor_ = ballaccfactor; } 72 float getBallAccelerationFactor() const 73 { return this->ballaccfactor_; } 74 70 75 void setBatSpeed(float batspeed) 71 76 { this->batspeed_ = batspeed; } … … 85 90 86 91 float ballspeed_; 92 float ballaccfactor_; 87 93 float batspeed_; 88 94 float batlength_; -
code/trunk/src/modules/pong/PongPrereqs.h
r5794 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 39 #include "OrxonoxPrereqs.h" 38 40 39 41 //----------------------------------------------------------------------- 40 42 // Shared library settings 41 43 //----------------------------------------------------------------------- 44 42 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 46 # ifdef PONG_SHARED_BUILD -
code/trunk/src/modules/pong/PongScore.cc
r5781 r5929 133 133 134 134 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()); 136 136 else 137 137 this->owner_ = 0; -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r5781 r5929 75 75 XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode); 76 76 77 XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode); 78 77 79 COUT(3) << "New QuestEffectBeacon created." << std::endl; 78 80 } 79 81 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); 89 87 } 90 88 -
code/trunk/src/modules/questsystem/QuestEffectBeacon.h
r5781 r5929 86 86 87 87 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); 90 89 91 90 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. -
code/trunk/src/modules/questsystem/QuestGUI.cc
r5781 r5929 79 79 80 80 if(this->root_ != NULL) 81 delete this->root_;81 this->root_->destroy(); 82 82 } 83 83 … … 146 146 COUT(3) << "Clearing Node '" << *str << "' ..." << std::endl; 147 147 delete str; 148 delete node;148 node->destroy(); 149 149 } 150 150 this->nodes_.clear(); -
code/trunk/src/modules/questsystem/QuestManager.cc
r5781 r5929 41 41 #include "core/ConsoleCommand.h" 42 42 #include "core/LuaState.h" 43 #include "core/ScopedSingletonManager.h" 43 44 #include "infos/PlayerInfo.h" 44 45 #include "overlays/GUIOverlay.h" … … 56 57 //! Pointer to the current (and single) instance of this class. 57 58 /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL; 59 ManageScopedSingleton(QuestManager, ScopeID::Root, false); 58 60 59 61 /** … … 76 78 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++) 77 79 { 78 delete (*it).second;80 (*it).second->destroy(); 79 81 } 80 82 this->questGUIs_.clear(); -
code/trunk/src/modules/questsystem/QuestManager.h
r5781 r5929 42 42 #include <string> 43 43 44 #include "util/S copedSingleton.h"44 #include "util/Singleton.h" 45 45 #include "core/OrxonoxClass.h" 46 46 … … 50 50 namespace orxonox 51 51 { 52 53 typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua54 55 52 /** 56 53 @brief … … 60 57 Damian 'Mozork' Frick 61 58 */ 62 class _QuestsystemExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass 63 { 59 class _QuestsystemExport QuestManager 64 60 // tolua_end 61 : public Singleton<QuestManager>, public orxonox::OrxonoxClass 62 { // tolua_export 65 63 66 friend class S copedSingleton<QuestManager, ScopeID::GSLevel>;64 friend class Singleton<QuestManager>; 67 65 friend class QuestGUI; 68 66 … … 72 70 73 71 //! Returns a reference to the single instance of the Quest Manager. 74 static QuestManager& getInstance() { return S copedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export72 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 75 73 76 74 //! Retreive the main window for the GUI. -
code/trunk/src/modules/questsystem/QuestsystemPrecompiledHeaders.h
r5781 r5929 51 51 #include <OgreColourValue.h> // 16 52 52 53 #include <tinyxml/ticpp.h> 54 #include "util/S copedSingleton.h"// 1353 #include <tinyxml/ticpp.h> // 14 54 #include "util/Singleton.h" // 13 55 55 56 56 /////////////////////////////////////////// -
code/trunk/src/modules/questsystem/QuestsystemPrereqs.h
r5781 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef QUESTSYSTEM_SHARED_BUILD … … 76 77 class QuestEffect; 77 78 class QuestEffectBeacon; 79 class QuestGUI; 78 80 class QuestGUINode; 79 class QuestGUI;80 81 class QuestHint; 81 82 class QuestItem; … … 83 84 class QuestManager; 84 85 class QuestNotification; 85 class Rewardable;86 86 87 // notifications 87 88 class Notification; 88 class NotificationListener;89 89 class NotificationManager; 90 90 class NotificationOverlay; -
code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
r5781 r5929 37 37 38 38 #include "core/CoreIncludes.h" 39 #include "core/ScopedSingletonManager.h" 39 40 #include "Notification.h" 40 41 #include "interfaces/NotificationListener.h" … … 47 48 48 49 NotificationManager* NotificationManager::singletonPtr_s = NULL; 50 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 49 51 50 52 /** -
code/trunk/src/modules/questsystem/notifications/NotificationManager.h
r5781 r5929 41 41 #include <string> 42 42 43 #include "util/S copedSingleton.h"43 #include "util/Singleton.h" 44 44 #include "core/OrxonoxClass.h" 45 45 46 46 namespace orxonox 47 47 { 48 49 48 /** 50 49 @brief … … 54 53 Damian 'Mozork' Frick 55 54 */ 56 class _QuestsystemExport NotificationManager : public S copedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass55 class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass 57 56 { 58 friend class S copedSingleton<NotificationManager, ScopeID::GSLevel>;57 friend class Singleton<NotificationManager>; 59 58 public: 60 59 NotificationManager(); -
code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
r5781 r5929 426 426 this->containers_.erase(container); 427 427 this->overlays_.erase(container->notification); 428 delete container->overlay;428 container->overlay->destroy(); 429 429 delete container; 430 430 this->size_= this->size_-1; -
code/trunk/src/modules/weapons/MuzzleFlash.cc
r5781 r5929 41 41 RegisterObject(MuzzleFlash); 42 42 this->setScale(0.1f); 43 44 this->delayTimer_.setTimer(0.1f, false, this, createExecutor(createFunctor(&MuzzleFlash::destroy)));45 43 44 this->delayTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&MuzzleFlash::destroy, this))); 46 45 } 47 48 void MuzzleFlash::destroy()49 {50 delete this;51 }52 53 46 } -
code/trunk/src/modules/weapons/MuzzleFlash.h
r5781 r5929 43 43 virtual ~MuzzleFlash() {} 44 44 45 46 47 45 private: 48 void destroy(); 49 Timer<MuzzleFlash> delayTimer_; 50 46 Timer delayTimer_; 51 47 }; 52 48 } -
code/trunk/src/modules/weapons/WeaponsPrereqs.h
r5781 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef WEAPONS_SHARED_BUILD … … 64 65 namespace orxonox 65 66 { 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; 67 82 class FusionFire; 68 83 class HsW01; 84 class LaserFire; 69 85 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;82 86 } 83 87 -
code/trunk/src/modules/weapons/munitions/ReplenishingMunition.cc
r5781 r5929 44 44 // replenishIntervall_ and replenishMunitionAmount_ will be set in the constructor of the 45 45 // 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))); 47 47 } 48 48 … … 50 50 { 51 51 // 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))); 53 53 } 54 54 -
code/trunk/src/modules/weapons/munitions/ReplenishingMunition.h
r5781 r5929 51 51 void initializeTimer(); 52 52 53 Timer <ReplenishingMunition>replenishingTimer_;53 Timer replenishingTimer_; 54 54 }; 55 55 } -
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
r5781 r5929 42 42 this->textureIndex_ = 1; 43 43 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))); 45 45 46 46 registerVariables(); -
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.h
r5781 r5929 50 50 unsigned int textureIndex_; 51 51 unsigned int maxTextureIndex_; 52 Timer <LightningGunProjectile>textureTimer_;52 Timer textureTimer_; 53 53 std::string materialBase_; 54 54 private: -
code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
r5781 r5929 59 59 { 60 60 this->detachOgreObject(this->particles_->getParticleSystem()); 61 delete this->particles_;61 this->particles_->destroy(); 62 62 } 63 63 } -
code/trunk/src/modules/weapons/projectiles/Projectile.cc
r5781 r5929 61 61 this->attachCollisionShape(shape); 62 62 63 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));63 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Projectile::destroyObject, this))); 64 64 } 65 65 } … … 84 84 85 85 if (this->bDestroy_) 86 delete this;86 this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick() 87 87 } 88 88 … … 90 90 { 91 91 if (GameMode::isMaster()) 92 delete this;92 this->destroy(); 93 93 } 94 94 … … 133 133 } 134 134 135 void Projectile:: destroyedPawn(Pawn* pawn)135 void Projectile::setOwner(Pawn* owner) 136 136 { 137 if (this->owner_ == pawn) 138 this->owner_ = 0; 137 this->owner_ = owner; 139 138 } 140 139 } -
code/trunk/src/modules/weapons/projectiles/Projectile.h
r5781 r5929 33 33 34 34 #include "tools/Timer.h" 35 #include "interfaces/PawnListener.h"36 35 #include "worldentities/MovableEntity.h" 37 36 38 37 namespace orxonox 39 38 { 40 class _WeaponsExport Projectile : public MovableEntity , public PawnListener39 class _WeaponsExport Projectile : public MovableEntity 41 40 { 42 41 public: … … 49 48 virtual void tick(float dt); 50 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 51 virtual void destroyedPawn(Pawn* pawn);52 50 53 51 inline void setDamage(float damage) … … 56 54 { return this->damage_; } 57 55 58 inline void setOwner(Pawn* owner) 59 { this->owner_ = owner; } 56 void setOwner(Pawn* owner); 60 57 inline Pawn* getOwner() const 61 58 { return this->owner_; } 62 59 63 60 private: 64 Pawn*owner_;61 WeakPtr<Pawn> owner_; 65 62 float lifetime_; 66 63 float damage_; 67 64 bool bDestroy_; 68 Timer <Projectile>destroyTimer_;65 Timer destroyTimer_; 69 66 }; 70 67 } -
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
r5781 r5929 54 54 this->setMunitionName("FusionMunition"); 55 55 56 this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot)));56 this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this))); 57 57 this->delayTimer_.stopTimer(); 58 58 } -
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h
r5781 r5929 59 59 float speed_; 60 60 float delay_; 61 Timer <EnergyDrink>delayTimer_;61 Timer delayTimer_; 62 62 }; 63 63 } -
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
r5781 r5929 54 54 this->setMunitionName("LaserMunition"); 55 55 56 this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot)));56 this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this))); 57 57 this->delayTimer_.stopTimer(); 58 58 } -
code/trunk/src/modules/weapons/weaponmodes/HsW01.h
r5781 r5929 57 57 float speed_; 58 58 float delay_; 59 Timer <HsW01>delayTimer_;59 Timer delayTimer_; 60 60 }; 61 61 }
Note: See TracChangeset
for help on using the changeset viewer.