Changeset 2361
- Timestamp:
- Dec 9, 2008, 2:07:24 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/core/Core.cc
r2344 r2361 56 56 RegisterRootObject(Core); 57 57 58 assert(singletonRef_s == 0); 59 singletonRef_s = this; 58 assert(this->singletonRef_s == 0); 59 this->singletonRef_s = this; 60 this->bInitializeRandomNumberGenerator_ = false; 60 61 61 62 this->setConfigValues(); … … 80 81 SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged); 81 82 SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged); 83 SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator); 82 84 } 83 85 … … 174 176 ResetConfigValue(language_); 175 177 } 178 179 void Core::initializeRandomNumberGenerator() 180 { 181 static bool bInitialized = false; 182 if (!bInitialized && this->bInitializeRandomNumberGenerator_) 183 { 184 srand(time(0)); 185 rand(); 186 bInitialized = true; 187 } 188 } 176 189 } -
code/branches/objecthierarchy2/src/core/Core.h
r2344 r2361 78 78 Core(const Core&); 79 79 void resetLanguageIntern(); 80 void initializeRandomNumberGenerator(); 80 81 81 82 int softDebugLevel_; //!< The debug level … … 84 85 int softDebugLevelShell_; //!< The debug level for the ingame shell 85 86 std::string language_; //!< The language 87 bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called 86 88 87 89 static bool bShowsGraphics_s; //!< global variable that tells whether to show graphics -
code/branches/objecthierarchy2/src/core/Super.h
r2257 r2361 99 99 \ 100 100 static void apply(void* temp) {} \ 101 \ 101 102 static void apply(baseclass* temp) \ 102 103 { \ … … 104 105 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \ 105 106 { \ 107 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 108 { \ 109 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \ 110 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \ 111 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \ 112 } \ 113 \ 106 114 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 107 115 { \ … … 163 171 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) 164 172 { 173 // Check if the caller is a fallback-caller 174 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) 175 { 176 // Delete the fallback caller an prepare to get a real caller 177 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; 178 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; 179 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; 180 } 181 165 182 // Check if there's not already a caller 166 183 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) … … 183 200 struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \ 184 201 { \ 185 // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)202 // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1) 186 203 static void check() \ 187 204 { \ … … 301 318 }; \ 302 319 \ 320 class _CoreExport SuperFunctionCaller_##functionname \ 321 { \ 322 public: \ 323 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \ 324 virtual ~SuperFunctionCaller_##functionname () {} \ 325 }; \ 326 \ 327 template <class T> \ 328 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \ 329 { \ 330 public: \ 331 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \ 332 { \ 333 } \ 334 }; \ 335 \ 303 336 template <class T> \ 304 337 struct SuperFunctionInitialization<functionnumber, T> \ … … 306 339 static void initialize(ClassIdentifier<T>* identifier) \ 307 340 { \ 308 identifier->superFunctionCaller_##functionname##_ = 0; \ 341 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \ 342 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \ 309 343 SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \ 310 344 } \ … … 322 356 }; \ 323 357 \ 324 class _CoreExport SuperFunctionCaller_##functionname \325 { \326 public: \327 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \328 virtual ~SuperFunctionCaller_##functionname () {} \329 }; \330 \331 358 template <class T> \ 332 359 class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \ … … 375 402 }; 376 403 377 // Initializes the SuperFunctionCaller-pointer with zero. 404 // Baseclass of the super-function caller. The real call will be done by a 405 // templatized subclass through the virtual () operator. 406 class _CoreExport SuperFunctionCaller_##functionname 407 { 408 public: 409 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; 410 virtual ~SuperFunctionCaller_##functionname () {} 411 }; 412 413 // Fallback if the base is pure virtual 414 template <class T> 415 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname 416 { 417 public: 418 // Fallback does nothing 419 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) 420 { 421 } 422 }; 423 424 // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual 378 425 template <class T> 379 426 struct SuperFunctionInitialization<functionnumber, T> … … 381 428 static void initialize(ClassIdentifier<T>* identifier) 382 429 { 383 identifier->superFunctionCaller_##functionname##_ = 0; 430 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; 431 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; 384 432 385 433 // Calls the initialization of the next super-function (functionnumber + 1) … … 400 448 SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); 401 449 } 402 };403 404 // Baseclass of the super-function caller. The real call will be done by a405 // templatized subclass through the virtual () operator.406 class _CoreExport SuperFunctionCaller_##functionname407 {408 public:409 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;410 virtual ~SuperFunctionCaller_##functionname () {}411 450 }; 412 451 … … 497 536 #ifndef SUPER_INTRUSIVE_DECLARATION 498 537 #define SUPER_INTRUSIVE_DECLARATION(functionname) \ 499 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_ 538 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \ 539 bool bSuperFunctionCaller_##functionname##_isFallback_ 500 540 #endif 501 541 -
code/branches/objecthierarchy2/src/orxonox/objects/Radar.cc
r2256 r2361 99 99 void Radar::tick(float dt) 100 100 { 101 SUPER(Radar, tick, dt); 102 101 103 if (this->focus_ != *(this->itFocus_)) 102 104 { -
code/branches/objecthierarchy2/src/orxonox/objects/Scene.cc
r2171 r2361 167 167 void Scene::tick(float dt) 168 168 { 169 SUPER(Scene, tick, dt); 170 169 171 if (!Core::showsGraphics()) 170 172 { -
code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc
r2171 r2361 62 62 void Gametype::tick(float dt) 63 63 { 64 SUPER(Gametype, tick, dt); 65 64 66 if (this->bStartCountdownRunning_ && !this->bStarted_) 65 67 this->startCountdown_ -= dt; … … 150 152 if (this->spawnpoints_.size() > 0) 151 153 { 152 srand(time(0));153 rnd();154 155 154 unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size()); 156 155 unsigned int index = 0; -
code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.cc
r2350 r2361 144 144 return; 145 145 146 SUPER(Engine, tick, dt); 147 146 148 const Vector3& direction = this->getDirection(); 147 149 Vector3 velocity = this->ship_->getVelocity(); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2171 r2361 75 75 void BlinkingBillboard::tick(float dt) 76 76 { 77 SUPER(BlinkingBillboard, tick, dt); 78 77 79 if (Core::isMaster() && this->isActive()) 78 80 { -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc
r2350 r2361 94 94 void Camera::tick(float dt) 95 95 { 96 SUPER(Camera, tick, dt); 96 97 /* 97 98 // this stuff here may need some adjustments -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc
r2256 r2361 232 232 if (this->isActive()) 233 233 { 234 SUPER(ControllableEntity, tick, dt); 235 234 236 this->velocity_ += (dt * this->acceleration_); 235 237 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/FadingBillboard.cc
r2254 r2361 140 140 void FadingBillboard::tick(float dt) 141 141 { 142 SUPER(FadingBillboard, tick, dt); 143 142 144 if (this->changedirection_ > 0 && (this->fadedColour_.a < this->getColour().a)) 143 145 { -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/MovableEntity.cc
r2171 r2361 74 74 if (this->isActive()) 75 75 { 76 SUPER(MovableEntity, tick, dt); 77 76 78 this->velocity_ += (dt * this->acceleration_); 77 79 this->node_->translate(dt * this->velocity_); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/triggers/Trigger.cc
r2171 r2361 106 106 if (!this->BaseObject::isActive()) 107 107 return; 108 109 SUPER(Trigger, tick, dt); 108 110 109 111 bool newTriggered = this->isTriggered() ^ this->bInvertMode_; -
code/branches/objecthierarchy2/src/orxonox/overlays/debug/DebugFPSText.cc
r2087 r2361 49 49 void DebugFPSText::tick(float dt) 50 50 { 51 SUPER(DebugFPSText, tick, dt); 52 51 53 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 54 this->setCaption(convertToString(fps)); -
code/branches/objecthierarchy2/src/orxonox/overlays/debug/DebugRTRText.cc
r2087 r2361 49 49 void DebugRTRText::tick(float dt) 50 50 { 51 SUPER(DebugRTRText, tick, dt); 52 51 53 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 54 this->setCaption(convertToString(rtr)); -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDNavigation.cc
r2087 r2361 129 129 void HUDNavigation::tick(float dt) 130 130 { 131 SUPER(HUDNavigation, tick, dt); 132 131 133 if (!Radar::getInstance().getFocus()) 132 134 { -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2256 r2361 52 52 void HUDSpeedBar::tick(float dt) 53 53 { 54 SUPER(HUDSpeedBar, tick, dt); 55 54 56 if (this->owner_ && this->owner_->getEngine()) 55 57 { -
code/branches/objecthierarchy2/src/orxonox/tools/Shader.cc
r2358 r2361 101 101 void Shader::tick(float dt) 102 102 { 103 SUPER(Shader, tick, dt); 104 103 105 if (this->bLoadCompositor_ && !this->bViewportInitialized_ && this->scenemanager_ && this->scenemanager_->getCurrentViewport()) 104 106 { -
code/branches/objecthierarchy2/src/util/Convert.h
r2171 r2361 460 460 else 461 461 *output = "false"; 462 return false;462 return true; 463 463 } 464 464 };
Note: See TracChangeset
for help on using the changeset viewer.