Changeset 5929 for code/trunk/src/orxonox
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 5 deleted
- 96 edited
- 28 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/orxonox/CMakeLists.txt
r5781 r5929 25 25 26 26 SET_SOURCE_FILES(ORXONOX_SRC_FILES 27 Level.cc 28 LevelManager.cc 27 29 Main.cc 28 29 CameraManager.cc30 LevelManager.cc31 30 PawnManager.cc 32 31 PlayerManager.cc 33 34 Level.cc35 32 Radar.cc 33 COMPILATION_BEGIN SceneCompilation.cc 34 CameraManager.cc 36 35 Scene.cc 36 COMPILATION_END 37 37 ) 38 38 39 39 ADD_SUBDIRECTORY(collisionshapes) 40 40 ADD_SUBDIRECTORY(controllers) 41 ADD_SUBDIRECTORY(gamestates) 41 42 ADD_SUBDIRECTORY(gametypes) 42 43 ADD_SUBDIRECTORY(graphics) -
code/trunk/src/orxonox/CameraManager.cc
r5781 r5929 26 26 * 27 27 */ 28 28 29 #include "CameraManager.h" 29 30 … … 34 35 #include "util/StringUtils.h" 35 36 #include "core/GameMode.h" 37 #include "core/GraphicsManager.h" 36 38 #include "core/GUIManager.h" 37 39 #include "core/ObjectList.h" 40 #include "core/ScopedSingletonManager.h" 38 41 #include "tools/Shader.h" 39 42 #include "graphics/Camera.h" … … 43 46 { 44 47 CameraManager* CameraManager::singletonPtr_s = 0; 48 ManageScopedSingleton(CameraManager, ScopeID::Graphics, false); 45 49 46 CameraManager::CameraManager( Ogre::Viewport* viewport)47 : viewport_( viewport)50 CameraManager::CameraManager() 51 : viewport_(GraphicsManager::getInstance().getViewport()) 48 52 { 49 this->fallbackCamera_ = 0;53 assert(GameMode::showsGraphics()); 50 54 } 51 55 52 56 CameraManager::~CameraManager() 53 57 { 54 if (this->fallbackCamera_) 55 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 58 GUIManager::getInstance().setCamera(0); 56 59 } 57 60 58 61 Camera* CameraManager::getActiveCamera() const 59 62 { 60 if ( this->cameraList_.size() > 0)63 if (!this->cameraList_.empty()) 61 64 return this->cameraList_.front(); 62 65 else … … 66 69 void CameraManager::requestFocus(Camera* camera) 67 70 { 68 if (!GameMode::showsGraphics())69 return;70 71 71 // notify old camera (if it exists) 72 if ( this->cameraList_.size() > 0)72 if (!this->cameraList_.empty()) 73 73 this->cameraList_.front()->removeFocus(); 74 else if (this->fallbackCamera_)75 {76 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);77 this->fallbackCamera_ = 0;78 }79 74 80 75 camera->setFocus(); 81 76 82 77 // make sure we don't add it twice 83 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)78 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();) 84 79 if ((*it) == camera) 85 return; 86 80 this->cameraList_.erase(it++); 81 else 82 ++it; 87 83 // add to list 88 84 this->cameraList_.push_front(camera); … … 91 87 void CameraManager::releaseFocus(Camera* camera) 92 88 { 93 if (!GameMode::showsGraphics())94 return;95 96 89 // notify the cam of releasing the focus 97 if ( this->cameraList_.front() == camera)90 if (!this->cameraList_.empty() && this->cameraList_.front() == camera) 98 91 { 99 92 camera->removeFocus(); … … 101 94 102 95 // set new focus if possible 103 if ( this->cameraList_.size() > 0)96 if (!this->cameraList_.empty()) 104 97 this->cameraList_.front()->setFocus(); 105 else106 {107 // there are no more cameras, create a fallback108 if (!this->fallbackCamera_)109 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());110 this->useCamera(this->fallbackCamera_);111 }112 98 } 113 99 else 114 {115 100 this->cameraList_.remove(camera); 116 }117 101 } 118 102 -
code/trunk/src/orxonox/CameraManager.h
r5781 r5929 42 42 #include "util/OgreForwardRefs.h" 43 43 #include "util/Singleton.h" 44 #include "core/OrxonoxClass.h" 45 #include "core/SmartPtr.h" 44 46 45 47 namespace orxonox 46 48 { 47 class _OrxonoxExport CameraManager : public Singleton<CameraManager> 49 class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass 48 50 { 49 51 friend class Singleton<CameraManager>; 50 52 public: 51 CameraManager( Ogre::Viewport* viewport);53 CameraManager(); 52 54 ~CameraManager(); 53 55 … … 66 68 std::list<Camera*> cameraList_; 67 69 Ogre::Viewport* viewport_; 68 Ogre::Camera* fallbackCamera_;69 70 70 71 static CameraManager* singletonPtr_s; -
code/trunk/src/orxonox/Level.cc
r5781 r5929 30 30 31 31 #include "util/Math.h" 32 #include "core/Core.h"33 32 #include "core/CoreIncludes.h" 34 33 #include "core/Loader.h" … … 40 39 #include "gametypes/Gametype.h" 41 40 #include "overlays/OverlayGroup.h" 42 #include "sound/SoundBase.h"43 41 #include "LevelManager.h" 44 42 … … 53 51 this->registerVariables(); 54 52 this->xmlfilename_ = this->getFilename(); 53 this->xmlfile_ = 0; 55 54 } 56 55 … … 64 63 if (this->xmlfile_) 65 64 Loader::unload(this->xmlfile_); 66 67 if(this->ambientsound_ != NULL)68 delete this->ambientsound_;69 65 } 70 66 } … … 76 72 XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode); 77 73 XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype"); 78 79 XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);80 74 81 75 XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false); … … 116 110 this->gametype_ = gametype; 117 111 118 std::cout << "Load Gametype: " << this->gametype_ << std::endl;119 120 112 Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this)); 121 113 this->setGametype(rootgametype); 122 123 std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;124 114 125 115 for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it) … … 149 139 } 150 140 151 void Level::loadAmbientSound(const std::string& filename)152 {153 if(filename == "") return;154 else155 {156 if(this->ambientsound_ == NULL)157 {158 this->ambientsound_ = new SoundBase();159 }160 161 this->ambientsound_->loadFile(filename);162 this->ambientsound_->play(true);163 }164 }165 166 141 void Level::playerEntered(PlayerInfo* player) 167 142 { -
code/trunk/src/orxonox/Level.h
r5781 r5929 53 53 { return this->description_; } 54 54 55 void loadAmbientSound(const std::string& filename);56 57 55 void playerEntered(PlayerInfo* player); 58 56 void playerLeft(PlayerInfo* player); … … 73 71 XMLFile* xmlfile_; 74 72 std::list<BaseObject*> objects_; 75 76 SoundBase* ambientsound_;77 73 }; 78 74 } -
code/trunk/src/orxonox/LevelManager.cc
r5781 r5929 34 34 #include "core/CommandLine.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/Core.h"37 36 #include "core/CoreIncludes.h" 38 37 #include "core/Loader.h" 38 #include "core/ScopedSingletonManager.h" 39 39 #include "PlayerManager.h" 40 40 #include "Level.h" 41 #include "infos/HumanPlayer.h"42 41 43 42 namespace orxonox … … 46 45 47 46 LevelManager* LevelManager::singletonPtr_s = 0; 47 ManageScopedSingleton(LevelManager, ScopeID::Root, false); 48 48 49 49 LevelManager::LevelManager() -
code/trunk/src/orxonox/Main.cc
r5781 r5929 31 31 @file 32 32 @brief 33 The main function of Orxonox .33 The main function of Orxonox (but not the entry point of the program!) 34 34 */ 35 35 36 36 #include "OrxonoxPrereqs.h" 37 #include "SpecialConfig.h"38 37 39 #include "util/Exception.h"40 38 #include "core/CommandLine.h" 41 39 #include "core/Game.h" … … 50 48 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode"); 51 49 SetCommandLineSwitch(standalone).information("Start in standalone mode"); 50 SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode"); 52 51 53 52 DeclareToluaInterface(Orxonox); … … 57 56 /** 58 57 @brief 59 Main method. Game starts here (except for static initialisations).58 Starting point of orxonox (however not the entry point of the program!) 60 59 */ 61 60 int main(const std::string& strCmdLine) … … 67 66 " graphics" 68 67 " mainMenu" 69 " standalone "68 " standalone,server,client" 70 69 " level" 71 " server" 72 " level" 73 " client" 74 " level" 75 " dedicated" 70 " dedicated,dedicatedClient" 76 71 " level" 77 72 " ioConsole" … … 89 84 else if (CommandLine::getValue("dedicated").getBool()) 90 85 Game::getInstance().requestStates("dedicated, level"); 86 else if (CommandLine::getValue("dedicatedClient").getBool()) 87 Game::getInstance().requestStates("dedicatedClient, level"); 91 88 else if (CommandLine::getValue("console").getBool()) 92 89 Game::getInstance().requestStates("ioConsole"); -
code/trunk/src/orxonox/OrxonoxPrereqs.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 orxonox library 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "tools/ToolsPrereqs.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 ORXONOX_SHARED_BUILD … … 65 66 { 66 67 class CameraManager; 68 class Level; 67 69 class LevelManager; 68 70 class PawnManager; 69 71 class PlayerManager; 70 71 class Level; 72 class Radar; 72 73 class Scene; 73 class Tickable; 74 75 // collisionshapes 76 class CollisionShape; 77 class CompoundCollisionShape; 78 class WorldEntityCollisionShape; 79 80 // controllers 81 class AIController; 82 class ArtificialController; 83 class Controller; 84 class HumanController; 85 class ScriptController; 86 class WaypointController; 87 class WaypointPatrolController; 88 89 // gametypes 90 class Asteroids; 91 class Deathmatch; 92 class Gametype; 93 class TeamBaseMatch; 94 class TeamDeathmatch; 95 class UnderAttack; 96 97 // graphics 98 class Backlight; 99 class Billboard; 100 class BlinkingBillboard; 101 class Camera; 102 class FadingBillboard; 103 class GlobalShader; 104 class Light; 105 class Model; 106 class ParticleEmitter; 107 class ParticleSpawner; 108 109 // infos 110 class Bot; 111 class GametypeInfo; 112 class HumanPlayer; 113 class Info; 114 class PlayerInfo; 74 115 75 116 // interfaces 76 117 class GametypeMessageListener; 77 118 class NotificationListener; 78 class PawnListener;79 119 class PlayerTrigger; 80 120 class RadarListener; 81 121 class RadarViewable; 82 122 class Rewardable; 83 class Teamcolourable; 84 85 // worldentities 86 class WorldEntity; 87 class StaticEntity; 88 class MobileEntity; 89 class ControllableEntity; 90 class MovableEntity; 91 92 // graphics 93 class Model; 94 class Billboard; 95 class BlinkingBillboard; 96 class BigExplosion; 97 class ExplosionChunk; 98 class FadingBillboard; 99 class GlobalShader; 100 class Light; 101 class Backlight; 102 class ParticleEmitter; 103 class ParticleSpawner; 104 class Camera; 105 106 // mixed 107 class SpawnPoint; 108 class TeamSpawnPoint; 109 110 class CameraPosition; 111 class Sublevel; 112 class Radar; 113 114 class Test; 115 116 // pawns 117 class Spectator; 118 class Pawn; 119 class SpaceShip; 120 class TeamBaseMatchBase; 121 class Destroyer; 122 123 // gametypes 124 class Gametype; 125 class Deathmatch; 126 class TeamDeathmatch; 127 class Asteroids; 128 class TeamBaseMatch; 129 class UnderAttack; 130 131 // pickups 123 class TeamColourable; 124 125 // items 126 class Engine; 127 class Item; 128 class MultiStateEngine; 129 130 // overlays 131 class InGameConsole; 132 class Map; 133 class OrxonoxOverlay; 134 class OverlayGroup; 135 136 // pickup 132 137 class BaseItem; 133 138 class DroppedItem; … … 139 144 class PickupSpawner; 140 145 class UsableItem; 141 146 // pickup, items 147 class HealthImmediate; 148 class HealthUsable; 142 149 class Jump; 143 class HealthUsable; 144 class PassiveItem; 145 146 // items 147 class Item; 148 class Engine; 149 class MultiStateEngine; 150 class RotatingEngine; 150 151 //sound 152 class AmbientSound; 153 class BaseSound; 154 class SoundManager; 155 class WorldSound; 151 156 152 157 // weaponsystem 153 class WeaponSystem; 158 class DefaultWeaponmodeLink; 159 class Munition; 160 class Weapon; 161 class WeaponMode; 162 class WeaponPack; 154 163 class WeaponSet; 155 164 class WeaponSlot; 156 class WeaponPack; 157 class Weapon; 158 class WeaponMode; 159 class DefaultWeaponmodeLink; 160 class Munition; 161 162 // controller 163 class Controller; 164 class HumanController; 165 class ArtificialController; 166 class AIController; 167 class ScriptController; 168 class WaypointController; 169 class WaypointPatrolController; 170 171 // infos 172 class Info; 173 class PlayerInfo; 174 class HumanPlayer; 175 class Bot; 176 class GametypeInfo; 177 178 // collision 179 class CollisionShape; 180 class CompoundCollisionShape; 181 class WorldEntityCollisionShape; 182 183 // overlays 184 class OverlayGroup; 185 class OrxonoxOverlay; 186 class Notification; 187 class NotificationManager; 188 class InGameConsole; 189 class Map; 190 191 //sound 192 class SoundBase; 193 class SoundManager; 194 class SoundMainMenu; 165 class WeaponSystem; 166 167 // worldentities 168 class BigExplosion; 169 class CameraPosition; 170 class ControllableEntity; 171 class ExplosionChunk; 172 class MobileEntity; 173 class MovableEntity; 174 class SpawnPoint; 175 class StaticEntity; 176 class TeamSpawnPoint; 177 class WorldEntity; 178 // worldentities, pawns 179 class Destroyer; 180 class Pawn; 181 class SpaceShip; 182 class Spectator; 183 class TeamBaseMatchBase; 195 184 } 196 185 -
code/trunk/src/orxonox/PawnManager.cc
r5781 r5929 57 57 { 58 58 if (!it->isAlive()) 59 delete (*(it++));59 (it++)->destroy(); 60 60 else 61 61 ++it; … … 63 63 64 64 if (count == 0) 65 delete this;65 this->destroy(); 66 66 } 67 67 } -
code/trunk/src/orxonox/PlayerManager.cc
r5781 r5929 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/GameMode.h" 33 #include "core/ScopedSingletonManager.h" 33 34 #include "Level.h" 34 35 #include "infos/HumanPlayer.h" … … 38 39 { 39 40 PlayerManager* PlayerManager::singletonPtr_s = 0; 41 ManageScopedSingleton(PlayerManager, ScopeID::Root, false); 40 42 41 43 PlayerManager::PlayerManager() … … 74 76 if (GameMode::isMaster()) 75 77 { 76 COUT(3) << "client disconnected" << std::endl; 78 if (clientID != 0) 79 COUT(3) << "client disconnected" << std::endl; 77 80 78 81 // remove from clients-map … … 85 88 // delete PlayerInfo instance 86 89 if (player) 87 delete player;90 player->destroy(); 88 91 } 89 92 } -
code/trunk/src/orxonox/PlayerManager.h
r5781 r5929 50 50 { return this->clients_; } 51 51 52 private:53 52 void clientConnected(unsigned int clientID); 54 53 void clientDisconnected(unsigned int clientID); 55 54 55 private: 56 56 std::map<unsigned int, PlayerInfo*> clients_; 57 57 -
code/trunk/src/orxonox/Radar.cc
r5781 r5929 43 43 namespace orxonox 44 44 { 45 SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);46 SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);47 48 Radar* Radar::instance_s = 0;49 45 50 46 Radar::Radar() … … 52 48 , objectTypeCounter_(0) 53 49 { 54 assert(instance_s == 0);55 instance_s = this;56 57 50 // TODO: make this mapping configurable. Maybe there's a possibility with self configured 58 51 // configValues.. … … 79 72 Radar::~Radar() 80 73 { 81 instance_s = 0;82 74 } 83 75 84 76 const RadarViewable* Radar::getFocus() 85 77 { 86 return *(this->itFocus_); 78 if (this->itFocus_) 79 return *(this->itFocus_); 80 else 81 return 0; 87 82 } 88 83 … … 101 96 SUPER(Radar, tick, dt); 102 97 103 if (this-> focus_ != *(this->itFocus_))98 if (this->itFocus_ && (this->focus_ != *(this->itFocus_))) 104 99 { 105 100 // focus object was deleted, release focus … … 191 186 } 192 187 } 193 194 195 /*static*/ Radar& Radar::getInstance()196 {197 assert(instance_s);198 return *instance_s;199 }200 201 /*static*/ void Radar::cycleNavigationFocus()202 {203 // avoid using getInstance because of the assert().204 // User might call this fuction even if HUDNavigation doesn't exist.205 if (instance_s)206 instance_s->cycleFocus();207 }208 209 /*static*/ void Radar::releaseNavigationFocus()210 {211 // avoid using getInstance because of the assert().212 // User might call this fuction even if HUDNavigation doesn't exist.213 if (instance_s)214 instance_s->releaseFocus();215 }216 188 } -
code/trunk/src/orxonox/Radar.h
r5781 r5929 46 46 namespace orxonox 47 47 { 48 /** 49 @brief This class merely ensures that no one can inherit from Radar. 50 */ 51 class _OrxonoxExport RadarBase 52 { 53 private: 54 friend class Radar; 55 RadarBase() { } 56 }; 57 58 class _OrxonoxExport Radar : public Tickable, private virtual RadarBase 48 class _OrxonoxExport Radar : public Tickable 59 49 { 60 50 public: 61 51 Radar(); 62 ~Radar();52 virtual ~Radar(); 63 53 64 54 virtual void tick(float dt); … … 69 59 void listObjects() const; 70 60 71 static Radar& getInstance(); 72 static Radar* getInstancePtr() { return instance_s; } 73 74 static void cycleNavigationFocus(); 75 static void releaseNavigationFocus(); 61 void releaseFocus(); 62 void cycleFocus(); 76 63 77 64 private: 78 65 Radar(Radar& instance); 79 66 80 void releaseFocus();81 67 void updateFocus(); 82 void cycleFocus();83 68 84 69 ObjectListIterator<RadarViewable> itFocus_; … … 86 71 std::map<std::string, RadarViewable::Shape> objectTypes_; 87 72 int objectTypeCounter_; 88 89 static Radar* instance_s;90 73 }; 91 74 } -
code/trunk/src/orxonox/Scene.cc
r5781 r5929 42 42 #include "core/CoreIncludes.h" 43 43 #include "core/GameMode.h" 44 #include "core/GUIManager.h" 44 45 #include "core/XMLPort.h" 45 46 #include "tools/BulletConversions.h" 47 #include "Radar.h" 46 48 #include "worldentities/WorldEntity.h" 47 49 … … 54 56 RegisterObject(Scene); 55 57 56 this->setScene( this);58 this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN); 57 59 this->bShadows_ = true; 58 60 … … 62 64 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); 63 65 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 66 67 this->radar_ = new Radar(); 64 68 } 65 69 else … … 68 72 this->sceneManager_ = new Ogre::DefaultSceneManager(""); 69 73 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 74 75 this->radar_ = 0; 70 76 } 71 77 … … 92 98 else 93 99 delete this->sceneManager_; 100 101 if (this->radar_) 102 this->radar_->destroy(); 94 103 95 104 this->setPhysicalWorld(false); … … 275 284 { 276 285 this->objects_.push_back(object); 277 object->setScene(this );286 object->setScene(this, this->getObjectID()); 278 287 } 279 288 -
code/trunk/src/orxonox/Scene.h
r5781 r5929 71 71 { return this->bShadows_; } 72 72 73 inline Radar* getRadar() 74 { return this->radar_; } 75 76 inline virtual uint32_t getSceneID() const { return this->getObjectID(); } 77 73 78 virtual void tick(float dt); 74 79 … … 91 96 std::list<BaseObject*> objects_; 92 97 bool bShadows_; 98 Radar* radar_; 93 99 94 100 -
code/trunk/src/orxonox/Test.cc
r5781 r5929 63 63 setConfigValues(); 64 64 registerVariables(); 65 set ObjectMode(0x3);65 setSyncMode(0x3); 66 66 } 67 67 -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r5781 r5929 56 56 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 57 57 it->first->notifyDetached(); 58 delete it->first;58 it->first->destroy(); 59 59 } 60 60 -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r5781 r5929 43 43 this->worldEntityOwner_ = creator; 44 44 // suppress synchronisation 45 this->set ObjectMode(0x0);45 this->setSyncMode(0x0); 46 46 } 47 47 -
code/trunk/src/orxonox/controllers/AIController.cc
r5781 r5929 44 44 RegisterObject(AIController); 45 45 46 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));46 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&AIController::action, this))); 47 47 } 48 48 -
code/trunk/src/orxonox/controllers/AIController.h
r5781 r5929 50 50 51 51 private: 52 Timer <AIController>actionTimer_;52 Timer actionTimer_; 53 53 }; 54 54 } -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r5781 r5929 46 46 this->bHasTargetPosition_ = false; 47 47 this->targetPosition_ = Vector3::ZERO; 48 49 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 48 50 } 49 51 … … 162 164 } 163 165 164 void ArtificialController::destroyedPawn(Pawn* ship) 165 { 166 if (ship == this->target_) 167 { 168 this->forgetTarget(); 169 this->searchRandomTargetPosition(); 170 } 166 void ArtificialController::abandonTarget(Pawn* target) 167 { 168 if (target == this->target_) 169 this->targetDied(); 170 } 171 172 void ArtificialController::targetDied() 173 { 174 this->forgetTarget(); 175 this->searchRandomTargetPosition(); 171 176 } 172 177 -
code/trunk/src/orxonox/controllers/ArtificialController.h
r5781 r5929 33 33 34 34 #include "util/Math.h" 35 #include "interfaces/PawnListener.h"36 35 #include "Controller.h" 37 36 38 37 namespace orxonox 39 38 { 40 class _OrxonoxExport ArtificialController : public Controller , public PawnListener39 class _OrxonoxExport ArtificialController : public Controller 41 40 { 42 41 public: 43 42 ArtificialController(BaseObject* creator); 44 43 virtual ~ArtificialController(); 45 46 v irtual void destroyedPawn(Pawn* pawn);44 45 void abandonTarget(Pawn* target); 47 46 48 47 protected: 48 void targetDied(); 49 49 50 void moveToPosition(const Vector3& target); 50 51 void moveToTargetPosition(); … … 65 66 bool bHasTargetPosition_; 66 67 Vector3 targetPosition_; 67 Pawn*target_;68 WeakPtr<Pawn> target_; 68 69 bool bShooting_; 69 70 -
code/trunk/src/orxonox/controllers/HumanController.cc
r5781 r5929 36 36 #include "infos/PlayerInfo.h" 37 37 #include "overlays/Map.h" 38 #include "graphics/Camera.h" 39 #include "sound/SoundManager.h" 40 #include "Radar.h" 41 #include "Scene.h" 38 42 39 43 namespace orxonox … … 56 60 SetConsoleCommand(HumanController, dropItems, true); 57 61 SetConsoleCommand(HumanController, useItem, true); 62 SetConsoleCommand(HumanController, cycleNavigationFocus, true); 63 SetConsoleCommand(HumanController, releaseNavigationFocus, true); 58 64 59 65 CreateUnloadableFactory(HumanController); … … 71 77 { 72 78 HumanController::localController_s = 0; 79 } 80 81 void HumanController::tick(float dt) 82 { 83 if (GameMode::playsSound() && HumanController::localController_s && HumanController::localController_s->controllableEntity_) 84 { 85 // Update sound listener 86 Camera* camera = HumanController::localController_s->controllableEntity_->getCamera(); 87 if (camera) 88 { 89 SoundManager::getInstance().setListenerPosition(camera->getWorldPosition()); 90 SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation()); 91 } 92 else 93 COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl; 94 } 73 95 } 74 96 … … 200 222 return NULL; 201 223 } 224 225 void HumanController::cycleNavigationFocus() 226 { 227 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 228 HumanController::localController_s->controllableEntity_->getScene()->getRadar()->cycleFocus(); 229 } 230 231 void HumanController::releaseNavigationFocus() 232 { 233 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 234 HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus(); 235 } 202 236 } -
code/trunk/src/orxonox/controllers/HumanController.h
r5781 r5929 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "tools/interfaces/Tickable.h" 33 35 #include "Controller.h" 34 36 35 37 namespace orxonox 36 38 { 37 class _OrxonoxExport HumanController : public Controller 39 class _OrxonoxExport HumanController : public Controller, public Tickable 38 40 { 39 41 public: 40 42 HumanController(BaseObject* creator); 41 43 virtual ~HumanController(); 44 45 virtual void tick(float dt); 42 46 43 47 static void moveFrontBack(const Vector2& value); … … 58 62 static void dropItems(); 59 63 static void useItem(); 64 static void cycleNavigationFocus(); 65 static void releaseNavigationFocus(); 60 66 61 67 static void suicide(); -
code/trunk/src/orxonox/controllers/WaypointController.cc
r5781 r5929 50 50 { 51 51 for (size_t i = 0; i < this->waypoints_.size(); ++i) 52 delete this->waypoints_[i];52 this->waypoints_[i]->destroy(); 53 53 } 54 54 } -
code/trunk/src/orxonox/controllers/WaypointPatrolController.cc
r5781 r5929 45 45 this->alertnessradius_ = 500; 46 46 47 this->patrolTimer_.setTimer(rnd(), true, this, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy)));47 this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this))); 48 48 } 49 49 -
code/trunk/src/orxonox/controllers/WaypointPatrolController.h
r5781 r5929 61 61 int team_; 62 62 float alertnessradius_; 63 Timer <WaypointPatrolController>patrolTimer_;63 Timer patrolTimer_; 64 64 }; 65 65 } -
code/trunk/src/orxonox/gametypes/Asteroids.cc
r5781 r5929 54 54 if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_) 55 55 { 56 this->gtinfo_ .sendAnnounceMessage("Time's up - you have lost the match!");56 this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!"); 57 57 this->end(); 58 58 } … … 63 63 if (victim && victim->getPlayer()) 64 64 { 65 this->gtinfo_ .sendAnnounceMessage("You're dead - you have lost the match!");65 this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!"); 66 66 this->end(); 67 67 } -
code/trunk/src/orxonox/gametypes/Gametype.cc
r5781 r5929 33 33 #include "core/ConfigValueIncludes.h" 34 34 #include "core/GameMode.h" 35 #include "core/ConsoleCommand.h" 35 36 36 37 #include "infos/PlayerInfo.h" … … 47 48 CreateUnloadableFactory(Gametype); 48 49 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) , gtinfo_(creator)50 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 50 51 { 51 52 RegisterObject(Gametype); 52 53 this->setGametype(this); 53 54 this->gtinfo_ = new GametypeInfo(creator); 55 56 this->setGametype(SmartPtr<Gametype>(this, false)); 54 57 55 58 this->defaultControllableEntity_ = Class(Spectator); … … 76 79 else 77 80 this->scoreboard_ = 0; 81 82 /* HACK HACK HACK */ 83 this->hackAddBots_ = createConsoleCommand( createFunctor(&Gametype::addBots, this), "hackAddBots"); 84 this->hackKillBots_ = createConsoleCommand( createFunctor(&Gametype::killBots, this), "hackKillBots"); 85 CommandExecutor::addConsoleCommandShortcut( this->hackAddBots_ ); 86 CommandExecutor::addConsoleCommandShortcut( this->hackKillBots_ ); 87 /* HACK HACK HACK */ 88 } 89 90 Gametype::~Gametype() 91 { 92 if (this->isInitialized()) 93 { 94 this->gtinfo_->destroy(); 95 if( this->hackAddBots_ ) 96 delete this->hackAddBots_; 97 if( this->hackKillBots_ ) 98 delete this->hackKillBots_; 99 } 78 100 } 79 101 … … 100 122 } 101 123 102 if (this->gtinfo_ .bStartCountdownRunning_ && !this->gtinfo_.bStarted_)103 this->gtinfo_ .startCountdown_ -= dt;104 105 if (!this->gtinfo_ .bStarted_)124 if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_) 125 this->gtinfo_->startCountdown_ -= dt; 126 127 if (!this->gtinfo_->bStarted_) 106 128 this->checkStart(); 107 else if (!this->gtinfo_ .bEnded_)129 else if (!this->gtinfo_->bEnded_) 108 130 this->spawnDeadPlayersIfRequested(); 109 131 … … 115 137 this->addBots(this->numberOfBots_); 116 138 117 this->gtinfo_ .bStarted_ = true;139 this->gtinfo_->bStarted_ = true; 118 140 119 141 this->spawnPlayersIfRequested(); … … 122 144 void Gametype::end() 123 145 { 124 this->gtinfo_ .bEnded_ = true;146 this->gtinfo_->bEnded_ = true; 125 147 126 148 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 130 152 ControllableEntity* oldentity = it->first->getControllableEntity(); 131 153 132 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity ->getCreator());154 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity); 133 155 if (oldentity->getCamera()) 134 156 { … … 243 265 244 266 if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 245 this->gtinfo_ .sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());267 this->gtinfo_->sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID()); 246 268 if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 247 this->gtinfo_ .sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());269 this->gtinfo_->sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID()); 248 270 } 249 271 } … … 308 330 it->second.state_ = PlayerState::Dead; 309 331 310 if (!it->first->isReadyToSpawn() || !this->gtinfo_ .bStarted_)332 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_) 311 333 { 312 334 this->spawnPlayerAsDefaultPawn(it->first); … … 319 341 void Gametype::checkStart() 320 342 { 321 if (!this->gtinfo_ .bStarted_)322 { 323 if (this->gtinfo_ .bStartCountdownRunning_)324 { 325 if (this->gtinfo_ .startCountdown_ <= 0)326 { 327 this->gtinfo_ .bStartCountdownRunning_ = false;328 this->gtinfo_ .startCountdown_ = 0;343 if (!this->gtinfo_->bStarted_) 344 { 345 if (this->gtinfo_->bStartCountdownRunning_) 346 { 347 if (this->gtinfo_->startCountdown_ <= 0) 348 { 349 this->gtinfo_->bStartCountdownRunning_ = false; 350 this->gtinfo_->startCountdown_ = 0; 329 351 this->start(); 330 352 } … … 349 371 if (allplayersready && hashumanplayers) 350 372 { 351 this->gtinfo_ .startCountdown_ = this->initialStartCountdown_;352 this->gtinfo_ .bStartCountdownRunning_ = true;373 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 374 this->gtinfo_->bStartCountdownRunning_ = true; 353 375 } 354 376 } … … 419 441 if (it->getGametype() == this) 420 442 { 421 delete (*(it++));443 (it++)->destroy(); 422 444 ++i; 423 445 } 446 else 447 ++it; 424 448 } 425 449 } -
code/trunk/src/orxonox/gametypes/Gametype.h
r5781 r5929 37 37 38 38 #include "core/BaseObject.h" 39 #include "core/ Identifier.h"39 #include "core/SubclassIdentifier.h" 40 40 #include "tools/interfaces/Tickable.h" 41 41 #include "infos/GametypeInfo.h" … … 68 68 public: 69 69 Gametype(BaseObject* creator); 70 virtual ~Gametype() {}70 virtual ~Gametype(); 71 71 72 72 void setConfigValues(); … … 75 75 76 76 inline const GametypeInfo* getGametypeInfo() const 77 { return &this->gtinfo_; }77 { return this->gtinfo_; } 78 78 79 79 inline bool hasStarted() const 80 { return this->gtinfo_ .bStarted_; }80 { return this->gtinfo_->bStarted_; } 81 81 inline bool hasEnded() const 82 { return this->gtinfo_ .bEnded_; }82 { return this->gtinfo_->bEnded_; } 83 83 84 84 virtual void start(); … … 114 114 115 115 inline bool isStartCountdownRunning() const 116 { return this->gtinfo_ .bStartCountdownRunning_; }116 { return this->gtinfo_->bStartCountdownRunning_; } 117 117 inline float getStartCountdown() const 118 { return this->gtinfo_ .startCountdown_; }118 { return this->gtinfo_->startCountdown_; } 119 119 120 120 inline void setHUDTemplate(const std::string& name) 121 { this->gtinfo_ .hudtemplate_ = name; }121 { this->gtinfo_->hudtemplate_ = name; } 122 122 inline const std::string& getHUDTemplate() const 123 { return this->gtinfo_ .hudtemplate_; }123 { return this->gtinfo_->hudtemplate_; } 124 124 125 125 void addBots(unsigned int amount); … … 163 163 virtual void spawnDeadPlayersIfRequested(); 164 164 165 GametypeInfogtinfo_;165 SmartPtr<GametypeInfo> gtinfo_; 166 166 167 167 bool bAutoStart_; … … 184 184 // Config Values 185 185 std::string scoreboardTemplate_; 186 187 /* HACK HACK HACK */ 188 ConsoleCommand* hackAddBots_; 189 ConsoleCommand* hackKillBots_; 190 /* HACK HACK HACK */ 186 191 }; 187 192 } -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
r5781 r5929 42 42 RegisterObject(TeamBaseMatch); 43 43 44 this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));45 this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));44 this->scoreTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::winPoints, this))); 45 this->outputTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::showPoints, this))); 46 46 47 47 this->pointsTeam1_ = 0; … … 67 67 { 68 68 base->setState(BaseState::ControlTeam1); 69 this->gtinfo_ .sendAnnounceMessage("The red team captured a base");69 this->gtinfo_->sendAnnounceMessage("The red team captured a base"); 70 70 } 71 71 if (teamnr == 1) 72 72 { 73 73 base->setState(BaseState::ControlTeam2); 74 this->gtinfo_ .sendAnnounceMessage("The blue team captured a base");74 this->gtinfo_->sendAnnounceMessage("The blue team captured a base"); 75 75 } 76 76 } … … 194 194 195 195 if (it->second == winningteam) 196 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());196 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 197 197 else 198 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());198 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 199 199 } 200 200 -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.h
r5781 r5929 65 65 66 66 std::set<TeamBaseMatchBase*> bases_; 67 Timer <TeamBaseMatch>scoreTimer_;68 Timer <TeamBaseMatch>outputTimer_;67 Timer scoreTimer_; 68 Timer outputTimer_; 69 69 70 70 //points for each team -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r5781 r5929 93 93 94 94 if (valid_player) 95 this-> players_.erase(player);95 this->teamnumbers_.erase(player); 96 96 97 97 return valid_player; … … 100 100 bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator) 101 101 { 102 return (!this->pawnsAreInTheSameTeam(victim, originator) );102 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 103 103 } 104 104 105 105 bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator) 106 106 { 107 return (!this->pawnsAreInTheSameTeam(victim, originator) );107 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 108 108 } 109 109 110 110 bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator) 111 111 { 112 return (!this->pawnsAreInTheSameTeam(victim, originator) );112 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 113 113 } 114 114 -
code/trunk/src/orxonox/gametypes/UnderAttack.cc
r5781 r5929 46 46 this->teams_ = 2; 47 47 this->destroyer_ = 0; 48 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 48 49 this->gameEnded_ = false; 49 50 … … 65 66 66 67 67 void UnderAttack:: destroyedPawn(Pawn* pawn)68 void UnderAttack::killedDestroyer() 68 69 { 69 if (pawn == this->destroyer_) 70 this->end(); //end gametype 71 std::string message = "Ship destroyed! Team 0 has won!"; 72 COUT(0) << message << std::endl; 73 Host::Broadcast(message); 74 this->gameEnded_ = true; 75 76 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 70 77 { 71 this->end(); //end gametype 72 std::string message = "Ship destroyed! Team 0 has won!"; 73 COUT(0) << message << std::endl; 74 Host::Broadcast(message); 75 this->gameEnded_ = true; 78 if (it->first->getClientID() == CLIENTID_UNKNOWN) 79 continue; 76 80 77 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 78 { 79 if (it->first->getClientID() == CLIENTID_UNKNOWN) 80 continue; 81 82 if (it->second == 0) 83 this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID()); 84 else 85 this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 86 } 81 if (it->second == 0) 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 83 else 84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 87 85 } 88 86 } … … 164 162 165 163 if (it->second == 1) 166 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());164 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 167 165 else 168 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());166 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 169 167 } 170 168 } … … 178 176 Host::Broadcast(message); 179 177 */ 180 this->gtinfo_ .sendAnnounceMessage(message);178 this->gtinfo_->sendAnnounceMessage(message); 181 179 182 180 if (timesequence_ >= 30 && timesequence_ <= 60) -
code/trunk/src/orxonox/gametypes/UnderAttack.h
r5781 r5929 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "interfaces/PawnListener.h"35 34 #include "TeamDeathmatch.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport UnderAttack : public TeamDeathmatch , public PawnListener38 class _OrxonoxExport UnderAttack : public TeamDeathmatch 40 39 { 41 40 public: … … 54 53 55 54 protected: 56 virtual void destroyedPawn(Pawn* pawn);55 virtual void killedDestroyer(); 57 56 58 Destroyer*destroyer_;57 WeakPtr<Destroyer> destroyer_; 59 58 unsigned int teams_; 60 59 float gameTime_; -
code/trunk/src/orxonox/graphics/CMakeLists.txt
r5781 r5929 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 Backlight.cc3 2 Billboard.cc 4 3 BlinkingBillboard.cc 5 Camera.cc6 4 FadingBillboard.cc 7 5 GlobalShader.cc 8 Light.cc9 6 Model.cc 10 7 ParticleEmitter.cc 11 8 ParticleSpawner.cc 9 COMPILATION_BEGIN GraphicsCompilation.cc 10 Backlight.cc 11 Camera.cc 12 Light.cc 13 COMPILATION_END 12 14 ) -
code/trunk/src/orxonox/graphics/Camera.cc
r5781 r5929 38 38 #include "core/CoreIncludes.h" 39 39 #include "core/ConfigValueIncludes.h" 40 #include "core/GameMode.h" 41 #include "core/GUIManager.h" 40 42 #include "Scene.h" 41 43 #include "CameraManager.h" … … 49 51 RegisterObject(Camera); 50 52 53 if (!GameMode::showsGraphics()) 54 ThrowException(AbortLoading, "Can't create Camera, no graphics."); 51 55 if (!this->getScene()) 52 56 ThrowException(AbortLoading, "Can't create Camera, no scene."); … … 65 69 this->nearClipDistance_ = 1; 66 70 67 this->set ObjectMode(0x0);71 this->setSyncMode(0x0); 68 72 69 73 this->setConfigValues(); … … 75 79 if (this->isInitialized()) 76 80 { 81 if (GUIManager::getInstance().getCamera() == this->camera_) 82 GUIManager::getInstance().setCamera(NULL); 77 83 this->releaseFocus(); 78 84 -
code/trunk/src/orxonox/graphics/FadingBillboard.cc
r5781 r5929 103 103 { 104 104 this->changedirection_ = 1; 105 this->turnonofftimer_.setTimer(this->turnontime_, false, this, createExecutor(createFunctor(&FadingBillboard::stopturnonoff)));105 this->turnonofftimer_.setTimer(this->turnontime_, false, createExecutor(createFunctor(&FadingBillboard::stopturnonoff, this))); 106 106 107 107 if (this->isVisible()) … … 111 111 { 112 112 this->changedirection_ = -1; 113 this->turnonofftimer_.setTimer(this->turnofftime_, false, this, createExecutor(createFunctor(&FadingBillboard::stopturnonoff)));113 this->turnonofftimer_.setTimer(this->turnofftime_, false, createExecutor(createFunctor(&FadingBillboard::stopturnonoff, this))); 114 114 } 115 115 } … … 126 126 this->fadedColour_ = ColourValue::ZERO; 127 127 this->getBillboardSet().setColour(this->fadedColour_); 128 this->turnonofftimer_.setTimer(this->postprocessingtime_, false, this, createExecutor(createFunctor(&FadingBillboard::poststopturnonoff)));128 this->turnonofftimer_.setTimer(this->postprocessingtime_, false, createExecutor(createFunctor(&FadingBillboard::poststopturnonoff, this))); 129 129 } 130 130 this->changedirection_ = 0; -
code/trunk/src/orxonox/graphics/FadingBillboard.h
r5781 r5929 74 74 float turnofftime_; 75 75 float postprocessingtime_; 76 Timer <FadingBillboard>turnonofftimer_;76 Timer turnonofftimer_; 77 77 char changedirection_; 78 78 ColourValue fadedColour_; -
code/trunk/src/orxonox/graphics/ParticleEmitter.cc
r5781 r5929 63 63 { 64 64 this->detachOgreObject(this->particles_->getParticleSystem()); 65 delete this->particles_;65 this->particles_->destroy(); 66 66 } 67 67 } … … 101 101 if (this->particles_) 102 102 { 103 delete this->particles_;103 this->particles_->destroy(); 104 104 this->particles_ = 0; 105 105 } -
code/trunk/src/orxonox/graphics/ParticleSpawner.cc
r5781 r5929 71 71 } 72 72 73 void ParticleSpawner:: processEvent(Event& event)73 void ParticleSpawner::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 74 74 { 75 SUPER(ParticleSpawner, processEvent, event);75 SUPER(ParticleSpawner, XMLEventPort, xmlelement, mode); 76 76 77 ORXONOX_SET_EVENT(ParticleSpawner, "spawn", spawn, event);77 XMLPortEventState(ParticleSpawner, BaseObject, "spawn", spawn, xmlelement, mode); 78 78 } 79 79 … … 88 88 void ParticleSpawner::startParticleSpawner() 89 89 { 90 if (!this->particles_)91 return;92 93 90 this->setActive(false); 94 91 95 92 if (this->bForceDestroy_ || this->bSuppressStart_) 93 { 94 this->timer_.stopTimer(); 96 95 return; 96 } 97 97 98 this->timer_.setTimer(this->startdelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner)));98 this->timer_.setTimer(this->startdelay_, false, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner, this))); 99 99 } 100 100 … … 103 103 this->setActive(true); 104 104 if (this->lifetime_ != 0) 105 this->timer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner)));105 this->timer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner, this))); 106 106 } 107 107 … … 116 116 117 117 if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_) 118 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));118 this->timer_.setTimer(this->destroydelay_, false, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner, this))); 119 119 } 120 120 else if (this->bLoop_) 121 121 { 122 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner)));122 this->timer_.setTimer(this->destroydelay_, false, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner, this))); 123 123 } 124 124 } … … 126 126 void ParticleSpawner::destroyParticleSpawner() 127 127 { 128 delete this;128 this->destroy(); 129 129 } 130 130 } -
code/trunk/src/orxonox/graphics/ParticleSpawner.h
r5781 r5929 44 44 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 virtual void processEvent(Event& event);46 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 47 47 48 inline void destroy()49 { this->bForceDestroy_ = true; this->stopParticleSpawner(); }48 inline void stop(bool bDestroy) 49 { this->bForceDestroy_ = bDestroy; this->stopParticleSpawner(); } 50 50 inline void spawn() 51 51 { this->bSuppressStart_ = false; this->startParticleSpawner(); } … … 89 89 void destroyParticleSpawner(); 90 90 91 Timer <ParticleSpawner>timer_;91 Timer timer_; 92 92 93 93 bool bSuppressStart_; -
code/trunk/src/orxonox/infos/HumanPlayer.cc
r5781 r5929 64 64 { 65 65 if (this->humanHud_) 66 delete this->humanHud_;66 this->humanHud_->destroy(); 67 67 68 68 if (this->gametypeHud_) 69 delete this->gametypeHud_;69 this->gametypeHud_->destroy(); 70 70 } 71 71 } … … 116 116 117 117 if (!GameMode::isMaster()) 118 this->set ObjectMode(ObjectDirection::Bidirectional);118 this->setSyncMode(ObjectDirection::Bidirectional); 119 119 else 120 120 this->setName(this->nick_); … … 162 162 163 163 if (this->isInitialized() && this->isLocalPlayer()) 164 if (this->getGametype()->getHUDTemplate() != "") 164 { 165 if (this->getGametype() && this->getGametype()->getHUDTemplate() != "") 165 166 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 167 else 168 this->setGametypeHUDTemplate(""); 169 } 166 170 } 167 171 … … 170 174 if (this->humanHud_) 171 175 { 172 delete this->humanHud_;176 this->humanHud_->destroy(); 173 177 this->humanHud_ = 0; 174 178 } 175 179 176 if (this->isLocalPlayer() && this->humanHudTemplate_ != "" )180 if (this->isLocalPlayer() && this->humanHudTemplate_ != "" && GameMode::showsGraphics()) 177 181 { 178 182 this->humanHud_ = new OverlayGroup(this); … … 186 190 if (this->gametypeHud_) 187 191 { 188 delete this->gametypeHud_;192 this->gametypeHud_->destroy(); 189 193 this->gametypeHud_ = 0; 190 194 } -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r5781 r5929 35 35 #include "gametypes/Gametype.h" 36 36 #include "worldentities/ControllableEntity.h" 37 #include "controllers/Controller.h" 37 38 38 39 namespace orxonox … … 66 67 if (this->controller_) 67 68 { 68 delete this->controller_;69 this->controller_->destroy(); 69 70 this->controller_ = 0; 70 71 } … … 131 132 if (this->controller_) 132 133 { 133 delete this->controller_;134 this->controller_->destroy(); 134 135 this->controller_ = 0; 135 136 } -
code/trunk/src/orxonox/infos/PlayerInfo.h
r5781 r5929 33 33 34 34 #include "Info.h" 35 #include "core/Identifier.h" 36 #include "controllers/Controller.h" 35 #include "core/SubclassIdentifier.h" 37 36 38 37 namespace orxonox -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r5781 r5929 34 34 35 35 #include "GametypeMessageListener.h" 36 #include "PawnListener.h"37 36 #include "PlayerTrigger.h" 38 37 #include "RadarListener.h" … … 51 50 { 52 51 RegisterRootObject(GametypeMessageListener); 53 }54 55 //----------------------------56 // PawnListener57 //----------------------------58 /**59 @brief Constructor for the PawnListener.60 */61 PawnListener::PawnListener()62 {63 RegisterRootObject(PawnListener);64 52 } 65 53 -
code/trunk/src/orxonox/interfaces/NotificationListener.h
r5781 r5929 45 45 namespace orxonox 46 46 { 47 class Notification; 48 47 49 class _OrxonoxExport NotificationListener : virtual public OrxonoxClass 48 50 { -
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r5781 r5929 38 38 #include "worldentities/WorldEntity.h" 39 39 #include "Radar.h" 40 #include "Scene.h" 40 41 #include "overlays/Map.h" 41 42 … … 135 136 void RadarViewable::setRadarObjectDescription(const std::string& str) 136 137 { 137 Radar* radar = Radar::getInstancePtr();138 Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 138 139 if (radar) 139 140 this->radarObjectShape_ = radar->addObjectDescription(str); -
code/trunk/src/orxonox/items/Engine.cc
r5781 r5929 37 37 #include "pickup/ModifierType.h" 38 38 #include "tools/Shader.h" 39 #include "sound/SoundBase.h"40 39 41 40 namespace orxonox … … 68 67 this->setConfigValues(); 69 68 this->registerVariables(); 70 71 this->sound_ = NULL;72 69 } 73 70 … … 79 76 80 77 if (this->boostBlur_) 81 delete this->boostBlur_; 82 83 if(this->sound_ != NULL) 84 delete this->sound_; 78 this->boostBlur_->destroy(); 85 79 } 86 80 } … … 102 96 XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode); 103 97 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 104 105 XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);106 98 } 107 99 … … 237 229 if (this->boostBlur_) 238 230 { 239 delete this->boostBlur_;231 this->boostBlur_->destroy(); 240 232 this->boostBlur_ = 0; 241 233 } 242 243 if(this->sound_ != NULL)244 this->sound_->attachToEntity(ship);245 234 } 246 235 } … … 253 242 return Vector3::ZERO; 254 243 } 255 256 void Engine::loadSound(const std::string filename)257 {258 if(filename == "") return;259 else260 {261 if(this->sound_ == NULL)262 {263 this->sound_ = new SoundBase(this->ship_);264 }265 266 this->sound_->loadFile(filename);267 this->sound_->play(true);268 }269 }270 244 } -
code/trunk/src/orxonox/items/Engine.h
r5781 r5929 130 130 Shader* boostBlur_; 131 131 float blurStrength_; 132 133 SoundBase* sound_;134 132 }; 135 133 } -
code/trunk/src/orxonox/items/MultiStateEngine.cc
r5781 r5929 60 60 // We have no ship, so the effects are not attached and won't be destroyed automatically 61 61 for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it) 62 delete (*it);62 (*it)->destroy(); 63 63 for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it) 64 delete (*it);64 (*it)->destroy(); 65 65 for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it) 66 delete (*it);66 (*it)->destroy(); 67 67 for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it) 68 delete (*it);68 (*it)->destroy(); 69 69 } 70 70 } … … 91 91 if (this->getShip()->hasLocalController()) 92 92 { 93 this->set ObjectMode(ObjectDirection::Bidirectional);93 this->setSyncMode(ObjectDirection::Bidirectional); 94 94 95 95 const Vector3& direction = this->getDirection(); -
code/trunk/src/orxonox/overlays/CMakeLists.txt
r5781 r5929 3 3 OverlayGroup.cc 4 4 5 COMPILATION_BEGIN OverlayCompilation.cc 5 6 InGameConsole.cc 6 7 Map.cc 8 COMPILATION_END 7 9 ) -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r5781 r5929 41 41 #include <OgreFont.h> 42 42 43 #include "util/Clock.h" 44 #include "util/Convert.h" 43 45 #include "util/Math.h" 44 #include "util/Convert.h"45 46 #include "util/UTFStringConversions.h" 46 #include "core/Clock.h"47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" 49 49 #include "core/ConsoleCommand.h" 50 #include "core/ScopedSingletonManager.h" 50 51 #include "core/input/InputManager.h" 51 52 #include "core/input/InputState.h" … … 61 62 62 63 InGameConsole* InGameConsole::singletonPtr_s = 0; 64 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 63 65 64 66 /** … … 85 87 86 88 this->setConfigValues(); 89 this->initialise(); 87 90 } 88 91 -
code/trunk/src/orxonox/overlays/InGameConsole.h
r5781 r5929 50 50 51 51 void initialise(); 52 void destroy();53 52 void setConfigValues(); 54 53 -
code/trunk/src/orxonox/overlays/Map.cc
r5781 r5929 290 290 for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); 291 291 it!=ObjectList<orxonox::RadarViewable>::end(); 292 it++)292 ++it) 293 293 { 294 294 //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl; … … 392 392 for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin(); 393 393 it!=ObjectList<orxonox::Map>::end(); 394 it++)394 ++it) 395 395 { 396 396 //Map * m = it->getMap(); -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r5781 r5929 213 213 }; 214 214 215 SUPER_FUNCTION( 7, OrxonoxOverlay, changedOwner, false);216 SUPER_FUNCTION( 8, OrxonoxOverlay, changedOverlayGroup, false);215 SUPER_FUNCTION(6, OrxonoxOverlay, changedOwner, false); 216 SUPER_FUNCTION(7, OrxonoxOverlay, changedOverlayGroup, false); 217 217 } 218 218 -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r5781 r5929 61 61 { 62 62 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 63 delete (*it);63 (*it)->destroy(); 64 64 } 65 65 -
code/trunk/src/orxonox/pickup/DroppedItem.cc
r5781 r5929 56 56 if (this->item_) 57 57 { 58 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)58 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 59 59 { 60 60 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 69 69 { 70 70 COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl; 71 delete this;71 this->destroy(); 72 72 } 73 73 } … … 76 76 if (this->timeToLive_ > 0) 77 77 { 78 ExecutorMember<DroppedItem>* exec = createExecutor(createFunctor(&DroppedItem::timerCallback)); 79 this->timer_.setTimer(this->timeToLive_, false, this, exec, false); 78 this->timer_.setTimer(this->timeToLive_, false, createExecutor(createFunctor(&DroppedItem::timerCallback, this)), false); 80 79 } 81 80 } … … 85 84 { 86 85 COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl; 87 delete this->item_;86 this->item_->destroy(); 88 87 } 89 88 90 delete this;89 this->destroy(); 91 90 } 92 91 -
code/trunk/src/orxonox/pickup/DroppedItem.h
r5781 r5929 77 77 BaseItem* item_; 78 78 79 Timer <DroppedItem>timer_;79 Timer timer_; 80 80 }; 81 81 } -
code/trunk/src/orxonox/pickup/ModifierPickup.cc
r5781 r5929 101 101 if (this->duration_ > 0.0f) 102 102 { 103 Executor Member<ModifierPickup>* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback));103 Executor* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback, this)); 104 104 executor->setDefaultValues(pawn); 105 this->timer_.setTimer(this->duration_, false, this,executor);105 this->timer_.setTimer(this->duration_, false, executor); 106 106 } 107 107 … … 139 139 this->timer_.stopTimer(); 140 140 141 delete this;141 this->destroy(); 142 142 143 143 return true; -
code/trunk/src/orxonox/pickup/ModifierPickup.h
r5781 r5929 129 129 130 130 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 131 131 132 private: 132 133 float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType. … … 138 139 std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType. 139 140 140 float duration_; //!< Duration of this pickup's effect (0 for unlimited).141 Timer <ModifierPickup> timer_;//!< Timer used if the pickup's effect has a time limit.141 float duration_; //!< Duration of this pickup's effect (0 for unlimited). 142 Timer timer_; //!< Timer used if the pickup's effect has a time limit. 142 143 }; 143 144 } -
code/trunk/src/orxonox/pickup/PickupSpawner.cc
r5781 r5929 91 91 asItem->addTemplate(this->itemTemplate_); 92 92 PickupInventory::getImageForItem(asItem); 93 delete newObject;93 newObject->destroy(); 94 94 } 95 95 … … 127 127 if (this->isActive()) 128 128 { 129 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)129 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 130 130 { 131 131 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 166 166 if (this->respawnTime_ > 0.0f) 167 167 { 168 ExecutorMember<PickupSpawner>* executor = createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback)); 169 this->respawnTimer_.setTimer(this->respawnTime_, false, this, executor); 168 this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this))); 170 169 171 170 this->setActive(false); … … 174 173 } 175 174 else 176 delete newObject;175 newObject->destroy(); 177 176 } 178 177 } -
code/trunk/src/orxonox/pickup/PickupSpawner.h
r5781 r5929 114 114 115 115 float respawnTime_; //!< Time after which this gets re-actived. 116 Timer <PickupSpawner> respawnTimer_;//!< Timer used for re-activating.116 Timer respawnTimer_; //!< Timer used for re-activating. 117 117 }; 118 118 } -
code/trunk/src/orxonox/pickup/items/HealthImmediate.cc
r5781 r5929 67 67 { 68 68 pawn->addHealth(this->recoveredHealth_); 69 delete this;69 this->destroy(); 70 70 } 71 71 -
code/trunk/src/orxonox/pickup/items/HealthUsable.cc
r5781 r5929 82 82 83 83 this->removeFrom(pawn); 84 delete this;84 this->destroy(); 85 85 } 86 86 } -
code/trunk/src/orxonox/pickup/items/Jump.cc
r5781 r5929 84 84 { 85 85 this->removeFrom(pawn); 86 delete this;86 this->destroy(); 87 87 } 88 88 } -
code/trunk/src/orxonox/sound/CMakeLists.txt
r5781 r5929 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 AmbientSound.cc 3 BaseSound.cc 2 4 SoundManager.cc 3 SoundBase.cc 4 SoundMainMenu.cc 5 WorldSound.cc 5 6 ) 6 7 -
code/trunk/src/orxonox/sound/SoundManager.cc
r5781 r5929 31 31 #include <AL/alut.h> 32 32 33 #include "util/Exception.h" 33 34 #include "util/Math.h" 34 #include " CameraManager.h"35 #include " graphics/Camera.h"36 #include " SoundBase.h"35 #include "util/ScopeGuard.h" 36 #include "core/GameMode.h" 37 #include "core/ScopedSingletonManager.h" 37 38 38 39 namespace orxonox 39 40 { 40 41 SoundManager* SoundManager::singletonPtr_s = NULL; 42 ManageScopedSingleton(SoundManager, ScopeID::Graphics, true); 41 43 42 /**43 * Default constructor44 */45 44 SoundManager::SoundManager() 46 45 { 47 this->device_ = NULL; 48 this->soundavailable_ = true; 49 if(!alutInitWithoutContext(NULL,NULL)) 46 if (!alutInitWithoutContext(NULL,NULL)) 47 ThrowException(InitialisationFailed, "OpenAL ALUT error: " << alutGetErrorString(alutGetError())); 48 Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit); 49 50 COUT(3) << "OpenAL: Opening sound device..." << std::endl; 51 this->device_ = alcOpenDevice(NULL); 52 if (this->device_ == NULL) 50 53 { 51 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 52 this->soundavailable_ = false; 54 COUT(0) << "OpenaAL: Could not open sound device. Have you installed OpenAL?" << std::endl; 55 #ifdef ORXONOX_PLATFORM_WINDOWS 56 COUT(0) << "Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl; 57 #endif 58 ThrowException(InitialisationFailed, "OpenAL error: Could not open sound device."); 53 59 } 60 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); 61 62 COUT(3) << "OpenAL: Sound device opened" << std::endl; 63 this->context_ = alcCreateContext(this->device_, NULL); 64 if (this->context_ == NULL) 65 ThrowException(InitialisationFailed, "OpenAL error: Could not create sound context"); 66 Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_); 67 68 if (alcMakeContextCurrent(this->context_) == AL_TRUE) 69 COUT(3) << "OpenAL: Context " << this->context_ << " loaded" << std::endl; 70 71 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 72 73 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER); 74 if (str == NULL) 75 COUT(2) << "OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl; 54 76 else 55 { 56 assert(this->device_ == NULL); 57 COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl; 58 this->device_ = alcOpenDevice(NULL); 77 COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl; 59 78 60 if(this->device_ == NULL) 61 { 62 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl; 63 this->soundavailable_ = false; 64 } 65 else 66 { 67 COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl; 68 this->context_ = alcCreateContext(this->device_, NULL); 69 if(this->context_ == NULL) 70 { 71 COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl; 72 this->soundavailable_ = false; 73 } 74 else 75 { 76 if(alcMakeContextCurrent(this->context_) == AL_TRUE) 77 COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl; 78 79 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 80 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER); 81 if (str == NULL) 82 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 83 else 84 COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl; 85 } 86 } 87 } 79 GameMode::setPlaysSound(true); 80 // Disarm guards 81 alutExitGuard.Dismiss(); 82 closeDeviceGuard.Dismiss(); 83 desroyContextGuard.Dismiss(); 88 84 } 89 85 90 86 SoundManager::~SoundManager() 91 87 { 88 GameMode::setPlaysSound(false); 92 89 alcDestroyContext(this->context_); 93 90 alcCloseDevice(this->device_); … … 95 92 } 96 93 97 /** 98 * Add a SoundBase object to the list. Every SoundBase object should be in 99 * this list. 100 * 101 * @param sound Pointer to the SoundBase object to add 102 */ 103 void SoundManager::addSound(SoundBase* sound) 94 void SoundManager::setListenerPosition(const Vector3& position) 104 95 { 105 this->soundlist_.push_back(sound); 96 alListener3f(AL_POSITION, position.x, position.y, position.z); 97 ALenum error = alGetError(); 98 if (error == AL_INVALID_VALUE) 99 COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl; 106 100 } 107 101 108 /** 109 * Remove a SoundBase object from the list and destroy it. 110 */ 111 void SoundManager::removeSound(SoundBase* sound) 102 void SoundManager::setListenerOrientation(const Quaternion& orientation) 112 103 { 113 std::list<SoundBase*>::iterator pos = this->soundlist_.end(); 114 for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++) 115 { 116 if((*i) == sound) 117 pos = i; 118 } 104 // update listener orientation 105 Vector3 up = orientation.xAxis(); // just a wild guess 106 Vector3 at = orientation.zAxis(); 119 107 120 delete (*pos); 121 this->soundlist_.erase(pos); 122 } 108 ALfloat orient[6] = { at.x, at.y, at.z, 109 up.x, up.y, up.z }; 123 110 124 /** 125 * Tick function, updates listener and registred SoundBase objects 126 * 127 * @param dt @see Orxonox::Tickable 128 */ 129 void SoundManager::tick(float dt) 130 { 131 if (!CameraManager::getInstancePtr()) 132 return; 133 134 // update listener position 135 Camera* camera = CameraManager::getInstance().getActiveCamera(); 136 if(camera == NULL) return; 137 Vector3 pos = camera->getPosition(); 138 alListener3f(AL_POSITION, pos.x, pos.y, pos.z); 111 alListenerfv(AL_POSITION, orient); 139 112 ALenum error = alGetError(); 140 if(error == AL_INVALID_VALUE) 141 COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl; 142 143 // update listener orientation 144 const Quaternion& orient = camera->getOrientation(); 145 Vector3 up = orient.xAxis(); // just a wild guess 146 Vector3 at = orient.zAxis(); 147 148 ALfloat orientation[6] = { at.x, at.y, at.z, 149 up.x, up.y, up.z }; 150 151 alListenerfv(AL_POSITION, orientation); 152 error = alGetError(); 153 if(error == AL_INVALID_VALUE) 113 if (error == AL_INVALID_VALUE) 154 114 COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl; 155 156 // update sounds157 for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)158 (*i)->update();159 }160 161 /**162 * Check if sound is available163 */164 bool SoundManager::isSoundAvailable()165 {166 return this->soundavailable_;167 115 } 168 116 } -
code/trunk/src/orxonox/sound/SoundManager.h
r5781 r5929 39 39 /** 40 40 * The SoundManager class manages the OpenAL device, context and listener 41 * position. It has a list of all SoundBase objects and calls their update 42 * function every tick. It is a singleton. 41 * position. It is a singleton. 43 42 * 44 43 */ 45 class _OrxonoxExport SoundManager : public Singleton<SoundManager> , public Tickable44 class _OrxonoxExport SoundManager : public Singleton<SoundManager> 46 45 { 47 46 friend class Singleton<SoundManager>; … … 49 48 SoundManager(); 50 49 ~SoundManager(); 51 void addSound(SoundBase* sound); 52 void removeSound(SoundBase* sound); 53 void tick(float dt); 54 bool isSoundAvailable(); 50 51 void setListenerPosition(const Vector3& position); 52 void setListenerOrientation(const Quaternion& orientation); 55 53 56 54 private: 57 55 ALCdevice* device_; 58 56 ALCcontext* context_; 59 std::list<SoundBase*> soundlist_;60 bool soundavailable_;61 57 62 58 static SoundManager* singletonPtr_s; 63 }; // class SoundManager64 } // namespace orxonox59 }; 60 } 65 61 66 62 #endif /* _SoundManager_H__ */ -
code/trunk/src/orxonox/weaponsystem/Munition.cc
r5781 r5929 461 461 if (bUseReloadTime && (munition->reloadTime_ > 0 || munition->bStackMunition_)) 462 462 { 463 Executor Member<Magazine>* executor = createExecutor(createFunctor(&Magazine::loaded));463 Executor* executor = createExecutor(createFunctor(&Magazine::loaded, this)); 464 464 executor->setDefaultValues(munition); 465 465 466 this->loadTimer_.setTimer(munition->reloadTime_, false, this,executor);466 this->loadTimer_.setTimer(munition->reloadTime_, false, executor); 467 467 } 468 468 else -
code/trunk/src/orxonox/weaponsystem/Munition.h
r5781 r5929 47 47 48 48 unsigned int munition_; 49 Timer <Magazine>loadTimer_;49 Timer loadTimer_; 50 50 bool bLoaded_; 51 51 -
code/trunk/src/orxonox/weaponsystem/Weapon.cc
r5781 r5929 50 50 this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED; 51 51 52 this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded)));52 this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&Weapon::reloaded, this))); 53 53 this->reloadTimer_.stopTimer(); 54 54 } … … 62 62 63 63 for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it) 64 delete it->second;64 it->second->destroy(); 65 65 } 66 66 } -
code/trunk/src/orxonox/weaponsystem/Weapon.h
r5781 r5929 71 71 std::multimap<unsigned int, WeaponMode*> weaponmodes_; 72 72 73 Timer <Weapon>reloadTimer_;73 Timer reloadTimer_; 74 74 bool bReloading_; 75 75 unsigned int reloadingWeaponmode_; -
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
r5781 r5929 57 57 this->bParallelReload_ = true; 58 58 59 this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&WeaponMode::reloaded)));59 this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this))); 60 60 this->reloadTimer_.stopTimer(); 61 61 -
code/trunk/src/orxonox/weaponsystem/WeaponMode.h
r5781 r5929 36 36 #include "util/Math.h" 37 37 #include "core/BaseObject.h" 38 #include "core/ Identifier.h"38 #include "core/SubclassIdentifier.h" 39 39 #include "tools/Timer.h" 40 40 … … 150 150 std::string munitionname_; 151 151 152 Timer <WeaponMode>reloadTimer_;152 Timer reloadTimer_; 153 153 bool bReloading_; 154 154 }; -
code/trunk/src/orxonox/weaponsystem/WeaponPack.cc
r5781 r5929 54 54 55 55 while (!this->weapons_.empty()) 56 delete (*this->weapons_.begin());56 (*this->weapons_.begin())->destroy(); 57 57 58 58 for (std::set<DefaultWeaponmodeLink*>::iterator it = this->links_.begin(); it != this->links_.end(); ) 59 delete (*(it++));59 (*(it++))->destroy(); 60 60 } 61 61 } -
code/trunk/src/orxonox/weaponsystem/WeaponSlot.cc
r5781 r5929 46 46 this->weapon_ = 0; 47 47 48 this->set ObjectMode(0x0);48 this->setSyncMode(0x0); 49 49 } 50 50 -
code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc
r5781 r5929 62 62 63 63 while (!this->weaponSets_.empty()) 64 delete (this->weaponSets_.begin()->second);64 this->weaponSets_.begin()->second->destroy(); 65 65 66 66 while (!this->weaponPacks_.empty()) 67 delete (*this->weaponPacks_.begin());67 (*this->weaponPacks_.begin())->destroy(); 68 68 69 69 while (!this->weaponSlots_.empty()) 70 delete (*this->weaponSlots_.begin());70 (*this->weaponSlots_.begin())->destroy(); 71 71 72 72 while (!this->munitions_.empty()) 73 { delete (this->munitions_.begin()->second); this->munitions_.erase(this->munitions_.begin()); }73 { this->munitions_.begin()->second->destroy(); this->munitions_.erase(this->munitions_.begin()); } 74 74 } 75 75 } -
code/trunk/src/orxonox/worldentities/BigExplosion.cc
r5781 r5929 90 90 this->setVelocity(velocity); 91 91 92 this->destroyTimer_.setTimer(rnd(2, 4), false, this, createExecutor(createFunctor(&BigExplosion::stop)));92 this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&BigExplosion::stop, this))); 93 93 } 94 94 this->registerVariables(); … … 226 226 { 227 227 this->debris1_->detachOgreObject(this->debrisFire1_->getParticleSystem()); 228 delete this->debrisFire1_;228 this->debrisFire1_->destroy(); 229 229 } 230 230 if (this->debrisSmoke1_) 231 231 { 232 232 this->debris1_->detachOgreObject(this->debrisSmoke1_->getParticleSystem()); 233 delete this->debrisSmoke1_;233 this->debrisSmoke1_->destroy(); 234 234 } 235 235 … … 237 237 { 238 238 this->debris2_->detachOgreObject(this->debrisFire2_->getParticleSystem()); 239 delete this->debrisFire2_;239 this->debrisFire2_->destroy(); 240 240 } 241 241 if (this->debrisSmoke2_) 242 242 { 243 243 this->debris2_->detachOgreObject(this->debrisSmoke2_->getParticleSystem()); 244 delete this->debrisSmoke2_;244 this->debrisSmoke2_->destroy(); 245 245 } 246 246 … … 248 248 { 249 249 this->debris3_->detachOgreObject(this->debrisFire3_->getParticleSystem()); 250 delete this->debrisFire3_;250 this->debrisFire3_->destroy(); 251 251 } 252 252 if (this->debrisSmoke3_) 253 253 { 254 254 this->debris3_->detachOgreObject(this->debrisSmoke3_->getParticleSystem()); 255 delete this->debrisSmoke3_;255 this->debrisSmoke3_->destroy(); 256 256 } 257 257 … … 259 259 { 260 260 this->debris4_->detachOgreObject(this->debrisFire4_->getParticleSystem()); 261 delete this->debrisFire4_;261 this->debrisFire4_->destroy(); 262 262 } 263 263 if (this->debrisSmoke4_) 264 264 { 265 265 this->debris4_->detachOgreObject(this->debrisSmoke4_->getParticleSystem()); 266 delete this->debrisSmoke4_;266 this->debrisSmoke4_->destroy(); 267 267 } 268 268 } … … 329 329 { 330 330 this->bStop_ = true; 331 this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&BigExplosion::destroy))); 332 } 333 } 334 335 void BigExplosion::destroy() 336 { 337 delete this; 331 this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&BigExplosion::destroy, this))); 332 } 338 333 } 339 334 -
code/trunk/src/orxonox/worldentities/BigExplosion.h
r5781 r5929 57 57 void checkStop(); 58 58 void stop(); 59 void destroy();60 59 void init(); 61 60 void initZero(); … … 98 97 ParticleInterface* explosionFire_; 99 98 100 LODParticle::Value 101 Timer <BigExplosion>destroyTimer_;99 LODParticle::Value LOD_; 100 Timer destroyTimer_; 102 101 }; 103 102 } -
code/trunk/src/orxonox/worldentities/CameraPosition.cc
r5781 r5929 46 46 this->bRenderCamera_ = false; 47 47 48 this->set ObjectMode(0x0);48 this->setSyncMode(0x0); 49 49 } 50 50 -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r5781 r5929 96 96 97 97 if (this->xmlcontroller_) 98 delete this->xmlcontroller_;98 this->xmlcontroller_->destroy(); 99 99 100 100 if (this->hud_) 101 delete this->hud_;101 this->hud_->destroy(); 102 102 103 103 if (this->camera_) 104 delete this->camera_;105 106 for (std::list< CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)107 delete (*it);104 this->camera_->destroy(); 105 106 for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 107 (*it)->destroy(); 108 108 109 109 if (this->getScene()->getSceneManager()) … … 153 153 { 154 154 unsigned int i = 0; 155 for (std::list< CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)155 for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 156 156 { 157 157 if (i == index) … … 172 172 else if (this->cameraPositions_.size() > 0) 173 173 { 174 for (std::list< CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)174 for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 175 175 { 176 176 if ((*it) == this->camera_->getParent()) … … 238 238 { 239 239 this->client_overwrite_ = this->server_overwrite_; 240 this->set ObjectMode(ObjectDirection::Bidirectional);240 this->setSyncMode(ObjectDirection::Bidirectional); 241 241 } 242 242 } … … 254 254 this->bHasLocalController_ = false; 255 255 this->bHasHumanController_ = false; 256 this->set ObjectMode(ObjectDirection::ToClient);256 this->setSyncMode(ObjectDirection::ToClient); 257 257 258 258 this->changedPlayer(); 259 259 260 260 if (this->bDestroyWhenPlayerLeft_) 261 delete this;261 this->destroy(); 262 262 } 263 263 … … 275 275 void ControllableEntity::startLocalHumanControl() 276 276 { 277 if (!this->camera_ )277 if (!this->camera_ && GameMode::showsGraphics()) 278 278 { 279 279 this->camera_ = new Camera(this); … … 287 287 } 288 288 289 if (!this->hud_ )289 if (!this->hud_ && GameMode::showsGraphics()) 290 290 { 291 291 if (this->hudtemplate_ != "") … … 303 303 { 304 304 this->camera_->detachFromParent(); 305 delete this->camera_;305 this->camera_->destroy(); 306 306 this->camera_ = 0; 307 307 } … … 309 309 if (this->hud_) 310 310 { 311 delete this->hud_;311 this->hud_->destroy(); 312 312 this->hud_ = 0; 313 313 } … … 333 333 if (parent) 334 334 { 335 for (std::list< CameraPosition*>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)335 for (std::list<SmartPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 336 336 if ((*it)->getIsAbsolute()) 337 337 parent->attach((*it)); -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r5781 r5929 104 104 void addCameraPosition(CameraPosition* position); 105 105 CameraPosition* getCameraPosition(unsigned int index) const; 106 inline const std::list< CameraPosition*>& getCameraPositions() const106 inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const 107 107 { return this->cameraPositions_; } 108 108 … … 198 198 float mouseLookSpeed_; 199 199 Ogre::SceneNode* cameraPositionRootNode_; 200 std::list< CameraPosition*> cameraPositions_;200 std::list<SmartPtr<CameraPosition> > cameraPositions_; 201 201 std::string cameraPositionTemplate_; 202 202 Controller* xmlcontroller_; -
code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
r5781 r5929 79 79 this->setVelocity(velocity); 80 80 81 this->destroyTimer_.setTimer(rnd(1, 2), false, this, createExecutor(createFunctor(&ExplosionChunk::stop)));81 this->destroyTimer_.setTimer(rnd(1, 2), false, createExecutor(createFunctor(&ExplosionChunk::stop, this))); 82 82 } 83 83 … … 92 92 { 93 93 this->detachOgreObject(this->fire_->getParticleSystem()); 94 delete this->fire_;94 this->fire_->destroy(); 95 95 } 96 96 if (this->smoke_) 97 97 { 98 98 this->detachOgreObject(this->smoke_->getParticleSystem()); 99 delete this->smoke_;99 this->smoke_->destroy(); 100 100 } 101 101 } … … 132 132 { 133 133 this->bStop_ = true; 134 this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&ExplosionChunk::destroy)));134 this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&ExplosionChunk::destroy, this))); 135 135 } 136 }137 138 void ExplosionChunk::destroy()139 {140 delete this;141 136 } 142 137 -
code/trunk/src/orxonox/worldentities/ExplosionChunk.h
r5781 r5929 55 55 void checkStop(); 56 56 void stop(); 57 void destroy();58 57 59 58 bool bStop_; 60 59 ParticleInterface* fire_; 61 60 ParticleInterface* smoke_; 62 LODParticle::Value 63 Timer <ExplosionChunk>destroyTimer_;61 LODParticle::Value LOD_; 62 Timer destroyTimer_; 64 63 }; 65 64 } -
code/trunk/src/orxonox/worldentities/MovableEntity.cc
r5781 r5929 61 61 if (this->isInitialized()) 62 62 if (this->continuousResynchroTimer_) 63 delete this->continuousResynchroTimer_;63 this->continuousResynchroTimer_->destroy(); 64 64 } 65 65 … … 98 98 void MovableEntity::clientConnected(unsigned int clientID) 99 99 { 100 this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)));100 this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, createExecutor(createFunctor(&MovableEntity::resynchronize, this))); 101 101 } 102 102 … … 110 110 { 111 111 // Resynchronise every few seconds because we only work with velocities (no positions) 112 continuousResynchroTimer_ = new Timer <MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),113 true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);112 continuousResynchroTimer_ = new Timer(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1), 113 true, createExecutor(createFunctor(&MovableEntity::resynchronize, this)), false); 114 114 } 115 115 -
code/trunk/src/orxonox/worldentities/MovableEntity.h
r5781 r5929 96 96 Quaternion overwrite_orientation_; 97 97 98 Timer <MovableEntity>resynchronizeTimer_;99 Timer <MovableEntity>* continuousResynchroTimer_;98 Timer resynchronizeTimer_; 99 Timer* continuousResynchroTimer_; 100 100 101 101 Pawn* owner_; -
code/trunk/src/orxonox/worldentities/SpawnPoint.cc
r5781 r5929 50 50 COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl; 51 51 52 this->set ObjectMode(0x0);52 this->setSyncMode(0x0); 53 53 } 54 54 -
code/trunk/src/orxonox/worldentities/SpawnPoint.h
r5781 r5929 33 33 34 34 #include <string> 35 #include "core/ Identifier.h"35 #include "core/SubclassIdentifier.h" 36 36 #include "worldentities/StaticEntity.h" 37 37 -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r5781 r5929 119 119 { 120 120 if ((*it)->getDeleteWithParent()) 121 delete (*(it++));121 (*(it++))->destroy(); 122 122 else 123 123 { … … 132 132 delete this->physicalBody_; 133 133 } 134 delete this->collisionShape_;134 this->collisionShape_->destroy(); 135 135 136 136 this->node_->detachAllObjects(); … … 175 175 void WorldEntity::registerVariables() 176 176 { 177 registerVariable(this->mainStateName_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState ));177 registerVariable(this->mainStateName_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainStateName)); 178 178 179 179 registerVariable(this->bActive_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); -
code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc
r5781 r5929 40 40 RegisterObject(Destroyer); 41 41 42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype() );42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get()); 43 43 if (gametype) 44 44 { -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r5781 r5929 36 36 #include "network/NetworkFunction.h" 37 37 38 #include "interfaces/PawnListener.h"39 38 #include "PawnManager.h" 40 39 #include "infos/PlayerInfo.h" … … 93 92 if (this->isInitialized()) 94 93 { 95 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)96 it->destroyedPawn(this);97 98 94 if (this->weaponSystem_) 99 delete this->weaponSystem_;95 this->weaponSystem_->destroy(); 100 96 } 101 97 } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r5781 r5929 75 75 { 76 76 if (this->isInitialized() && this->engine_) 77 delete this->engine_;77 this->engine_->destroy(); 78 78 } 79 79 … … 207 207 else 208 208 { 209 delete object;209 object->destroy(); 210 210 } 211 211 } -
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r5781 r5929 145 145 ControllableEntity::setPlayer(player); 146 146 147 // this->set ObjectMode(ObjectDirection::ToClient);147 // this->setSyncMode(ObjectDirection::ToClient); 148 148 } 149 149 -
code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r5781 r5929 31 31 32 32 #include "core/CoreIncludes.h" 33 #include " interfaces/PawnListener.h"33 #include "controllers/ArtificialController.h" 34 34 #include "interfaces/TeamColourable.h" 35 35 #include "gametypes/TeamBaseMatch.h" … … 45 45 this->state_ = BaseState::Uncontrolled; 46 46 47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype() );47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get()); 48 48 if (gametype) 49 49 { … … 58 58 this->fireEvent(); 59 59 60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype() );60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get()); 61 61 if (!gametype) 62 62 return; … … 92 92 93 93 // Call this so bots stop shooting at the base after they converted it 94 for (ObjectList< PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)95 it-> destroyedPawn(this);94 for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it) 95 it->abandonTarget(this); 96 96 } 97 97 }
Note: See TracChangeset
for help on using the changeset viewer.