Changeset 10624 for code/trunk/src
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 18 deleted
- 271 edited
- 28 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/CMakeLists.txt
r10268 r10624 39 39 ADD_SUBDIRECTORY(orxonox) 40 40 SET(ORXONOX_MODULES CACHE INTERNAL "") 41 SET(ORXONOX_PLUGINS CACHE INTERNAL "") 41 42 ADD_SUBDIRECTORY(modules) 42 43 … … 72 73 OUTPUT_NAME orxonox 73 74 ) 74 # Main executable should depend on all modules 75 # Main executable should depend on all modules (but not on plugins) 75 76 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES}) 76 77 -
code/trunk/src/SpecialConfig.h.in
r8351 r10624 60 60 const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@"; 61 61 const char defaultModulePath[] = "@DEFAULT_MODULE_PATH@"; 62 const char defaultPluginPath[] = "@DEFAULT_PLUGIN_PATH@"; 62 63 const char defaultDocPath[] = "@DEFAULT_DOC_PATH@"; 63 64 const char defaultDataPath[] = "@DEFAULT_DATA_PATH@"; … … 69 70 const char dataInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIRECTORY@"; 70 71 const char moduleInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@MODULE_INSTALL_DIRECTORY@"; 72 const char pluginInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@PLUGIN_INSTALL_DIRECTORY@"; 71 73 #endif 72 74 … … 76 78 #ifdef CMAKE_CONFIGURATION_TYPES 77 79 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 80 const char pluginDevDirectory[] = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 78 81 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 79 82 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 80 83 #else 81 84 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@"; 85 const char pluginDevDirectory[] = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@"; 82 86 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@"; 83 87 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@"; … … 88 92 #endif 89 93 90 // Module extension94 // Module and plugin extension 91 95 const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@"; 96 const char pluginExtension[] = "@ORXONOX_PLUGIN_EXTENSION@"; 92 97 93 98 // OGRE PLUGINS -
code/trunk/src/libraries/core/BaseObject.cc
r9667 r10624 63 63 this->bActive_ = true; 64 64 this->bVisible_ = true; 65 this->oldGametype_ = 0;66 65 this->bRegisteredEventStates_ = false; 67 66 … … 78 77 { 79 78 this->setFile(this->creator_->getFile()); 80 this->setNamespace(this->creator_->getNamespace()); 81 this->setScene(this->creator_->getScene(), this->creator_->getSceneID()); 82 this->setGametype(this->creator_->getGametype()); 83 this->setLevel(this->creator_->getLevel()); 79 80 // store strong-pointers on all four base objects by default (can be overwritten with weak-ptr after the constructor if necessary) 81 this->setNamespace(this->creator_->namespace_.createStrongPtr()); 82 this->setScene (this->creator_->scene_ .createStrongPtr(), this->creator_->sceneID_); 83 this->setGametype (this->creator_->gametype_ .createStrongPtr()); 84 this->setLevel (this->creator_->level_ .createStrongPtr()); 84 85 } 85 86 else 86 87 { 87 88 this->file_ = 0; 88 this->namespace_ = 0;89 this->scene_ = 0;90 89 this->sceneID_ = OBJECTID_UNKNOWN; 91 this->gametype_ = 0;92 this->level_ = 0;93 90 } 94 91 } -
code/trunk/src/libraries/core/BaseObject.h
r10298 r10624 51 51 #include "class/OrxonoxClass.h" 52 52 #include "class/Super.h" 53 #include "object/S martPtr.h"53 #include "object/StrongPtr.h" 54 54 55 55 namespace orxonox … … 63 63 { 64 64 template <class T> friend class XMLPortClassParamContainer; 65 66 public: 67 template <class T> 68 class StrongOrWeakPtr 69 { 70 public: 71 inline StrongOrWeakPtr(); 72 inline StrongOrWeakPtr(const StrongPtr<T>& ptr); 73 inline StrongOrWeakPtr(const WeakPtr<T>& ptr); 74 75 inline T* get() const; 76 inline StrongPtr<T> createStrongPtr() const; 77 78 private: 79 StrongPtr<T> strongPtr_; 80 WeakPtr<T> weakPtr_; 81 }; 65 82 66 83 public: … … 138 155 { return this->templates_; } 139 156 140 inline void setNamespace(const S martPtr<Namespace>& ns) { this->namespace_ = ns; }141 inline const SmartPtr<Namespace>& getNamespace() const { return this->namespace_; }157 inline void setNamespace(const StrongOrWeakPtr<Namespace>& ns) { this->namespace_ = ns; } 158 inline Namespace* getNamespace() const { return this->namespace_.get(); } 142 159 143 160 inline void setCreator(BaseObject* creator) { this->creator_ = creator; } 144 161 inline BaseObject* getCreator() const { return this->creator_; } 145 162 146 inline void setScene(const S martPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }147 inline const SmartPtr<Scene>& getScene() const { return this->scene_; }163 inline void setScene(const StrongOrWeakPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; } 164 inline Scene* getScene() const { return this->scene_.get(); } 148 165 inline virtual uint32_t getSceneID() const { return this->sceneID_; } 149 166 150 inline void setGametype(const SmartPtr<Gametype>& gametype) 151 { 152 if (gametype != this->gametype_) 153 { 154 this->oldGametype_ = this->gametype_; 155 this->gametype_ = gametype; 156 this->changedGametype(); 157 } 158 } 159 inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; } 160 inline Gametype* getOldGametype() const { return this->oldGametype_; } 161 virtual void changedGametype() {} 162 163 inline void setLevel(const SmartPtr<Level>& level) 164 { 165 if (level != this->level_) 166 { 167 this->level_ = level; 168 this->changedLevel(); 169 } 170 } 171 inline const SmartPtr<Level>& getLevel() const { return this->level_; } 172 virtual void changedLevel() {} 167 inline void setGametype(const StrongOrWeakPtr<Gametype>& gametype) { this->gametype_ = gametype; } 168 inline Gametype* getGametype() const { return this->gametype_.get(); } 169 170 inline void setLevel(const StrongOrWeakPtr<Level>& level) { this->level_ = level; } 171 inline Level* getLevel() const { return this->level_.get(); } 173 172 174 173 void addEventSource(BaseObject* source, const std::string& state); … … 217 216 void registerEventStates(); 218 217 219 bool bInitialized_;//!< True if the object was initialized (passed the object registration)220 const XMLFile* file_;//!< The XMLFile that loaded this object221 Element* lastLoadedXMLElement_;//!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map218 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 219 const XMLFile* file_; //!< The XMLFile that loaded this object 220 Element* lastLoadedXMLElement_; //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map 222 221 std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes 223 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 224 SmartPtr<Namespace> namespace_; 225 BaseObject* creator_; 226 SmartPtr<Scene> scene_; 227 uint32_t sceneID_; 228 SmartPtr<Gametype> gametype_; 229 Gametype* oldGametype_; 230 SmartPtr<Level> level_; 231 std::set<Template*> templates_; 222 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 223 StrongOrWeakPtr<Namespace> namespace_; 224 BaseObject* creator_; 225 StrongOrWeakPtr<Scene> scene_; 226 uint32_t sceneID_; 227 StrongOrWeakPtr<Gametype> gametype_; 228 StrongOrWeakPtr<Level> level_; 229 std::set<Template*> templates_; 232 230 233 231 std::map<BaseObject*, std::string> eventSources_; //!< List of objects which send events to this object, mapped to the state which they affect … … 243 241 SUPER_FUNCTION(4, BaseObject, XMLEventPort, false); 244 242 SUPER_FUNCTION(8, BaseObject, changedName, false); 245 SUPER_FUNCTION(9, BaseObject, changedGametype, false); 243 244 template <class T> 245 BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr() 246 { 247 } 248 249 template <class T> 250 BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const StrongPtr<T>& ptr) : strongPtr_(ptr) 251 { 252 } 253 254 template <class T> 255 BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const WeakPtr<T>& ptr) : weakPtr_(ptr) 256 { 257 } 258 259 template <class T> 260 T* BaseObject::StrongOrWeakPtr<T>::get() const 261 { 262 if (this->strongPtr_) 263 return this->strongPtr_; 264 else if (this->weakPtr_) 265 return this->weakPtr_; 266 else 267 return NULL; 268 } 269 270 template <class T> 271 StrongPtr<T> BaseObject::StrongOrWeakPtr<T>::createStrongPtr() const 272 { 273 if (this->strongPtr_) 274 return this->strongPtr_; // creates a copy 275 else 276 return this->weakPtr_; // converts automatically to StrongPtr 277 } 246 278 } 247 279 -
code/trunk/src/libraries/core/CMakeLists.txt
r10268 r10624 22 22 #BUILD_UNIT CoreStableBuildUnit.cc 23 23 ClassTreeMask.cc 24 DynLib.cc25 DynLibManager.cc26 24 Event.cc 27 25 Game.cc 26 GameConfig.cc 28 27 GameMode.cc 29 28 GameState.cc … … 34 33 NamespaceNode.cc 35 34 Template.cc 35 UpdateListener.cc 36 36 ViewportEventListener.cc 37 37 WindowEventListener.cc … … 42 42 BaseObject.cc 43 43 Core.cc 44 CoreConfig.cc 45 CoreStaticInitializationHandler.cc 44 46 45 47 BUILD_UNIT OgreBuildUnit.cc … … 52 54 command/ArgumentCompletionFunctions.cc 53 55 config/ConfigFile.cc 54 PathConfig.cc 56 ApplicationPaths.cc 57 ConfigurablePaths.cc 55 58 END_BUILD_UNIT 56 59 … … 64 67 ADD_SUBDIRECTORY(class) 65 68 ADD_SUBDIRECTORY(command) 69 ADD_SUBDIRECTORY(commandline) 66 70 ADD_SUBDIRECTORY(config) 67 71 ADD_SUBDIRECTORY(input) 72 ADD_SUBDIRECTORY(module) 68 73 ADD_SUBDIRECTORY(object) 74 ADD_SUBDIRECTORY(singleton) 69 75 70 76 #Add the icon (for the renderwindow) … … 78 84 command/CommandExecutor.h 79 85 config/SettingsConfigFile.h 86 ApplicationPaths.h 87 ConfigurablePaths.h 80 88 Game.h 81 89 GameMode.h … … 84 92 Loader.h 85 93 LuaState.h 86 PathConfig.h87 94 input/InputManager.h 88 95 input/KeyBinder.h -
code/trunk/src/libraries/core/ClassTreeMask.cc
r9667 r10624 293 293 { 294 294 // No it's not: Search for classes inheriting from the given class and add the rules for them 295 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren Begin(); it != subclass->getDirectChildrenEnd(); ++it)295 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it) 296 296 if ((*it)->isA(this->root_->getClass())) 297 297 if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist … … 392 392 if (!subclass) 393 393 return; 394 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren Begin(); it != subclass->getDirectChildrenEnd(); ++it)394 for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it) 395 395 this->add(*it, this->isIncluded(*it), false, false); 396 396 … … 943 943 944 944 // Insert all directChildren of the directChild 945 directChildren.insert((*it2)->getDirectChildren Begin(), (*it2)->getDirectChildrenEnd());945 directChildren.insert((*it2)->getDirectChildren().begin(), (*it2)->getDirectChildren().end()); 946 946 947 947 // Restart the scan with the expanded set of directChildren -
code/trunk/src/libraries/core/Core.cc
r9667 r10624 54 54 #include "util/Output.h" 55 55 #include "util/Exception.h" 56 #include "util/SignalHandler.h" 56 57 #include "util/output/LogWriter.h" 57 58 #include "util/output/OutputManager.h" 58 #include "util/Scope.h" 59 #include "util/ScopedSingletonManager.h" 60 #include "util/SignalHandler.h" 61 #include "PathConfig.h" 62 #include "config/CommandLineParser.h" 59 #include "core/singleton/Scope.h" 60 #include "ApplicationPaths.h" 61 #include "ConfigurablePaths.h" 62 #include "commandline/CommandLineIncludes.h" 63 63 #include "config/ConfigFileManager.h" 64 #include "config/ConfigValueIncludes.h"65 #include "CoreIncludes.h"66 #include "DynLibManager.h"67 64 #include "GameMode.h" 68 65 #include "GraphicsManager.h" 69 66 #include "GUIManager.h" 70 #include "class/Identifier.h"71 67 #include "Language.h" 68 #include "Loader.h" 72 69 #include "LuaState.h" 73 #include "command/ConsoleCommand.h"74 70 #include "command/IOConsole.h" 75 71 #include "command/TclBind.h" … … 77 73 #include "input/InputManager.h" 78 74 #include "object/ObjectList.h" 75 #include "module/DynLibManager.h" 76 #include "module/ModuleInstance.h" 77 #include "module/StaticInitializationManager.h" 78 #include "module/PluginManager.h" 79 #include "CoreStaticInitializationHandler.h" 80 #include "UpdateListener.h" 79 81 80 82 namespace orxonox … … 92 94 #endif 93 95 94 // register Core as an abstract class to avoid problems if the class hierarchy is created within Core-constructor95 RegisterAbstractClass(Core).inheritsFrom(Class(Configurable));96 97 96 Core::Core(const std::string& cmdLine) 98 : pathConfig_(NULL) 97 : applicationPaths_(NULL) 98 , configurablePaths_(NULL) 99 99 , dynLibManager_(NULL) 100 100 , signalHandler_(NULL) 101 101 , configFileManager_(NULL) 102 102 , languageInstance_(NULL) 103 , loaderInstance_(NULL) 103 104 , ioConsole_(NULL) 104 105 , tclBind_(NULL) … … 110 111 , graphicsScope_(NULL) 111 112 , bGraphicsLoaded_(false) 112 , bStartIOConsole_(true)113 , lastLevelTimestamp_(0)114 , ogreConfigTimestamp_(0)115 , bDevMode_(false)113 , staticInitHandler_(NULL) 114 , pluginManager_(NULL) 115 , rootModule_(NULL) 116 , config_(NULL) 116 117 , destructionHelper_(this) 117 118 { … … 119 120 120 121 // Set the hard coded fixed paths 121 this-> pathConfig_ = new PathConfig();122 this->applicationPaths_ = new ApplicationPaths(); 122 123 123 124 // Create a new dynamic library manager 124 125 this->dynLibManager_ = new DynLibManager(); 125 126 126 // Load modules 127 orxout(internal_info) << "Loading modules:" << endl; 128 const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths(); 129 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it) 130 { 131 try 132 { 133 this->dynLibManager_->load(*it); 134 } 135 catch (...) 136 { 137 orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl; 138 } 139 } 127 // create handler for static initialization 128 new StaticInitializationManager(); // create singleton 129 this->staticInitHandler_ = new CoreStaticInitializationHandler(); 130 StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_); 131 132 // load root module (all libraries which are linked to the executable, including core, network, and orxonox) 133 this->rootModule_ = ModuleInstance::getCurrentModuleInstance(); 134 StaticInitializationManager::getInstance().loadModule(this->rootModule_); 140 135 141 136 // Parse command line arguments AFTER the modules have been loaded (static code!) … … 143 138 144 139 // Set configurable paths like log, config and media 145 this->pathConfig_->setConfigurablePaths(); 146 147 orxout(internal_info) << "Root path: " << PathConfig::getRootPathString() << endl; 148 orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl; 149 orxout(internal_info) << "Data path: " << PathConfig::getDataPathString() << endl; 150 orxout(internal_info) << "Ext. data path: " << PathConfig::getExternalDataPathString() << endl; 151 orxout(internal_info) << "Config path: " << PathConfig::getConfigPathString() << endl; 152 orxout(internal_info) << "Log path: " << PathConfig::getLogPathString() << endl; 153 orxout(internal_info) << "Modules path: " << PathConfig::getModulePathString() << endl; 154 155 // create a signal handler (only active for Linux) 140 this->configurablePaths_ = new ConfigurablePaths(); 141 this->configurablePaths_->setConfigurablePaths(ApplicationPaths::getInstance()); 142 143 orxout(internal_info) << "Root path: " << ApplicationPaths::getRootPathString() << endl; 144 orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl; 145 orxout(internal_info) << "Modules path: " << ApplicationPaths::getModulePathString() << endl; 146 orxout(internal_info) << "Plugins path: " << ApplicationPaths::getPluginPathString() << endl; 147 148 orxout(internal_info) << "Data path: " << ConfigurablePaths::getDataPathString() << endl; 149 orxout(internal_info) << "Ext. data path: " << ConfigurablePaths::getExternalDataPathString() << endl; 150 orxout(internal_info) << "Config path: " << ConfigurablePaths::getConfigPathString() << endl; 151 orxout(internal_info) << "Log path: " << ConfigurablePaths::getLogPathString() << endl; 152 153 // create a signal handler 156 154 // This call is placed as soon as possible, but after the directories are set 157 155 this->signalHandler_ = new SignalHandler(); 158 this->signalHandler_->doCatch( PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");156 this->signalHandler_->doCatch(ApplicationPaths::getExecutablePathString(), ConfigurablePaths::getLogPathString() + "orxonox_crash.log"); 159 157 160 158 #ifdef ORXONOX_PLATFORM_WINDOWS … … 177 175 this->languageInstance_ = new Language(); 178 176 177 // initialize root context 178 Context::setRootContext(new Context(NULL)); 179 179 180 // Do this soon after the ConfigFileManager has been created to open up the 180 181 // possibility to configure everything below here 181 RegisterObject(Core);182 182 orxout(internal_info) << "configuring Core" << endl; 183 this-> setConfigValues();183 this->config_ = new CoreConfig(); 184 184 185 185 // Set the correct log path and rewrite the log file with the correct log levels 186 OutputManager::getInstance().getLogWriter()->setLogDirectory( PathConfig::getLogPathString());186 OutputManager::getInstance().getLogWriter()->setLogDirectory(ConfigurablePaths::getLogPathString()); 187 187 188 188 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) 189 189 // Create persistent IO console 190 if (CommandLineParser::getValue("noIOConsole").get<bool>()) 191 { 192 ModifyConfigValue(bStartIOConsole_, tset, false); 193 } 194 if (this->bStartIOConsole_) 190 if (CommandLineParser::getValue("noIOConsole").get<bool>() == false && this->config_->getStartIOConsole()) 195 191 { 196 192 orxout(internal_info) << "creating IO console" << endl; … … 201 197 // creates the class hierarchy for all classes with factories 202 198 orxout(internal_info) << "creating class hierarchy" << endl; 203 IdentifierManager::getInstance().createClassHierarchy(); 199 this->staticInitHandler_->initInstances(this->rootModule_); 200 this->staticInitHandler_->setInitInstances(true); 201 202 // Create plugin manager and search for plugins 203 this->pluginManager_ = new PluginManager(); 204 this->pluginManager_->findPlugins(); 205 206 // Loader 207 this->loaderInstance_ = new Loader(); 204 208 205 209 // Load OGRE excluding the renderer and the render window … … 208 212 209 213 // initialise Tcl 210 this->tclBind_ = new TclBind( PathConfig::getDataPathString());214 this->tclBind_ = new TclBind(ConfigurablePaths::getDataPathString()); 211 215 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 212 216 213 217 // Create singletons that always exist (in other libraries) 214 218 orxout(internal_info) << "creating root scope:" << endl; 215 this->rootScope_ = new Scope<ScopeID::R oot>();219 this->rootScope_ = new Scope<ScopeID::ROOT>(); 216 220 217 221 // Generate documentation instead of normal run? … … 237 241 orxout(internal_status) << "destroying Core object..." << endl; 238 242 239 // Remove us from the object lists again to avoid problems when destroying them240 this->unregisterObject();241 242 243 safeObjectDelete(&graphicsScope_); 243 244 safeObjectDelete(&guiManager_); … … 248 249 safeObjectDelete(&tclBind_); 249 250 safeObjectDelete(&ioConsole_); 251 safeObjectDelete(&loaderInstance_); 252 safeObjectDelete(&config_); 250 253 safeObjectDelete(&languageInstance_); 251 254 safeObjectDelete(&configFileManager_); 252 ConsoleCommand::destroyAll();253 Context::setRootContext(NULL);254 IdentifierManager::getInstance().destroyAllIdentifiers();255 255 safeObjectDelete(&signalHandler_); 256 safeObjectDelete(&pluginManager_); 257 Context::getRootContext()->unregisterObject(); // unregister context from object lists - otherwise the root context would be destroyed while unloading the root module 258 if (this->rootModule_) 259 { 260 StaticInitializationManager::getInstance().unloadModule(this->rootModule_); 261 this->rootModule_->deleteAllStaticallyInitializedInstances(); 262 } 263 if (this->staticInitHandler_) 264 StaticInitializationManager::getInstance().removeHandler(this->staticInitHandler_); 265 Context::destroyRootContext(); 266 safeObjectDelete(&rootModule_); 267 safeObjectDelete(&staticInitHandler_); 268 delete &StaticInitializationManager::getInstance(); 256 269 safeObjectDelete(&dynLibManager_); 257 safeObjectDelete(&pathConfig_); 270 safeObjectDelete(&configurablePaths_); 271 safeObjectDelete(&applicationPaths_); 258 272 259 273 orxout(internal_status) << "finished destroying Core object" << endl; 260 274 } 261 275 262 //! Function to collect the SetConfigValue-macro calls. 263 void Core::setConfigValues() 264 { 265 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_, 266 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(), 267 OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(), 268 OutputManager::getInstance().getLogWriter()->configurableMaxLevel_) 269 .description("The maximum level of output shown in the log file") 270 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel); 271 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_, 272 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(), 273 OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(), 274 OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_) 275 .description("The maximum level of output shown in the log file for additional contexts") 276 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel); 277 SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_, 278 OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(), 279 OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(), 280 OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_) 281 .description("Additional output contexts shown in the log file") 282 .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts); 283 284 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun()) 285 .description("Developer mode. If not set, hides some things from the user to not confuse him.") 286 .callback(this, &Core::devModeChanged); 287 SetConfigValue(language_, Language::getInstance().defaultLanguage_) 288 .description("The language of the in game text") 289 .callback(this, &Core::languageChanged); 290 SetConfigValue(bInitRandomNumberGenerator_, true) 291 .description("If true, all random actions are different each time you start the game") 292 .callback(this, &Core::initRandomNumberGenerator); 293 SetConfigValue(bStartIOConsole_, true) 294 .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)"); 295 SetConfigValue(lastLevelTimestamp_, 0) 296 .description("Timestamp when the last level was started."); 297 SetConfigValue(ogreConfigTimestamp_, 0) 298 .description("Timestamp when the ogre config file was changed."); 299 } 300 301 /** Callback function for changes in the dev mode that affect debug levels. 302 The function behaves according to these rules: 303 - 'normal' mode is defined based on where the program was launched: if 304 the launch path was the build directory, development mode \c on is 305 normal, otherwise normal means development mode \c off. 306 - Debug levels should not be hard configured (\c config instead of 307 \c tconfig) in non 'normal' mode to avoid strange behaviour. 308 - Changing the development mode from 'normal' to the other state will 309 immediately change the debug levels to predefined values which can be 310 reconfigured with \c tconfig. 311 @note 312 The debug levels for the IOConsole and the InGameConsole can be found 313 in the Shell class. The same rules apply. 314 */ 315 void Core::devModeChanged() 316 { 317 // Inform listeners 318 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin(); 319 for (; it != ObjectList<DevModeListener>::end(); ++it) 320 it->devModeChanged(bDevMode_); 321 } 322 323 //! Callback function if the language has changed. 324 void Core::languageChanged() 325 { 326 // Read the translation file after the language was configured 327 Language::getInstance().readTranslatedLanguageFile(); 328 } 329 330 void Core::initRandomNumberGenerator() 331 { 332 static bool bInitialized = false; 333 if (!bInitialized && this->bInitRandomNumberGenerator_) 334 { 335 srand(static_cast<unsigned int>(time(0))); 336 rand(); 337 bInitialized = true; 338 } 276 void Core::loadModules() 277 { 278 orxout(internal_info) << "Loading modules:" << endl; 279 280 const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths(); 281 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it) 282 { 283 ModuleInstance* module = new ModuleInstance(*it); 284 this->loadModule(module); 285 this->modules_.push_back(module); 286 } 287 288 orxout(internal_info) << "finished loading modules" << endl; 289 } 290 291 void Core::loadModule(ModuleInstance* module) 292 { 293 orxout(internal_info) << "Loading module " << module->getLibraryName() << "..." << endl; 294 295 try 296 { 297 ModuleInstance::setCurrentModuleInstance(module); 298 DynLib* dynLib = this->dynLibManager_->load(module->getLibraryName()); 299 module->setDynLib(dynLib); 300 301 StaticInitializationManager::getInstance().loadModule(module); 302 } 303 catch (...) 304 { 305 orxout(user_error) << "Couldn't load module \"" << module->getLibraryName() << "\": " << Exception::handleMessage() << endl; 306 } 307 } 308 309 void Core::unloadModules() 310 { 311 for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it) 312 { 313 ModuleInstance* module = (*it); 314 this->unloadModule(module); 315 delete module; 316 } 317 this->modules_.clear(); 318 } 319 320 void Core::unloadModule(ModuleInstance* module) 321 { 322 orxout(internal_info) << "Unloading module " << module->getLibraryName() << "..." << endl; 323 324 StaticInitializationManager::getInstance().unloadModule(module); 325 326 module->deleteAllStaticallyInitializedInstances(); 327 this->dynLibManager_->unload(module->getDynLib()); 328 module->setDynLib(NULL); 339 329 } 340 330 … … 344 334 345 335 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 346 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics );336 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics, true); 347 337 348 338 // Upgrade OGRE to receive a render window … … 385 375 // Create singletons associated with graphics (in other libraries) 386 376 orxout(internal_info) << "creating graphics scope:" << endl; 387 graphicsScope_ = new Scope<ScopeID::G raphics>();377 graphicsScope_ = new Scope<ScopeID::GRAPHICS>(); 388 378 389 379 unloader.Dismiss(); … … 392 382 } 393 383 394 void Core::unloadGraphics( )384 void Core::unloadGraphics(bool loadGraphicsManagerWithoutRenderer) 395 385 { 396 386 orxout(internal_info) << "unloading graphics in Core" << endl; 387 388 if (this->graphicsManager_) 389 this->graphicsManager_->unloadDebugOverlay(); 397 390 398 391 safeObjectDelete(&graphicsScope_); … … 403 396 // Load Ogre::Root again, but without the render system 404 397 try 405 { this->graphicsManager_ = new GraphicsManager(false); } 398 { 399 if (loadGraphicsManagerWithoutRenderer) 400 this->graphicsManager_ = new GraphicsManager(false); 401 } 406 402 catch (...) 407 403 { … … 414 410 bGraphicsLoaded_ = false; 415 411 GameMode::bShowsGraphics_s = false; 416 }417 418 //! Sets the language in the config-file back to the default.419 void Core::resetLanguage()420 {421 ResetConfigValue(language_);422 412 } 423 413 … … 470 460 void Core::preUpdate(const Clock& time) 471 461 { 472 // Update singletons before general ticking 473 ScopedSingletonManager::preUpdate<ScopeID::Root>(time); 462 // Update UpdateListeners before general ticking 463 for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it) 464 it->preUpdate(time); 474 465 if (this->bGraphicsLoaded_) 475 466 { … … 478 469 // Update GUI 479 470 this->guiManager_->preUpdate(time); 480 // Update singletons before general ticking481 ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);482 471 } 483 472 // Process console events and status line … … 490 479 void Core::postUpdate(const Clock& time) 491 480 { 492 // Update singletons just before rendering 493 ScopedSingletonManager::postUpdate<ScopeID::Root>(time); 481 // Update UpdateListeners just before rendering 482 for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it) 483 it->postUpdate(time); 494 484 if (this->bGraphicsLoaded_) 495 485 { 496 // Update singletons just before rendering497 ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);498 486 // Render (doesn't throw) 499 487 this->graphicsManager_->postUpdate(time); 500 488 } 501 489 } 502 503 void Core::updateLastLevelTimestamp()504 {505 ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));506 }507 508 void Core::updateOgreConfigTimestamp()509 {510 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));511 }512 513 514 RegisterAbstractClass(DevModeListener).inheritsFrom(Class(Listable));515 516 DevModeListener::DevModeListener()517 {518 RegisterObject(DevModeListener);519 }520 490 } -
code/trunk/src/libraries/core/Core.h
r9667 r10624 47 47 #include "util/DestructionHelper.h" 48 48 #include "util/Singleton.h" 49 #include " config/Configurable.h"49 #include "CoreConfig.h" 50 50 51 51 namespace orxonox 52 52 { 53 //! Informs about changes in the Development Mode.54 class DevModeListener : virtual public Listable55 {56 public:57 DevModeListener();58 virtual ~DevModeListener() {}59 virtual void devModeChanged(bool value) = 0;60 };61 62 53 /** 63 54 @brief … … 66 57 You should only create this singleton once because it destroys the identifiers! 67 58 */ 68 class _CoreExport Core : public Singleton<Core> , public Configurable59 class _CoreExport Core : public Singleton<Core> 69 60 { 70 61 friend class Singleton<Core>; 71 friend class Game;72 62 73 63 public: … … 86 76 void destroy(); 87 77 88 void setConfigValues(); 78 void preUpdate(const Clock& time); 79 void postUpdate(const Clock& time); 89 80 90 //! Returns the configured language. 91 const std::string& getLanguage() 92 { return this->language_; } 93 void resetLanguage(); 81 void loadGraphics(); 82 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 94 83 95 void updateLastLevelTimestamp(); 96 inline long long getLastLevelTimestamp() const 97 { return this->lastLevelTimestamp_; } 84 void loadModules(); 85 void unloadModules(); 86 void loadModule(ModuleInstance* module); 87 void unloadModule(ModuleInstance* module); 98 88 99 void updateOgreConfigTimestamp(); 100 inline long long getOgreConfigTimestamp() const 101 { return this->ogreConfigTimestamp_; } 102 103 //! Developers bit. If returns false, some options are not available as to not confuse the normal user. 104 inline bool inDevMode(void) const 105 { return this->bDevMode_; } 89 inline CoreConfig* getConfig() const 90 { return this->config_; } 106 91 107 92 private: 108 93 Core(const Core&); //!< Don't use (undefined symbol) 109 94 110 void devModeChanged();111 void languageChanged();112 void initRandomNumberGenerator();113 114 void preUpdate(const Clock& time);115 void postUpdate(const Clock& time);116 117 void loadGraphics();118 void unloadGraphics();119 120 95 void setThreadAffinity(int limitToCPU); 121 96 122 PathConfig* pathConfig_; 123 DynLibManager* dynLibManager_; 124 SignalHandler* signalHandler_; 125 ConfigFileManager* configFileManager_; 126 Language* languageInstance_; 127 IOConsole* ioConsole_; 128 TclBind* tclBind_; 129 TclThreadManager* tclThreadManager_; 130 Scope<ScopeID::Root>* rootScope_; 97 ApplicationPaths* applicationPaths_; 98 ConfigurablePaths* configurablePaths_; 99 DynLibManager* dynLibManager_; 100 SignalHandler* signalHandler_; 101 ConfigFileManager* configFileManager_; 102 Language* languageInstance_; 103 Loader* loaderInstance_; 104 IOConsole* ioConsole_; 105 TclBind* tclBind_; 106 TclThreadManager* tclThreadManager_; 107 Scope<ScopeID::ROOT>* rootScope_; 131 108 // graphical 132 GraphicsManager* graphicsManager_; //!< Interface to OGRE 133 InputManager* inputManager_; //!< Interface to OIS 134 GUIManager* guiManager_; //!< Interface to GUI 135 Scope<ScopeID::Graphics>* graphicsScope_; 109 GraphicsManager* graphicsManager_; //!< Interface to OGRE 110 InputManager* inputManager_; //!< Interface to OIS 111 GUIManager* guiManager_; //!< Interface to GUI 112 Scope<ScopeID::GRAPHICS>* graphicsScope_; 113 bool bGraphicsLoaded_; 136 114 137 bool bGraphicsLoaded_;138 std::string language_; //!< The language139 bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called140 bool bStartIOConsole_; //!< Set to false if you don't want to use the IOConsole141 long long lastLevelTimestamp_; ///< Timestamp when the last level was started 142 long long ogreConfigTimestamp_; ///< Timestamp wehen the ogre config level was modified143 bool bDevMode_; //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.115 CoreStaticInitializationHandler* staticInitHandler_; 116 PluginManager* pluginManager_; 117 ModuleInstance* rootModule_; 118 std::list<ModuleInstance*> modules_; 119 120 /// Helper object that stores the config values 121 CoreConfig* config_; 144 122 145 123 /// Helper object that executes the surrogate destructor destroy() 146 DestructionHelper<Core> destructionHelper_;124 DestructionHelper<Core> destructionHelper_; 147 125 148 static Core* singletonPtr_s;126 static Core* singletonPtr_s; 149 127 }; 150 128 } -
code/trunk/src/libraries/core/CoreIncludes.h
r10208 r10624 84 84 #include "object/ClassFactory.h" 85 85 #include "object/ObjectList.h" 86 #include "module/StaticallyInitializedInstance.h" 86 87 87 88 // resolve macro conflict on windows … … 126 127 */ 127 128 #define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \ 128 Identifier& _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)129 orxonox::SI_I& _##ClassName##Identifier = (*new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable))) 129 130 130 131 /** … … 133 134 */ 134 135 #define RegisterObject(ClassName) \ 135 if (ClassIdentifier<ClassName>::getIdentifier( #ClassName)->initializeObject(this)) \136 if (ClassIdentifier<ClassName>::getIdentifier()->initializeObject(this)) \ 136 137 return; \ 137 138 else \ … … 152 153 */ 153 154 template <class T> 154 inline Identifier ®isterClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)155 inline Identifier* registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true) 155 156 { 156 157 return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable); … … 164 165 */ 165 166 template <class T> 166 inline Identifier& registerClass(const std::string& name, Factory* factory, bool bLoadable = true) 167 { 168 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl; 169 Identifier* identifier = ClassIdentifier<T>::getIdentifier(name); 170 identifier->setFactory(factory); 171 identifier->setLoadable(bLoadable); 172 return *identifier; 167 inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true) 168 { 169 return new ClassIdentifier<T>(name, factory, bLoadable); 173 170 } 174 171 … … 211 208 return ClassIdentifier<T>::getIdentifier(); 212 209 } 210 211 212 213 214 /** 215 * The static initializer stores the parent classes of this identifier. The corresponding identifiers are later loaded. This prevents identifiers from 216 * being used before they are completely initialized. 217 */ 218 class _CoreExport StaticallyInitializedIdentifier : public StaticallyInitializedInstance 219 { 220 template <class T> 221 struct InheritsFromClass : public Identifier::InheritsFrom 222 { 223 virtual Identifier* getParent() const { return Class(T); } 224 }; 225 226 public: 227 StaticallyInitializedIdentifier(Identifier* identifier) 228 : StaticallyInitializedInstance(StaticInitialization::IDENTIFIER) 229 , identifier_(identifier) 230 {} 231 ~StaticallyInitializedIdentifier() { delete identifier_; } 232 233 virtual void load() 234 { 235 IdentifierManager::getInstance().addIdentifier(this->identifier_); 236 } 237 238 virtual void unload() 239 { 240 IdentifierManager::getInstance().removeIdentifier(this->identifier_); 241 } 242 243 inline Identifier& getIdentifier() 244 { return *this->identifier_; } 245 246 template <class T> 247 inline StaticallyInitializedIdentifier& inheritsFrom() 248 { this->identifier_->inheritsFrom(new InheritsFromClass<T>()); return *this; } 249 250 inline StaticallyInitializedIdentifier& virtualBase() 251 { this->identifier_->setVirtualBase(true); return *this; } 252 253 private: 254 Identifier* identifier_; 255 }; 256 257 typedef StaticallyInitializedIdentifier SI_I; 213 258 } 214 259 -
code/trunk/src/libraries/core/CorePrereqs.h
r9978 r10624 77 77 namespace orxonox 78 78 { 79 namespace ScopeID 80 { 81 typedef int Value; 82 83 //!A list of available scopes for the Scope template. 84 static const Value ROOT = 1; 85 static const Value GRAPHICS = 2; 86 } 87 88 namespace StaticInitialization 89 { 90 typedef int Type; 91 92 static const Type STATIC_INITIALIZATION_HANDLER = 1; 93 static const Type IDENTIFIER = 2; 94 static const Type SCOPED_SINGLETON_WRAPPER = 3; 95 static const Type COMMAND_LINE_ARGUMENT = 4; 96 static const Type CONSOLE_COMMAND = 5; 97 } 98 79 99 namespace XMLPort 80 100 { … … 123 143 T orxonox_cast(U*); 124 144 145 class ApplicationPaths; 125 146 class BaseObject; 126 147 template <class T> … … 143 164 class ConfigFileSection; 144 165 class Configurable; 166 class ConfigurablePaths; 145 167 class ConfigValueContainer; 146 168 class Context; 147 169 class Core; 170 class CoreConfig; 171 class CoreStaticInitializationHandler; 148 172 class Destroyable; 173 class DestroyLaterManager; 149 174 class DestructionListener; 150 175 class DynLib; … … 154 179 class Factory; 155 180 class Game; 181 class GameConfig; 156 182 class GameState; 157 183 struct GameStateInfo; … … 165 191 class Language; 166 192 class Listable; 193 class Loader; 167 194 class LuaFunctor; 168 195 class LuaState; 169 196 class MemoryArchive; 170 197 class MemoryArchiveFactory; 198 class ModuleInstance; 171 199 class Namespace; 172 200 class NamespaceNode; … … 182 210 class OrxonoxClass; 183 211 class OrxonoxInterface; 184 class PathConfig; 212 class Plugin; 213 class PluginManager; 214 class PluginReference; 185 215 struct ResourceInfo; 216 template <ScopeID::Value> 217 class Scope; 218 class ScopeManager; 219 class ScopedSingletonWrapper; 186 220 class SettingsConfigFile; 187 template <class T> 188 class SmartPtr; 221 class StaticallyInitializedInstance; 222 class StaticInitializationHandler; 223 class StaticInitializationManager; 224 template <class T> 225 class StrongPtr; 189 226 template <class T> 190 227 class SubclassIdentifier; … … 192 229 class Thread; 193 230 class ThreadPool; 231 class UpdateListener; 194 232 class ViewportEventListener; 195 233 template <class T> … … 210 248 class CommandEvaluation; 211 249 class ConsoleCommand; 250 class ConsoleCommandManager; 212 251 class Executor; 213 252 template <class T> -
code/trunk/src/libraries/core/GUIManager.cc
r10279 r10624 106 106 #include "GraphicsManager.h" 107 107 #include "LuaState.h" 108 #include " PathConfig.h"108 #include "ConfigurablePaths.h" 109 109 #include "Resource.h" 110 #include "command/ConsoleCommand .h"110 #include "command/ConsoleCommandIncludes.h" 111 111 #include "input/InputManager.h" 112 112 #include "input/InputState.h" … … 255 255 SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false); 256 256 257 RegisterAbstractClass(GUIManager).inheritsFrom<WindowEventListener>(); 258 257 259 /** 258 260 @brief … … 329 331 // Create our own logger to specify the filepath 330 332 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 331 ceguiLogger->setLogFilename( PathConfig::getLogPathString() + "cegui.log");333 ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log"); 332 334 ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_)); 333 335 this->ceguiLogger_ = ceguiLogger.release(); … … 833 835 /*static*/ bool GUIManager::inDevMode() 834 836 { 835 return Core::getInstance(). inDevMode();837 return Core::getInstance().getConfig()->inDevMode(); 836 838 } 837 839 -
code/trunk/src/libraries/core/Game.cc
r9667 r10624 45 45 #include "util/SubString.h" 46 46 #include "Core.h" 47 #include "CoreIncludes.h" 48 #include "config/CommandLineParser.h" 49 #include "config/ConfigValueIncludes.h" 47 #include "commandline/CommandLineParser.h" 48 #include "GameConfig.h" 50 49 #include "GameMode.h" 51 50 #include "GameState.h" 52 51 #include "GraphicsManager.h" 53 52 #include "GUIManager.h" 54 #include "command/ConsoleCommand .h"53 #include "command/ConsoleCommandIncludes.h" 55 54 56 55 namespace orxonox … … 82 81 , bChangingState_(false) 83 82 , bAbort_(false) 83 , config_(NULL) 84 84 , destructionHelper_(this) 85 85 { … … 110 110 orxout(internal_info) << "creating Core object:" << endl; 111 111 this->core_ = new Core(cmdLine); 112 this->core_->loadModules(); 112 113 113 114 // Do this after the Core creation! 114 RegisterObject(Game); 115 this->setConfigValues(); 115 this->config_ = new GameConfig(); 116 116 117 117 // After the core has been created, we can safely instantiate the GameStates that don't require graphics … … 136 136 orxout(internal_status) << "destroying Game object..." << endl; 137 137 138 // Remove us from the object lists again to avoid problems when destroying them139 this->unregisterObject();140 141 138 assert(loadedStates_.size() <= 1); // Just empty root GameState 142 139 // Destroy all GameStates (shared_ptrs take care of actual destruction) … … 144 141 145 142 GameStateFactory::getFactories().clear(); 143 safeObjectDelete(&config_); 144 if (this->core_) 145 this->core_->unloadModules(); 146 146 safeObjectDelete(&core_); 147 147 safeObjectDelete(&gameClock_); 148 148 149 149 orxout(internal_status) << "finished destroying Game object..." << endl; 150 }151 152 void Game::setConfigValues()153 {154 SetConfigValue(statisticsRefreshCycle_, 250000)155 .description("Sets the time in microseconds interval at which average fps, etc. get updated.");156 SetConfigValue(statisticsAvgLength_, 1000000)157 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");158 159 SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)160 .description("Sets the desired frame rate (0 for no limit).");161 150 } 162 151 … … 229 218 // Limit frame rate 230 219 static bool hasVSync = GameMode::showsGraphics() && GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart 231 if (this-> fpsLimit_> 0 && !hasVSync)220 if (this->config_->getFpsLimit() > 0 && !hasVSync) 232 221 this->updateFPSLimiter(); 233 222 } … … 311 300 this->statisticsTickTimes_.back().tickLength += (uint32_t)(currentRealTime - currentTime); 312 301 this->periodTickTime_ += (uint32_t)(currentRealTime - currentTime); 313 if (this->periodTime_ > this-> statisticsRefreshCycle_)302 if (this->periodTime_ > this->config_->getStatisticsRefreshCycle()) 314 303 { 315 304 std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin(); 316 305 assert(it != this->statisticsTickTimes_.end()); 317 int64_t lastTime = currentTime - this-> statisticsAvgLength_;306 int64_t lastTime = currentTime - this->config_->getStatisticsAvgLength(); 318 307 if (static_cast<int64_t>(it->tickTime) < lastTime) 319 308 { … … 333 322 this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f; 334 323 335 this->periodTime_ -= this-> statisticsRefreshCycle_;324 this->periodTime_ -= this->config_->getStatisticsRefreshCycle(); 336 325 } 337 326 } … … 339 328 void Game::updateFPSLimiter() 340 329 { 341 uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);330 uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / this->config_->getFpsLimit()); 342 331 uint64_t currentRealTime = gameClock_->getRealMicroseconds(); 343 332 while (currentRealTime < nextTime - minimumSleepTime_) … … 529 518 530 519 core_->loadGraphics(); 531 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics );520 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true); 532 521 533 522 // Construct all the GameStates that require graphics … … 550 539 } 551 540 552 void Game::unloadGraphics( )541 void Game::unloadGraphics(bool loadGraphicsManagerWithoutRenderer) 553 542 { 554 543 if (GameMode::showsGraphics()) … … 566 555 } 567 556 568 core_->unloadGraphics( );557 core_->unloadGraphics(loadGraphicsManagerWithoutRenderer); 569 558 } 570 559 } … … 587 576 588 577 // If state requires graphics, load it 589 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics );578 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true); 590 579 if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics()) 591 580 this->loadGraphics(); … … 623 612 } 624 613 // Check if graphics is still required 625 if (!bAbort_) 626 { 627 bool graphicsRequired = false; 628 for (unsigned i = 0; i < loadedStates_.size(); ++i) 629 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 630 if (!graphicsRequired) 631 this->unloadGraphics(); 632 } 614 bool graphicsRequired = false; 615 for (unsigned i = 0; i < loadedStates_.size(); ++i) 616 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 617 if (!graphicsRequired) 618 this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive) 633 619 this->bChangingState_ = false; 634 620 } -
code/trunk/src/libraries/core/Game.h
r9667 r10624 50 50 #include "util/DestructionHelper.h" 51 51 #include "util/Singleton.h" 52 #include "config/Configurable.h"53 52 54 53 /** … … 82 81 class _CoreExport Game 83 82 // tolua_end 84 : public Singleton<Game> , public Configurable83 : public Singleton<Game> 85 84 { // tolua_export 86 85 friend class Singleton<Game>; … … 96 95 /// Destructor that also executes when object fails to construct 97 96 void destroy(); 98 99 void setConfigValues();100 97 101 98 void setStateHierarchy(const std::string& str); … … 151 148 152 149 void loadGraphics(); 153 void unloadGraphics( );150 void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); 154 151 155 152 void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode); … … 189 186 unsigned int minimumSleepTime_; 190 187 191 // config values 192 unsigned int statisticsRefreshCycle_; 193 unsigned int statisticsAvgLength_; 194 unsigned int fpsLimit_; 188 /// Helper object that stores the config values 189 GameConfig* config_; 195 190 196 191 /// Helper object that executes the surrogate destructor destroy() -
code/trunk/src/libraries/core/GraphicsManager.cc
r10295 r10624 59 59 #include "GUIManager.h" 60 60 #include "Loader.h" 61 #include "PathConfig.h" 61 #include "ApplicationPaths.h" 62 #include "ConfigurablePaths.h" 62 63 #include "ViewportEventListener.h" 63 64 #include "WindowEventListener.h" 64 65 #include "XMLFile.h" 65 #include "command/ConsoleCommand .h"66 #include "command/ConsoleCommandIncludes.h" 66 67 #include "input/InputManager.h" 67 68 … … 94 95 GraphicsManager* GraphicsManager::singletonPtr_s = 0; 95 96 97 RegisterAbstractClass(GraphicsManager).inheritsFrom<Configurable>(); 98 96 99 GraphicsManager::GraphicsManager(bool bLoadRenderer) 97 100 : ogreWindowEventListener_(new OgreWindowEventListener()) … … 111 114 112 115 // At first, add the root paths of the data directories as resource locations 113 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( PathConfig::getDataPathString(), "FileSystem");116 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getDataPathString(), "FileSystem"); 114 117 // Load resources 115 118 resources_.reset(new XMLFile("DefaultResources.oxr")); 116 119 resources_->setLuaSupport(false); 117 Loader:: open(resources_.get(), ClassTreeMask(), false);120 Loader::getInstance().load(resources_.get(), ClassTreeMask(), false); 118 121 119 122 // Only for runs in the build directory (not installed) 120 if ( PathConfig::buildDirectoryRun())121 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( PathConfig::getExternalDataPathString(), "FileSystem");123 if (ApplicationPaths::buildDirectoryRun()) 124 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getExternalDataPathString(), "FileSystem"); 122 125 123 126 extResources_.reset(new XMLFile("resources.oxr")); 124 127 extResources_->setLuaSupport(false); 125 Loader:: open(extResources_.get(), ClassTreeMask(), false);128 Loader::getInstance().load(extResources_.get(), ClassTreeMask(), false); 126 129 127 130 if (bLoadRenderer) … … 137 140 { 138 141 orxout(internal_status) << "destroying GraphicsManager..." << endl; 139 140 Loader::unload(debugOverlay_.get());141 142 142 143 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_); … … 147 148 148 149 // Undeclare the resources 149 Loader:: unload(resources_.get());150 Loader:: unload(extResources_.get());150 Loader::getInstance().unload(resources_.get()); 151 Loader::getInstance().unload(extResources_.get()); 151 152 152 153 safeObjectDelete(&ogreRoot_); … … 218 219 } 219 220 220 boost::filesystem::path ogreConfigFilepath( PathConfig::getConfigPath() / this->ogreConfigFile_);221 boost::filesystem::path ogreLogFilepath( PathConfig::getLogPath() / this->ogreLogFile_);221 boost::filesystem::path ogreConfigFilepath(ConfigurablePaths::getConfigPath() / this->ogreConfigFile_); 222 boost::filesystem::path ogreLogFilepath(ConfigurablePaths::getLogPath() / this->ogreLogFile_); 222 223 223 224 // create a new logManager … … 258 259 std::string pluginPath = specialConfig::ogrePluginsDirectory; 259 260 #ifdef DEPENDENCY_PACKAGE_ENABLE 260 if (! PathConfig::buildDirectoryRun())261 if (!ApplicationPaths::buildDirectoryRun()) 261 262 { 262 263 # if defined(ORXONOX_PLATFORM_WINDOWS) 263 pluginPath = PathConfig::getExecutablePathString();264 pluginPath = ApplicationPaths::getExecutablePathString(); 264 265 # elif defined(ORXONOX_PLATFORM_APPLE) 265 266 // TODO: Where are the plugins being installed to? 266 pluginPath = PathConfig::getExecutablePathString();267 pluginPath = ApplicationPaths::getExecutablePathString(); 267 268 # endif 268 269 } … … 279 280 orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl; 280 281 281 bool updatedConfig = Core::getInstance().get OgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();282 bool updatedConfig = Core::getInstance().getConfig()->getOgreConfigTimestamp() > Core::getInstance().getConfig()->getLastLevelTimestamp(); 282 283 if (updatedConfig) 283 284 orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl; … … 288 289 ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled."); 289 290 else 290 Core::getInstance(). updateOgreConfigTimestamp();291 Core::getInstance().getConfig()->updateOgreConfigTimestamp(); 291 292 } 292 293 … … 328 329 orxout(internal_info) << "Loading Debug Overlay..." << endl; 329 330 debugOverlay_.reset(new XMLFile("debug.oxo")); 330 Loader::open(debugOverlay_.get(), ClassTreeMask(), false); 331 Loader::getInstance().load(debugOverlay_.get(), ClassTreeMask(), false); 332 } 333 334 void GraphicsManager::unloadDebugOverlay() 335 { 336 Loader::getInstance().unload(debugOverlay_.get()); 331 337 } 332 338 … … 514 520 GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height); 515 521 this->ogreRoot_->saveConfig(); 516 Core::getInstance(). updateOgreConfigTimestamp();522 Core::getInstance().getConfig()->updateOgreConfigTimestamp(); 517 523 // Also reload the input devices 518 524 InputManager::getInstance().reload(); … … 532 538 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 533 539 this->ogreRoot_->saveConfig(); 534 Core::getInstance(). updateOgreConfigTimestamp();540 Core::getInstance().getConfig()->updateOgreConfigTimestamp(); 535 541 } 536 542 … … 548 554 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 549 555 this->ogreRoot_->saveConfig(); 550 Core::getInstance(). updateOgreConfigTimestamp();556 Core::getInstance().getConfig()->updateOgreConfigTimestamp(); 551 557 } 552 558 … … 557 563 { 558 564 assert(this->renderWindow_); 559 this->renderWindow_->writeContentsToTimestampedFile( PathConfig::getLogPathString() + "screenShot_", ".png");565 this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png"); 560 566 } 561 567 } -
code/trunk/src/libraries/core/GraphicsManager.h
r9675 r10624 95 95 void upgradeToGraphics(); 96 96 void loadDebugOverlay(); 97 void unloadDebugOverlay(); 97 98 bool rendererLoaded() const { return renderWindow_ != NULL; } 98 99 -
code/trunk/src/libraries/core/Language.cc
r8858 r10624 37 37 #include "util/Output.h" 38 38 #include "util/StringUtils.h" 39 #include "Core.h" 40 #include "PathConfig.h" 39 #include "ConfigurablePaths.h" 41 40 42 41 namespace orxonox … … 203 202 orxout(internal_info, context::language) << "Read default language file." << endl; 204 203 205 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);204 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_); 206 205 207 206 // This creates the file if it's not existing … … 247 246 /** 248 247 @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object. 249 */ 250 void Language::readTranslatedLanguageFile() 251 { 252 orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << endl; 253 254 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage()); 248 @return Returns false if the language file couldn't be found. 249 */ 250 bool Language::readTranslatedLanguageFile(const std::string& language) 251 { 252 orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl; 253 254 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(language); 255 255 256 256 // Open the file … … 261 261 { 262 262 orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl; 263 orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << endl; 264 Core::getInstance().resetLanguage(); 265 orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl; 266 return; 263 orxout(internal_error, context::language) << "Couldn't open file " << getFilename(language) << " to read the translated language entries!" << endl; 264 return false; 267 265 } 268 266 … … 291 289 else 292 290 { 293 orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename( Core::getInstance().getLanguage()) << endl;291 orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(language) << endl; 294 292 } 295 293 } … … 297 295 298 296 file.close(); 297 return true; 299 298 } 300 299 … … 306 305 orxout(verbose, context::language) << "Write default language file." << endl; 307 306 308 const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);307 const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_); 309 308 310 309 // Open the file -
code/trunk/src/libraries/core/Language.h
r8858 r10624 161 161 { 162 162 friend class Singleton<Language>; 163 friend class Core ;163 friend class CoreConfig; 164 164 165 165 public: … … 174 174 175 175 void readDefaultLanguageFile(); 176 void readTranslatedLanguageFile();176 bool readTranslatedLanguageFile(const std::string& language); 177 177 void writeDefaultLanguageFile() const; 178 178 static std::string getFilename(const std::string& language); -
code/trunk/src/libraries/core/Loader.cc
r10278 r10624 48 48 namespace orxonox 49 49 { 50 std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s; 51 ClassTreeMask Loader::currentMask_s; 52 53 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 54 { 55 Loader::add(file, mask); 56 return Loader::load(file, mask, bVerbose); 57 } 58 59 void Loader::close() 60 { 61 Loader::unload(); 62 Loader::files_s.clear(); 63 } 64 65 void Loader::close(const XMLFile* file) 66 { 67 Loader::unload(file); 68 Loader::remove(file); 69 } 70 71 void Loader::add(const XMLFile* file, const ClassTreeMask& mask) 72 { 73 if (!file) 74 return; 75 Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask)); 76 } 77 78 void Loader::remove(const XMLFile* file) 79 { 80 if (!file) 81 return; 82 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 83 { 84 if (it->first == file) 85 { 86 Loader::files_s.erase(it); 87 break; 88 } 89 } 90 } 91 92 /** 93 @brief 94 Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask. 95 @param mask 96 A ClassTreeMask, which defines which types of classes are loaded and which aren't. 97 @param bVerbose 98 Whether the loader is verbose (prints its progress in a low output level) or not. 99 @return 100 Returns true if successful. 101 */ 102 bool Loader::load(const ClassTreeMask& mask, bool bVerbose) 103 { 104 bool success = true; 105 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 106 if (!Loader::load(it->first, it->second * mask, bVerbose)) 107 success = false; 108 109 return success; 110 } 111 112 void Loader::unload(const ClassTreeMask& mask) 113 { 114 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ) 115 { 116 if (mask.isIncluded(it->getIdentifier())) 117 (it++)->destroy(); 118 else 119 ++it; 120 } 121 } 122 123 /** 124 @brief 125 Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask. 126 @param mask 127 A ClassTreeMask, which defines which types of classes are reloaded and which aren't. 128 @param bVerbose 129 Whether the loader is verbose (prints its progress in a low output level) or not. 130 @return 131 Returns true if successful. 132 */ 133 bool Loader::reload(const ClassTreeMask& mask, bool bVerbose) 134 { 135 Loader::unload(mask); 136 return Loader::load(mask, bVerbose); 137 } 50 Loader* Loader::singletonPtr_s = 0; 138 51 139 52 /** … … 156 69 return false; 157 70 158 Loader::currentMask_s= file->getMask() * mask;71 this->currentMask_ = file->getMask() * mask; 159 72 160 73 std::string xmlInput; … … 189 102 // start of the program. 190 103 // Assumption: the LevelInfo tag does not use Lua scripting 191 xmlInput = removeLuaTags(xmlInput);104 xmlInput = Loader::removeLuaTags(xmlInput); 192 105 } 193 106 } … … 198 111 { 199 112 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl; 200 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s<< endl;113 orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl; 201 114 } 202 115 else 203 116 { 204 117 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl; 205 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s<< endl;118 orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl; 206 119 } 207 120 … … 220 133 rootNamespace->setLoaderIndentation(" "); 221 134 rootNamespace->setFile(file); 222 rootNamespace->setNamespace(rootNamespace);223 135 rootNamespace->setRoot(true); 224 136 rootNamespace->XMLPort(rootElement, XMLPort::LoadObject); … … 303 215 ++it; 304 216 } 305 }306 307 /**308 @brief309 Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.310 @param file311 The file to be reloaded.312 @param mask313 A ClassTreeMask, which defines which types of classes are reloaded and which aren't.314 @param bVerbose315 Whether the loader is verbose (prints its progress in a low output level) or not.316 @return317 Returns true if successful.318 */319 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)320 {321 Loader::unload(file, mask);322 return Loader::load(file, mask, bVerbose);323 217 } 324 218 -
code/trunk/src/libraries/core/Loader.h
r8858 r10624 44 44 #include <map> 45 45 #include <vector> 46 47 #include "util/Singleton.h" 46 48 #include "ClassTreeMask.h" 47 49 48 50 namespace orxonox 49 51 { 50 class _CoreExport Loader 52 class _CoreExport Loader : public Singleton<Loader> 51 53 { 54 friend class Singleton<Loader>; 55 52 56 public: 53 static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 54 static void close(); 55 static void close(const XMLFile* file); 56 57 static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 58 static void remove(const XMLFile* file); 59 60 static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 61 static void unload(const ClassTreeMask& mask = ClassTreeMask()); 62 static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 63 64 static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), 65 bool bVerbose = true, bool bRemoveLuaTags = false); 66 static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 67 static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 57 bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), 58 bool bVerbose = true, bool bRemoveLuaTags = false); 59 void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 68 60 69 61 static std::string replaceLuaTags(const std::string& text); 70 62 static std::string removeLuaTags(const std::string& text); 71 63 72 static ClassTreeMask currentMask_s;64 ClassTreeMask currentMask_; 73 65 74 66 private: 75 67 static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags); 76 68 77 static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s; 69 std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_; 70 71 static Loader* singletonPtr_s; 78 72 }; 79 73 } -
code/trunk/src/libraries/core/Namespace.cc
r10298 r10624 47 47 RegisterObject(Namespace); 48 48 49 this->setNamespace( SmartPtr<Namespace>(this, false));49 this->setNamespace(WeakPtr<Namespace>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency) 50 50 } 51 51 … … 105 105 void Namespace::loadObjects(BaseObject* object) 106 106 { 107 object->setNamespace(this);108 107 } 109 108 -
code/trunk/src/libraries/core/ViewportEventListener.cc
r9667 r10624 32 32 namespace orxonox 33 33 { 34 RegisterAbstractClass(ViewportEventListener).inheritsFrom (Class(Listable));34 RegisterAbstractClass(ViewportEventListener).inheritsFrom<Listable>(); 35 35 36 36 ViewportEventListener::ViewportEventListener() -
code/trunk/src/libraries/core/WindowEventListener.cc
r9667 r10624 35 35 unsigned int WindowEventListener::windowHeight_s = 0; 36 36 37 RegisterAbstractClass(WindowEventListener).inheritsFrom (Class(Listable));37 RegisterAbstractClass(WindowEventListener).inheritsFrom<Listable>(); 38 38 39 39 WindowEventListener::WindowEventListener() -
code/trunk/src/libraries/core/XMLNameListener.cc
r9667 r10624 32 32 namespace orxonox 33 33 { 34 RegisterAbstractClass(XMLNameListener).inheritsFrom (Class(Listable));34 RegisterAbstractClass(XMLNameListener).inheritsFrom<Listable>(); 35 35 36 36 XMLNameListener::XMLNameListener() -
code/trunk/src/libraries/core/XMLPort.cc
r9667 r10624 40 40 bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier) 41 41 { 42 return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader:: currentMask_s.isIncluded(identifier));42 return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::getInstance().currentMask_.isIncluded(identifier)); 43 43 } 44 44 -
code/trunk/src/libraries/core/class/Identifiable.cc
r9667 r10624 41 41 namespace orxonox 42 42 { 43 RegisterClassNoArgs(Identifiable) ;43 RegisterClassNoArgs(Identifiable).virtualBase(); 44 44 45 45 /** -
code/trunk/src/libraries/core/class/Identifier.cc
r9667 r10624 44 44 namespace orxonox 45 45 { 46 bool Identifier::initConfigValues_s = true; 47 46 48 // ############################### 47 49 // ### Identifier ### … … 50 52 @brief Constructor: No factory, no object created, new ObjectList and a unique networkID. 51 53 */ 52 Identifier::Identifier() 53 : classID_(IdentifierManager::getInstance().getUniqueClassId()) 54 { 55 this->factory_ = 0; 54 Identifier::Identifier(const std::string& name, Factory* factory, bool bLoadable) 55 { 56 orxout(verbose, context::identifier) << "Create identifier for " << name << endl; 57 58 static unsigned int classIDCounter = 0; 59 60 this->classID_ = classIDCounter++; 61 this->name_ = name; 62 this->factory_ = factory; 63 this->bLoadable_ = bLoadable; 56 64 this->bInitialized_ = false; 57 this->b Loadable_ = false;65 this->bIsVirtualBase_ = false; 58 66 59 67 this->bHasConfigValues_ = false; … … 71 79 delete this->factory_; 72 80 81 for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it) 82 delete (*it); 83 84 // erase this Identifier from all related identifiers 85 for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 86 const_cast<Identifier*>(*it)->children_.erase(this); 87 for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 88 const_cast<Identifier*>(*it)->directChildren_.erase(this); 89 for (std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it) 90 const_cast<Identifier*>(*it)->parents_.remove(this); 91 for (std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it) 92 const_cast<Identifier*>(*it)->directParents_.remove(this); 93 73 94 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 74 95 delete (it->second); … … 77 98 for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it) 78 99 delete (it->second); 79 }80 81 /**82 @brief Sets the name of the class.83 */84 void Identifier::setName(const std::string& name)85 {86 if (name != this->name_)87 {88 this->name_ = name;89 IdentifierManager::getInstance().addIdentifierToLookupMaps(this);90 }91 }92 93 void Identifier::setFactory(Factory* factory)94 {95 if (this->factory_)96 delete this->factory_;97 98 this->factory_ = factory;99 100 } 100 101 … … 126 127 { 127 128 this->networkID_ = id; 128 IdentifierManager::getInstance().addIdentifier ToLookupMaps(this);129 IdentifierManager::getInstance().addIdentifier(this); // add with new id 129 130 } 130 131 … … 132 133 * @brief Used to define the direct parents of an Identifier of an abstract class. 133 134 */ 134 Identifier& Identifier::inheritsFrom(I dentifier* directParent)135 { 136 if (this-> parents_.empty())137 this-> directParents_.insert(directParent);138 else 139 orxout(internal_error) << "Trying to add " << directParent->getName() << " as adirect parent of " << this->getName() << " after the latter was already initialized" << endl;135 Identifier& Identifier::inheritsFrom(InheritsFrom* directParent) 136 { 137 if (this->directParents_.empty()) 138 this->manualDirectParents_.push_back(directParent); 139 else 140 orxout(internal_error) << "Trying to manually add direct parent of " << this->getName() << " after the latter was already initialized" << endl; 140 141 141 142 return *this; … … 144 145 /** 145 146 * @brief Initializes the parents of this Identifier while creating the class hierarchy. 146 * @param i dentifiers All identifiers that were used to create an instance of this class (includingthis identifier itself)147 */ 148 void Identifier::initializeParents(const std:: set<const Identifier*>& identifiers)147 * @param initializationTrace All identifiers that were recorded while creating an instance of this class (including nested classes and this identifier itself) 148 */ 149 void Identifier::initializeParents(const std::list<const Identifier*>& initializationTrace) 149 150 { 150 151 if (!IdentifierManager::getInstance().isCreatingHierarchy()) … … 154 155 } 155 156 156 for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) 157 if (*it != this) 158 this->parents_.insert(*it); 159 } 160 161 /** 162 * @brief Initializes the direct parents of this Identifier while creating the class hierarchy. This is only intended for abstract classes. 163 */ 164 void Identifier::initializeDirectParentsOfAbstractClass() 157 if (this->directParents_.empty()) 158 { 159 for (std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it) 160 if (*it != this) 161 this->parents_.push_back(*it); 162 } 163 else 164 orxout(internal_error) << "Trying to add parents to " << this->getName() << " after it was already initialized with manual calls to inheritsFrom<Class>()." << endl; 165 } 166 167 /** 168 * @brief Finishes the initialization of this Identifier after creating the class hierarchy by wiring the (direct) parent/child references correctly. 169 */ 170 void Identifier::finishInitialization() 165 171 { 166 172 if (!IdentifierManager::getInstance().isCreatingHierarchy()) 167 173 { 168 orxout(internal_warning) << "Identifier:: initializeDirectParentsOfAbstractClass() created outside of class hierarchy creation" << endl;174 orxout(internal_warning) << "Identifier::finishInitialization() created outside of class hierarchy creation" << endl; 169 175 return; 170 176 } 171 177 172 // only Identifiable is allowed to have no parents (even tough it's currently not abstract) 173 if (this->directParents_.empty() && !this->isExactlyA(Class(Identifiable))) 174 { 175 orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeidName() << " is marked as abstract but has no direct parents defined" << endl; 178 if (this->isInitialized()) 179 return; 180 181 if (!this->parents_.empty()) 182 { 183 // parents defined -> this class was initialized by creating a sample instance and recording the trace of identifiers 184 185 // initialize all parents 186 for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 187 const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent 188 189 // parents of parents are no direct parents of this identifier 190 this->directParents_ = this->parents_; 191 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 192 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 193 this->directParents_.remove(*it_parent_parent); 194 195 this->verifyIdentifierTrace(); 196 } 197 else if (!this->manualDirectParents_.empty()) 198 { 199 // no parents defined -> this class was manually initialized by calling inheritsFrom<Class>() 200 201 // initialize all direct parents 202 for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it) 203 { 204 Identifier* directParent = (*it)->getParent(); 205 this->directParents_.push_back(directParent); 206 directParent->finishInitialization(); // initialize parent 207 } 208 209 // direct parents and their parents are also parents of this identifier (but only add them once) 210 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 211 { 212 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 213 this->addIfNotExists(this->parents_, *it_parent_parent); 214 this->addIfNotExists(this->parents_, *it_parent); 215 } 216 } 217 else if (!this->isExactlyA(Class(Identifiable))) 218 { 219 // only Identifiable is allowed to have no parents (even tough it's currently not abstract) 220 orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeInfo().name() << " is marked as abstract but has no direct parents defined" << endl; 176 221 orxout(internal_error) << " If this class is not abstract, use RegisterClass(ThisClass);" << endl; 177 222 orxout(internal_error) << " If this class is abstract, use RegisterAbstractClass(ThisClass).inheritsFrom(Class(BaseClass));" << endl; 178 223 } 179 }180 181 /**182 * @brief Finishes the initialization of this Identifier after creating the class hierarchy by wiring the (direct) parent/child references correctly.183 */184 void Identifier::finishInitialization()185 {186 if (!IdentifierManager::getInstance().isCreatingHierarchy())187 {188 orxout(internal_warning) << "Identifier::finishInitialization() created outside of class hierarchy creation" << endl;189 return;190 }191 192 if (this->isInitialized())193 return;194 195 // if no direct parents were defined, initialize them with the set of all parents196 if (this->directParents_.empty())197 this->directParents_ = this->parents_;198 199 // initialize all parents before continuing to initialize this identifier200 for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)201 {202 Identifier* directParent = const_cast<Identifier*>(*it);203 directParent->finishInitialization(); // initialize parent204 this->parents_.insert(directParent); // direct parent is also a parent205 this->parents_.insert(directParent->parents_.begin(), directParent->parents_.end()); // parents of direct parent are also parents206 }207 208 // parents of parents are no direct parents of this identifier209 for (std::set<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)210 for (std::set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)211 this->directParents_.erase(*it_parent_parent);212 224 213 225 // tell all parents that this identifier is a child 214 for (std:: set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)226 for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 215 227 const_cast<Identifier*>(*it)->children_.insert(this); 216 228 217 229 // tell all direct parents that this identifier is a direct child 218 for (std:: set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)230 for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 219 231 { 220 232 const_cast<Identifier*>(*it)->directChildren_.insert(this); … … 228 240 229 241 /** 242 * Resets all information about the class hierarchy. The identifier is considered uninitialized afterwards. 243 */ 244 void Identifier::reset() 245 { 246 this->directParents_.clear(); 247 this->parents_.clear(); 248 this->directChildren_.clear(); 249 this->children_.clear(); 250 this->bInitialized_ = false; 251 } 252 253 /** 254 * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class 255 * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes. 256 */ 257 void Identifier::verifyIdentifierTrace() const 258 { 259 260 std::list<const Identifier*> expectedIdentifierTrace; 261 262 // if any parent class is virtual, it will be instantiated first, so we need to add them first. 263 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 264 { 265 if ((*it_parent)->isVirtualBase()) 266 { 267 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 268 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 269 this->addIfNotExists(expectedIdentifierTrace, *it_parent); 270 } 271 } 272 273 // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again. 274 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 275 { 276 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 277 this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent); 278 this->addIfNotExists(expectedIdentifierTrace, *it_parent); 279 } 280 281 // check if the expected trace matches the actual trace (which was defined by creating a sample instance) 282 if (expectedIdentifierTrace != this->parents_) 283 { 284 orxout(internal_warning) << this->getName() << " has an unexpected initialization trace:" << endl; 285 286 orxout(internal_warning) << " Actual trace (after creating a sample instance):" << endl << " "; 287 for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 288 orxout(internal_warning) << " " << (*it_parent)->getName(); 289 orxout(internal_warning) << endl; 290 291 orxout(internal_warning) << " Expected trace (according to class hierarchy definitions):" << endl << " "; 292 for (std::list<const Identifier*>::const_iterator it_parent = expectedIdentifierTrace.begin(); it_parent != expectedIdentifierTrace.end(); ++it_parent) 293 orxout(internal_warning) << " " << (*it_parent)->getName(); 294 orxout(internal_warning) << endl; 295 296 orxout(internal_warning) << " Direct parents (according to class hierarchy definitions):" << endl << " "; 297 for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent) 298 orxout(internal_warning) << " " << (*it_parent)->getName(); 299 orxout(internal_warning) << endl; 300 } 301 } 302 303 /** 304 * Adds @param identifierToAdd to @param list if this identifier is not already contained in the list. 305 */ 306 void Identifier::addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const 307 { 308 if (std::find(list.begin(), list.end(), identifierToAdd) == list.end()) 309 list.push_back(identifierToAdd); 310 } 311 312 /** 230 313 @brief Returns true, if the Identifier is at least of the given type. 231 314 @param identifier The identifier to compare with … … 233 316 bool Identifier::isA(const Identifier* identifier) const 234 317 { 235 return (identifier == this || (this-> parents_.find(identifier) != this->parents_.end()));318 return (identifier == this || (this->isChildOf(identifier))); 236 319 } 237 320 … … 251 334 bool Identifier::isChildOf(const Identifier* identifier) const 252 335 { 253 return ( this->parents_.find(identifier) != this->parents_.end());336 return (std::find(this->parents_.begin(), this->parents_.end(), identifier) != this->parents_.end()); 254 337 } 255 338 … … 260 343 bool Identifier::isDirectChildOf(const Identifier* identifier) const 261 344 { 262 return ( this->directParents_.find(identifier) != this->directParents_.end());345 return (std::find(this->directParents_.begin(), this->directParents_.end(), identifier) != this->directParents_.end()); 263 346 } 264 347 -
code/trunk/src/libraries/core/class/Identifier.h
r9667 r10624 80 80 #include <typeinfo> 81 81 #include <loki/TypeTraits.h> 82 #include <boost/static_assert.hpp> 83 #include <boost/type_traits/is_base_of.hpp> 82 84 83 85 #include "util/Output.h" 86 #include "util/OrxAssert.h" 84 87 #include "core/object/ObjectList.h" 85 88 #include "core/object/Listable.h" … … 109 112 { 110 113 public: 111 Identifier(); 114 struct InheritsFrom //! helper class to manually define inheritance 115 { 116 virtual ~InheritsFrom() {} 117 virtual Identifier* getParent() const = 0; 118 }; 119 120 public: 121 Identifier(const std::string& name, Factory* factory, bool bLoadable); 112 122 Identifier(const Identifier& identifier); // don't copy 113 123 virtual ~Identifier(); … … 115 125 /// Returns the name of the class the Identifier belongs to. 116 126 inline const std::string& getName() const { return this->name_; } 117 void setName(const std::string& name); 118 119 /// Returns the name of the class as it is returned by typeid(T).name() 120 virtual const std::string& getTypeidName() = 0; 127 128 /// Returns the type_info of the class as it is returned by typeid(T) 129 virtual const std::type_info& getTypeInfo() = 0; 121 130 122 131 /// Returns the network ID to identify a class through the network. … … 127 136 ORX_FORCEINLINE unsigned int getClassID() const { return this->classID_; } 128 137 129 /// Sets the Factory.130 void setFactory(Factory* factory);131 138 /// Returns true if the Identifier has a Factory. 132 139 inline bool hasFactory() const { return (this->factory_ != 0); } … … 136 143 /// Returns true if the class can be loaded through XML. 137 144 inline bool isLoadable() const { return this->bLoadable_; } 138 /// Set the class to be loadable through XML or not. 139 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 145 146 /// Returns true if child classes should inherit virtually from this class. 147 inline bool isVirtualBase() const { return this->bIsVirtualBase_; } 148 /// Defines if child classes should inherit virtually from this class. 149 inline void setVirtualBase(bool bIsVirtualBase) { this->bIsVirtualBase_ = bIsVirtualBase; } 140 150 141 151 /// Returns true if the Identifier was completely initialized. 142 152 inline bool isInitialized() const { return this->bInitialized_; } 153 154 virtual void destroyObjects() = 0; 155 156 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0; 157 158 static bool initConfigValues_s; // TODO: this is a hack - remove it as soon as possible 143 159 144 160 … … 146 162 ////// Class Hierarchy ////// 147 163 ///////////////////////////// 148 Identifier& inheritsFrom(Identifier* directParent); 149 150 void initializeParents(const std::set<const Identifier*>& identifiers); 151 void initializeDirectParentsOfAbstractClass(); 164 Identifier& inheritsFrom(InheritsFrom* directParent); 165 166 void initializeParents(const std::list<const Identifier*>& initializationTrace); 152 167 void finishInitialization(); 168 void reset(); 153 169 154 170 bool isA(const Identifier* identifier) const; … … 159 175 bool isDirectParentOf(const Identifier* identifier) const; 160 176 177 /// Returns the direct parents of the class the Identifier belongs to. 178 inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; } 161 179 /// Returns the parents of the class the Identifier belongs to. 162 inline const std::set<const Identifier*>& getParents() const { return this->parents_; } 163 /// Returns the begin-iterator of the parents-list. 164 inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); } 165 /// Returns the end-iterator of the parents-list. 166 inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); } 167 180 inline const std::list<const Identifier*>& getParents() const { return this->parents_; } 181 182 /// Returns the direct children the class the Identifier belongs to. 183 inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; } 168 184 /// Returns the children of the class the Identifier belongs to. 169 185 inline const std::set<const Identifier*>& getChildren() const { return this->children_; } 170 /// Returns the begin-iterator of the children-list.171 inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }172 /// Returns the end-iterator of the children-list.173 inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }174 175 /// Returns the direct parents of the class the Identifier belongs to.176 inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }177 /// Returns the begin-iterator of the direct-parents-list.178 inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }179 /// Returns the end-iterator of the direct-parents-list.180 inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }181 182 /// Returns the direct children the class the Identifier belongs to.183 inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }184 /// Returns the begin-iterator of the direct-children-list.185 inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }186 /// Returns the end-iterator of the direct-children-list.187 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }188 186 189 187 … … 223 221 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 224 222 225 226 223 protected: 227 224 virtual void createSuperFunctionCaller() const = 0; 228 225 229 226 private: 230 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 227 void verifyIdentifierTrace() const; 228 void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const; 229 230 std::list<const InheritsFrom*> manualDirectParents_; //!< Manually defined direct parents 231 std::list<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization) 232 std::list<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to (sorted by their order of initialization) 233 234 std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 231 235 std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to 232 233 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to234 std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to235 236 236 237 bool bInitialized_; //!< Is true if the Identifier was completely initialized 237 238 bool bLoadable_; //!< False = it's not permitted to load the object through XML 239 bool bIsVirtualBase_; //!< If true, it is recommended to inherit virtually from this class. This changes the order of initialization of child classes, thus this information is necessary to check the class hierarchy. 238 240 std::string name_; //!< The name of the class the Identifier belongs to 239 241 Factory* factory_; //!< The Factory, able to create new objects of the given class (if available) 240 242 uint32_t networkID_; //!< The network ID to identify a class through the network 241 const unsigned int classID_;//!< Uniquely identifies a class (might not be the same as the networkID_)243 unsigned int classID_; //!< Uniquely identifies a class (might not be the same as the networkID_) 242 244 243 245 bool bHasConfigValues_; //!< True if this class has at least one assigned config value … … 267 269 class ClassIdentifier : public Identifier 268 270 { 271 BOOST_STATIC_ASSERT((boost::is_base_of<Identifiable, T>::value)); 272 269 273 #ifndef DOXYGEN_SHOULD_SKIP_THIS 270 274 #define SUPER_INTRUSIVE_DECLARATION_INCLUDE … … 273 277 274 278 public: 275 static ClassIdentifier<T>* getIdentifier(); 276 static ClassIdentifier<T>* getIdentifier(const std::string& name); 277 278 bool initializeObject(T* object); 279 280 void setConfigValues(T* object, Configurable*) const; 281 void setConfigValues(T* object, Identifiable*) const; 282 283 void addObjectToList(T* object, Listable*); 284 void addObjectToList(T* object, Identifiable*); 285 286 virtual void updateConfigValues(bool updateChildren = true) const; 287 288 virtual const std::string& getTypeidName() 289 { return this->typeidName_; } 290 291 private: 292 static void initializeIdentifier(); 293 294 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 295 ClassIdentifier() 279 ClassIdentifier(const std::string& name, Factory* factory, bool bLoadable) : Identifier(name, factory, bLoadable) 296 280 { 297 this->typeidName_ = typeid(T).name(); 281 OrxVerify(ClassIdentifier<T>::classIdentifier_s == NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name()); 282 ClassIdentifier<T>::classIdentifier_s = this; 283 298 284 SuperFunctionInitialization<0, T>::initialize(this); 299 285 } … … 303 289 } 304 290 291 bool initializeObject(T* object); 292 293 virtual void updateConfigValues(bool updateChildren = true) const; 294 295 virtual const std::type_info& getTypeInfo() 296 { return typeid(T); } 297 298 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const 299 { return dynamic_cast<T*>(object) != 0; } 300 301 virtual void destroyObjects(); 302 303 static ClassIdentifier<T>* getIdentifier(); 304 305 private: 306 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 307 308 void setConfigValues(T* object, Configurable*) const; 309 void setConfigValues(T* object, Identifiable*) const; 310 311 void addObjectToList(T* object, Listable*); 312 void addObjectToList(T* object, Identifiable*); 313 314 void destroyObjects(Listable*); 315 void destroyObjects(void*); 316 317 void destroyObject(Destroyable* object); 318 void destroyObject(void* object); 319 305 320 void updateConfigValues(bool updateChildren, Listable*) const; 306 321 void updateConfigValues(bool updateChildren, Identifiable*) const; 307 322 308 std::string typeidName_;309 323 static WeakPtr<ClassIdentifier<T> > classIdentifier_s; 310 324 }; … … 318 332 */ 319 333 template <class T> 320 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()321 { 322 // check if the Identifier already exists323 if (!ClassIdentifier<T>::classIdentifier_s)324 ClassIdentifier<T>::initializeIdentifier(); 325 334 /*static*/ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 335 { 336 if (ClassIdentifier<T>::classIdentifier_s == NULL) 337 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T)); 338 339 OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Did you forget to register the class of type " << typeid(T).name() << "?"); 326 340 return ClassIdentifier<T>::classIdentifier_s; 327 }328 329 /**330 @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.331 @param name The name of this Identifier332 @return The Identifier333 */334 template <class T>335 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)336 {337 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();338 identifier->setName(name);339 return identifier;340 }341 342 /**343 @brief Assigns the static field for the identifier singleton.344 */345 template <class T>346 /*static */ void ClassIdentifier<T>::initializeIdentifier()347 {348 // create a new identifier anyway. Will be deleted if not used.349 ClassIdentifier<T>* proposal = new ClassIdentifier<T>();350 351 // Get the entry from the map352 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getGloballyUniqueIdentifier(proposal);353 354 if (ClassIdentifier<T>::classIdentifier_s == proposal)355 orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was not yet existing and got created." << endl;356 else357 {358 orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was already existing and got assigned." << endl;359 delete proposal; // delete proposal (it is not used anymore)360 }361 341 } 362 342 … … 375 355 IdentifierManager::getInstance().createdObject(object); 376 356 377 this->setConfigValues(object, object); 357 if (Identifier::initConfigValues_s) 358 this->setConfigValues(object, object); 359 378 360 return true; 379 361 } … … 420 402 421 403 /** 404 * @brief Destroy all objects of this class (must be Listable). 405 * Destroyables are destroyed with destroy(), all other classes with delete. 406 */ 407 template <class T> 408 void ClassIdentifier<T>::destroyObjects() 409 { 410 this->destroyObjects((T*)0); 411 } 412 413 /** 414 * @brief Only searches and destroys objects if is a @ref Listable 415 */ 416 template <class T> 417 void ClassIdentifier<T>::destroyObjects(Listable*) 418 { 419 ObjectListBase* objectList = Context::getRootContext()->getObjectList(this); 420 ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin()); 421 ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end()); 422 for (typename ObjectList<T>::iterator it = begin; it != end; ) 423 this->destroyObject(*(it++)); 424 } 425 426 template <class T> 427 void ClassIdentifier<T>::destroyObjects(void*) 428 { 429 // no action 430 } 431 432 /** 433 * @brief Call 'object->destroy()' for Destroyables and 'delete object' for all other types. 434 */ 435 template <class T> 436 void ClassIdentifier<T>::destroyObject(Destroyable* object) 437 { 438 object->destroy(); 439 } 440 441 template <class T> 442 void ClassIdentifier<T>::destroyObject(void* object) 443 { 444 delete static_cast<Identifiable*>(object); 445 } 446 447 /** 422 448 @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function. 423 449 */ … … 438 464 439 465 if (updateChildren) 440 for (std::set<const Identifier*>::const_iterator it = this->getChildren Begin(); it != this->getChildrenEnd(); ++it)466 for (std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it) 441 467 (*it)->updateConfigValues(false); 442 468 } -
code/trunk/src/libraries/core/class/IdentifierManager.cc
r9667 r10624 37 37 38 38 #include "util/StringUtils.h" 39 #include "core/Core Includes.h"39 #include "core/Core.h" 40 40 #include "core/config/ConfigValueContainer.h" 41 41 #include "core/XMLPort.h" … … 44 44 namespace orxonox 45 45 { 46 /* static */ IdentifierManager& IdentifierManager::getInstance() 47 { 48 static IdentifierManager instance; 49 return instance; 50 } 46 IdentifierManager* IdentifierManager::singletonPtr_s = 0; 51 47 52 48 IdentifierManager::IdentifierManager() 53 49 { 54 50 this->hierarchyCreatingCounter_s = 0; 55 this->classIDCounter_s = 0; 56 } 57 58 /** 59 @brief Returns an identifier by name and adds it if not available 60 @param proposal A pointer to a newly created identifier for the case of non existence in the map 61 @return The identifier (unique instance) 62 */ 63 Identifier* IdentifierManager::getGloballyUniqueIdentifier(Identifier* proposal) 64 { 65 const std::string& typeidName = proposal->getTypeidName(); 66 std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.find(typeidName); 67 68 if (it != this->identifierByTypeidName_.end()) 69 { 70 // There is already an entry: return it 71 return it->second; 72 } 73 else 74 { 75 // There is no entry: put the proposal into the map and return it 76 this->identifierByTypeidName_[typeidName] = proposal; 77 return proposal; 78 } 51 this->recordTraceForIdentifier_ = NULL; 79 52 } 80 53 … … 82 55 * Registers the identifier in all maps of the IdentifierManager. 83 56 */ 84 void IdentifierManager::addIdentifierToLookupMaps(Identifier* identifier) 85 { 86 const std::string& typeidName = identifier->getTypeidName(); 87 if (this->identifierByTypeidName_.find(typeidName) != this->identifierByTypeidName_.end()) 88 { 89 this->identifierByString_[identifier->getName()] = identifier; 90 this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; 91 this->identifierByNetworkId_[identifier->getNetworkID()] = identifier; 92 } 93 else 94 orxout(internal_warning) << "Trying to add an identifier to lookup maps which is not known to IdentifierManager" << endl; 57 void IdentifierManager::addIdentifier(Identifier* identifier) 58 { 59 orxout(verbose, context::identifier) << "Adding identifier for " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl; 60 61 this->identifiers_.insert(identifier); 62 this->identifierByString_[identifier->getName()] = identifier; 63 this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; 64 this->identifierByNetworkId_[identifier->getNetworkID()] = identifier; 65 } 66 67 /** 68 * Unregisters the identifier from all maps of the IdentifierManager. 69 */ 70 void IdentifierManager::removeIdentifier(Identifier* identifier) 71 { 72 this->identifiers_.erase(identifier); 73 this->identifierByString_.erase(identifier->getName()); 74 this->identifierByLowercaseString_.erase(getLowercase(identifier->getName())); 75 this->identifierByNetworkId_.erase(identifier->getNetworkID()); 95 76 } 96 77 … … 112 93 { 113 94 Context temporaryContext(NULL); 114 for (std:: map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)95 for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 115 96 { 116 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << it->second->getName() << ">-Singleton." << endl; 97 Identifier* identifier = (*it); 98 if (identifier->isInitialized()) 99 continue; 100 101 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << identifier->getName() << ">-Singleton." << endl; 117 102 // To initialize the identifier, we create a new object and delete it afterwards. 118 if (i t->second->hasFactory())103 if (identifier->hasFactory()) 119 104 { 120 this->identifiersOfNewObject_.clear(); 121 Identifiable* temp = it->second->fabricate(&temporaryContext); 122 if (temp->getIdentifier() != it->second) 123 orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl; 105 this->identifierTraceOfNewObject_.clear(); 106 this->recordTraceForIdentifier_ = identifier; 107 108 Identifiable* temp = identifier->fabricate(&temporaryContext); 109 110 this->recordTraceForIdentifier_ = NULL; 111 112 if (temp->getIdentifier() != identifier) 113 orxout(internal_error) << "Newly created object of type " << identifier->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl; 114 115 identifier->initializeParents(this->identifierTraceOfNewObject_[temp]); 116 124 117 delete temp; 125 126 it->second->initializeParents(this->identifiersOfNewObject_);127 118 } 128 else 129 it->second->initializeDirectParentsOfAbstractClass(); 130 131 initializedIdentifiers.insert(it->second); 119 120 initializedIdentifiers.insert(identifier); 132 121 } 133 122 … … 138 127 139 128 // finish the initialization of all identifiers 140 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 141 { 142 if (initializedIdentifiers.find(it->second) != initializedIdentifiers.end()) 143 it->second->finishInitialization(); 144 else 145 orxout(internal_error) << "Identifier was registered late and is not initialized: " << it->second->getName() << " / " << it->second->getTypeidName() << endl; 146 } 129 for (std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it) 130 (*it)->finishInitialization(); 131 132 // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway. 133 if (!Core::exists() || Core::getInstance().getConfig()->inDevMode()) 134 this->verifyClassHierarchy(initializedIdentifiers); 147 135 148 136 this->stopCreatingHierarchy(); … … 151 139 152 140 /** 153 @brief Destroys all Identifiers. Called when exiting the program. 154 */ 155 void IdentifierManager::destroyAllIdentifiers() 156 { 157 for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 158 delete (it->second); 159 160 this->identifierByTypeidName_.clear(); 161 this->identifierByString_.clear(); 162 this->identifierByLowercaseString_.clear(); 163 this->identifierByNetworkId_.clear(); 141 * Verifies if the class hierarchy is consistent with the RTTI. 142 */ 143 void IdentifierManager::verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers) 144 { 145 // check if there are any uninitialized identifiers remaining 146 for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 147 if (!(*it)->isInitialized()) 148 orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl; 149 150 // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy 151 Context temporaryContext(NULL); 152 for (std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1) 153 { 154 if (!(*it1)->hasFactory()) 155 continue; 156 157 Identifiable* temp = (*it1)->fabricate(&temporaryContext); 158 159 for (std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2) 160 { 161 bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp); 162 bool isA_AccordingToClassHierarchy = temp->isA((*it2)); 163 164 if (isA_AccordingToRtti != isA_AccordingToClassHierarchy) 165 { 166 orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() << 167 (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl; 168 } 169 } 170 171 delete temp; 172 } 173 orxout(internal_info) << "Class hierarchy matches RTTI" << endl; 174 175 size_t numberOfObjects = temporaryContext.getObjectList<Listable>()->size(); 176 if (numberOfObjects > 0) 177 orxout(internal_warning) << "There are still " << numberOfObjects << " listables left after creating the class hierarchy" << endl; 178 } 179 180 /** 181 * @brief Resets all Identifiers. 182 */ 183 void IdentifierManager::destroyClassHierarchy() 184 { 185 orxout(internal_status) << "Destroy class-hierarchy" << endl; 186 for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 187 (*it)->reset(); 164 188 } 165 189 … … 170 194 { 171 195 if (this->isCreatingHierarchy()) 172 this->identifiersOfNewObject_.insert(identifiable->getIdentifier()); 196 { 197 if (this->recordTraceForIdentifier_) 198 { 199 std::list<const Identifier*>& traceForObject = this->identifierTraceOfNewObject_[identifiable]; 200 if (std::find(traceForObject.begin(), traceForObject.end(), identifiable->getIdentifier()) != traceForObject.end()) 201 { 202 orxout(internal_warning) << this->recordTraceForIdentifier_->getName() << " inherits two times from " << 203 identifiable->getIdentifier()->getName() << ". Did you forget to use virtual inheritance?" << endl; 204 } 205 traceForObject.push_back(identifiable->getIdentifier()); 206 } 207 } 173 208 else 174 209 orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl; … … 218 253 219 254 /** 255 @brief Returns the Identifier with a given typeid-name. 256 @param name The typeid-name of the wanted Identifier 257 @return The Identifier 258 */ 259 Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo) 260 { 261 // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11) 262 for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 263 if ((*it)->getTypeInfo() == typeInfo) 264 return (*it); 265 return 0; 266 } 267 268 /** 220 269 @brief Cleans the NetworkID map (needed on clients for correct initialization) 221 270 */ -
code/trunk/src/libraries/core/class/IdentifierManager.h
r9667 r10624 39 39 #include <map> 40 40 #include <set> 41 #include <list> 41 42 #include <string> 43 44 #include "util/Singleton.h" 42 45 43 46 namespace orxonox 44 47 { 45 class _CoreExport IdentifierManager 48 class _CoreExport IdentifierManager : public Singleton<IdentifierManager> 46 49 { 50 friend class Singleton<IdentifierManager>; 51 47 52 public: 48 static IdentifierManager& getInstance(); 53 IdentifierManager(); 54 ~IdentifierManager() {} 49 55 50 Identifier* getGloballyUniqueIdentifier(Identifier* proposal); 51 void addIdentifierToLookupMaps(Identifier* identifier); 52 53 unsigned int getUniqueClassId() 54 { return this->classIDCounter_s++; } 56 void addIdentifier(Identifier* identifier); 57 void removeIdentifier(Identifier* identifier); 55 58 56 59 … … 59 62 ///////////////////////////// 60 63 void createClassHierarchy(); 61 void destroyAllIdentifiers(); 64 void verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers); 65 void destroyClassHierarchy(); 62 66 63 67 void createdObject(Identifiable* identifiable); … … 74 78 Identifier* getIdentifierByLowercaseString(const std::string& name); 75 79 Identifier* getIdentifierByID(uint32_t id); 80 Identifier* getIdentifierByTypeInfo(const std::type_info& typeInfo); 76 81 77 82 void clearNetworkIDs(); … … 88 93 89 94 private: 90 IdentifierManager(); 91 IdentifierManager(const IdentifierManager&); 92 ~IdentifierManager() {} 95 IdentifierManager(const IdentifierManager&); // not implemented 93 96 94 97 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. … … 99 102 { hierarchyCreatingCounter_s--; } 100 103 101 std::map<std::string, Identifier*> identifierByTypeidName_; //!< Map with the names as received by typeid(). This is only used internally. 102 104 std::set<Identifier*> identifiers_; //!< All identifiers. This is only used internally. 103 105 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 104 106 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. … … 106 108 107 109 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 108 std::set<const Identifier*> identifiersOfNewObject_; //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object 109 unsigned int classIDCounter_s; //!< counter for the unique classIDs 110 111 /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as 112 /// a consequence of this, e.g. nested member objects). 113 std::map<Identifiable*, std::list<const Identifier*> > identifierTraceOfNewObject_; 114 Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded. 115 116 static IdentifierManager* singletonPtr_s; 110 117 }; 111 118 } -
code/trunk/src/libraries/core/class/OrxonoxInterface.cc
r9667 r10624 32 32 namespace orxonox 33 33 { 34 RegisterClassNoArgs(OrxonoxInterface) ;34 RegisterClassNoArgs(OrxonoxInterface).virtualBase(); 35 35 36 36 OrxonoxInterface::OrxonoxInterface() -
code/trunk/src/libraries/core/class/Super.h
r9667 r10624 274 274 SUPER_NOARGS(classname, functionname) 275 275 276 #define SUPER_changedGametype(classname, functionname, ...) \277 SUPER_NOARGS(classname, functionname)278 279 276 #define SUPER_changedUsed(classname, functionname, ...) \ 280 277 SUPER_NOARGS(classname, functionname) … … 555 552 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 556 553 557 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false) 558 () 559 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 560 561 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false) 562 () 563 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 564 565 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedCarrier, false) 566 () 567 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 568 569 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedPickedUp, false) 554 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedUsed, false) 555 () 556 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 557 558 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedCarrier, false) 559 () 560 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 561 562 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedPickedUp, false) 570 563 () 571 564 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; … … 623 616 SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup); 624 617 SUPER_INTRUSIVE_DECLARATION(changedName); 625 SUPER_INTRUSIVE_DECLARATION(changedGametype);626 618 SUPER_INTRUSIVE_DECLARATION(changedUsed); 627 619 SUPER_INTRUSIVE_DECLARATION(changedCarrier); -
code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
r9667 r10624 44 44 #include "CommandExecutor.h" 45 45 #include "ConsoleCommand.h" 46 #include "ConsoleCommandManager.h" 46 47 #include "TclThreadManager.h" 47 48 … … 98 99 99 100 // get all the groups that are visible (except the shortcut group "") 100 const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand ::getCommands();101 const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommandManager::getInstance().getCommands(); 101 102 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group) 102 103 if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0)) … … 137 138 138 139 // find the iterator of the given group 139 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand ::getCommands().begin();140 for ( ; it_group != ConsoleCommand ::getCommands().end(); ++it_group)140 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin(); 141 for ( ; it_group != ConsoleCommandManager::getInstance().getCommands().end(); ++it_group) 141 142 if (getLowercase(it_group->first) == groupLC) 142 143 break; 143 144 144 145 // add all commands in the group to the list 145 if (it_group != ConsoleCommand ::getCommands().end())146 if (it_group != ConsoleCommandManager::getInstance().getCommands().end()) 146 147 { 147 148 for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command) … … 206 207 return detail::_groupsandcommands(fragment, true); 207 208 208 if (ConsoleCommand ::getCommandLC(getLowercase(tokens[0])))209 if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0]))) 209 210 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment); 210 211 211 212 if (tokens.size() == 1) 212 213 { 213 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand ::getCommands().find(tokens[0]);214 if (it_group != ConsoleCommand ::getCommands().end())214 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]); 215 if (it_group != ConsoleCommandManager::getInstance().getCommands().end()) 215 216 return detail::_subcommands(fragment, tokens[0], true); 216 217 else … … 218 219 } 219 220 220 if (ConsoleCommand ::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))221 if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1]))) 221 222 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment); 222 223 -
code/trunk/src/libraries/core/command/CMakeLists.txt
r7284 r10624 4 4 ConsoleCommand.cc 5 5 ConsoleCommandCompilation.cc 6 ConsoleCommandIncludes.cc 7 ConsoleCommandManager.cc 6 8 Executor.cc 7 9 IOConsole.cc -
code/trunk/src/libraries/core/command/CommandEvaluation.cc
r9550 r10624 37 37 #include "CommandExecutor.h" 38 38 #include "ConsoleCommand.h" 39 #include "ConsoleCommandManager.h" 39 40 40 41 namespace orxonox … … 305 306 // the user typed 1-2 arguments, check what he tried to type and print a suitable error 306 307 std::string groupLC = getLowercase(this->getToken(0)); 307 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand ::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)308 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group) 308 309 if (it_group->first == groupLC) 309 310 return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\"."; … … 327 328 328 329 // iterate through all groups and their commands and calculate the distance to the current command. keep the best. 329 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand ::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)330 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group) 330 331 { 331 332 if (it_group->first != "") … … 345 346 346 347 // now also iterate through all shortcuts and keep the best if it's better than the one found above. 347 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand ::getCommandsLC().find("");348 if (it_group != ConsoleCommand ::getCommandsLC().end())348 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find(""); 349 if (it_group != ConsoleCommandManager::getInstance().getCommandsLC().end()) 349 350 { 350 351 for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name) -
code/trunk/src/libraries/core/command/CommandExecutor.cc
r9550 r10624 34 34 #include "CommandExecutor.h" 35 35 36 #include "ConsoleCommand .h"36 #include "ConsoleCommandIncludes.h" 37 37 #include "TclBind.h" 38 38 #include "Shell.h" … … 155 155 156 156 // assign the fallback-command to get hints about the possible commands and groups 157 evaluation.hintCommand_ = ConsoleCommand ::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);157 evaluation.hintCommand_ = ConsoleCommandManager::getInstance().getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name); 158 158 159 159 // check if there's at least one argument … … 161 161 { 162 162 // try to get a command from the first token 163 evaluation.execCommand_ = ConsoleCommand ::getCommandLC(evaluation.getToken(0));163 evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0)); 164 164 if (evaluation.execCommand_) 165 165 evaluation.execArgumentsOffset_ = 1; … … 167 167 { 168 168 // try to get a command from the first two tokens 169 evaluation.execCommand_ = ConsoleCommand ::getCommandLC(evaluation.getToken(0), evaluation.getToken(1));169 evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0), evaluation.getToken(1)); 170 170 if (evaluation.execCommand_) 171 171 evaluation.execArgumentsOffset_ = 2; … … 288 288 289 289 // check if the alias already exists - print an error and return if it does 290 if ((tokens.size() == 1 && ConsoleCommand ::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1])))290 if ((tokens.size() == 1 && ConsoleCommandManager::getInstance().getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommandManager::getInstance().getCommand(tokens[0], tokens[1]))) 291 291 { 292 292 orxout(user_error) << "A command with name \"" << alias << "\" already exists." << endl; … … 296 296 // create a new console command with the given alias as its name 297 297 if (tokens.size() == 1) 298 createConsoleCommand(tokens[0], executor);298 ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], executor)); 299 299 else if (tokens.size() == 2) 300 createConsoleCommand(tokens[0], tokens[1], executor);300 ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], tokens[1], executor)); 301 301 else 302 302 orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl; -
code/trunk/src/libraries/core/command/ConsoleCommand.cc
r9348 r10624 35 35 36 36 #include "util/Convert.h" 37 #include "util/StringUtils.h"38 37 #include "core/Language.h" 39 38 #include "core/GameMode.h" 40 39 #include "core/input/KeyBinder.h" 41 40 #include "core/input/KeyBinderManager.h" 41 #include "ConsoleCommandManager.h" 42 42 43 43 namespace orxonox 44 44 { 45 45 /** 46 @brief Constructor: Initializes all values and registers the command. 46 @brief Constructor: Initializes all values and registers the command (without a group). 47 @param name The name of the command 48 @param executor The executor of the command 49 @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used. 50 */ 51 ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized) 52 { 53 this->init("", name, executor, bInitialized); 54 } 55 56 /** 57 @brief Constructor: Initializes all values and registers the command (with a group). 47 58 @param group The group of the command 48 59 @param name The name of the command … … 52 63 ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized) 53 64 { 65 this->init(group, name, executor, bInitialized); 66 } 67 68 void ConsoleCommand::init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized) 69 { 54 70 this->bActive_ = true; 55 71 this->bHidden_ = false; … … 68 84 this->executor_ = executor; 69 85 70 ConsoleCommand::registerCommand(group, name, this);86 this->names_.push_back(CommandName(group, name)); 71 87 } 72 88 … … 76 92 ConsoleCommand::~ConsoleCommand() 77 93 { 78 ConsoleCommand::unregisterCommand(this);79 94 } 80 95 … … 84 99 ConsoleCommand& ConsoleCommand::addShortcut() 85 100 { 86 ConsoleCommand::registerCommand("", this->baseName_, this);101 this->names_.push_back(CommandName("", this->baseName_)); 87 102 return *this; 88 103 } … … 93 108 ConsoleCommand& ConsoleCommand::addShortcut(const std::string& name) 94 109 { 95 ConsoleCommand::registerCommand("", name, this);110 this->names_.push_back(CommandName("", name)); 96 111 return *this; 97 112 } … … 102 117 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group) 103 118 { 104 ConsoleCommand::registerCommand(group, this->baseName_, this);119 this->names_.push_back(CommandName(group, this->baseName_)); 105 120 return *this; 106 121 } … … 111 126 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string& name) 112 127 { 113 ConsoleCommand::registerCommand(group, name, this);128 this->names_.push_back(CommandName(group, name)); 114 129 return *this; 115 130 } … … 587 602 return *this; 588 603 } 589 590 /**591 @brief Returns the command with given group an name.592 @param group The group of the requested command593 @param name The group of the requested command594 @param bPrintError If true, an error is printed if the command doesn't exist595 */596 /* static */ ConsoleCommand* ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)597 {598 // find the group599 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMap().find(group);600 if (it_group != ConsoleCommand::getCommandMap().end())601 {602 // find the name603 std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);604 if (it_name != it_group->second.end())605 {606 // return the pointer607 return it_name->second;608 }609 }610 if (bPrintError)611 {612 if (group == "")613 orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;614 else615 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;616 }617 return 0;618 }619 620 /**621 @brief Returns the command with given group an name in lowercase.622 @param group The group of the requested command in lowercase623 @param name The group of the requested command in lowercase624 @param bPrintError If true, an error is printed if the command doesn't exist625 */626 /* static */ ConsoleCommand* ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)627 {628 std::string groupLC = getLowercase(group);629 std::string nameLC = getLowercase(name);630 631 // find the group632 std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMapLC().find(groupLC);633 if (it_group != ConsoleCommand::getCommandMapLC().end())634 {635 // find the name636 std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);637 if (it_name != it_group->second.end())638 {639 // return the pointer640 return it_name->second;641 }642 }643 if (bPrintError)644 {645 if (group == "")646 orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;647 else648 orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;649 }650 return 0;651 }652 653 /**654 @brief Returns the static map that stores all console commands.655 */656 /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMap()657 {658 static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap;659 return commandMap;660 }661 662 /**663 @brief Returns the static map that stores all console commands in lowercase.664 */665 /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMapLC()666 {667 static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC;668 return commandMapLC;669 }670 671 /**672 @brief Registers a new command with given group an name by adding it to the command map.673 */674 /* static */ void ConsoleCommand::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)675 {676 if (name == "")677 return;678 679 // check if a command with this name already exists680 if (ConsoleCommand::getCommand(group, name) != 0)681 {682 if (group == "")683 orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;684 else685 orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;686 }687 else688 {689 // add the command to the map690 ConsoleCommand::getCommandMap()[group][name] = command;691 ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command;692 }693 }694 695 /**696 @brief Removes the command from the command map.697 */698 /* static */ void ConsoleCommand::unregisterCommand(ConsoleCommand* command)699 {700 // iterate through all groups701 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMap().begin(); it_group != ConsoleCommand::getCommandMap().end(); )702 {703 // iterate through all commands of each group704 for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )705 {706 // erase the command707 if (it_name->second == command)708 it_group->second.erase(it_name++);709 else710 ++it_name;711 }712 713 // erase the group if it is empty now714 if (it_group->second.empty())715 ConsoleCommand::getCommandMap().erase(it_group++);716 else717 ++it_group;718 }719 720 // now the same for the lowercase-map:721 722 // iterate through all groups723 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMapLC().begin(); it_group != ConsoleCommand::getCommandMapLC().end(); )724 {725 // iterate through all commands of each group726 for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )727 {728 // erase the command729 if (it_name->second == command)730 it_group->second.erase(it_name++);731 else732 ++it_name;733 }734 735 // erase the group if it is empty now736 if (it_group->second.empty())737 ConsoleCommand::getCommandMapLC().erase(it_group++);738 else739 ++it_group;740 }741 }742 743 /**744 @brief Deletes all commands745 */746 /* static */ void ConsoleCommand::destroyAll()747 {748 // delete entries until the map is empty749 while (!ConsoleCommand::getCommandMap().empty() && !ConsoleCommand::getCommandMap().begin()->second.empty())750 delete ConsoleCommand::getCommandMap().begin()->second.begin()->second;751 }752 604 } -
code/trunk/src/libraries/core/command/ConsoleCommand.h
r9983 r10624 28 28 29 29 /** 30 @defgroup ConsoleCommand Console commands31 @ingroup Command32 */33 34 /**35 30 @file 36 31 @ingroup Command ConsoleCommand 37 @brief Declaration of the orxonox::ConsoleCommand class and the SetConsoleCommand() macro. 38 39 @anchor ConsoleCommandExample 40 41 Console commands can be used to write scripts, use key-bindings or simply to be 42 entered into the shell by the user. Instances of orxonox::ConsoleCommand define 43 the function of a command, and also more information like, for example, if it is 44 active, default values, and possible arguments. 45 46 Commands need to be registered to the system statically on startup by using the 47 SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function. 48 This ensures that commands are known to the system at any time, so they can be 49 evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings. 50 51 Example: 52 @code 53 void myCoutFunction(const std::string& text) // Define a static function 54 { 55 orxout() << "Text: " << text << endl; // Print the text to the console 56 } 57 58 SetConsoleCommand("cout", &myCoutFunction); // Register the function as command with name "cout" 59 @endcode 60 61 Now you can open the shell and execute the command: 62 @code 63 $ cout Hello World 64 @endcode 65 66 Internally this command is now passed to orxonox::CommandExecutor::execute(): 67 @code 68 CommandExecutor::execute("cout HelloWorld"); 69 @endcode 70 71 CommandExecutor searches for a command with name "cout" and passes the arguments 72 "Hello World" to it. Because we registered myCoutFunction() with this command, 73 as a result the following text will be printed to the console: 74 @code 75 Text: Hello World 76 @endcode 77 78 You can add more attributes to the ConsoleCommand, by using the command-chain feature 79 of SetConsoleCommand(). For example like this: 80 @code 81 SetConsoleCommand("cout", &myCoutFunction) 82 .addGroup("output", "text") 83 .accessLevel(AccessLevel::Offline) 84 .defaultValues("no text"); 85 @endcode 86 87 Open the shell again and try it: 88 @code 89 $ cout Hello World 90 Text: Hello World 91 $ output text Hello World 92 Text: Hello World 93 $ cout 94 Text: no text 95 @endcode 96 97 If you execute it online (note: the access level is "Offline"), you will see the 98 following (or something similar): 99 @code 100 $ cout Hello World 101 Error: Can't execute command "cout", access denied. 102 @endcode 103 104 If a command is executed, the arguments are passed to an underlying function, 105 whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor. 106 The Functor contains the function-pointer, as well as the object-pointer in 107 case of a non-static member-function. The executor stores possible default-values 108 for each argument of the function. 109 110 The function of a command can be changed at any time. It's possible to just exchange 111 the function-pointer of the underlying Functor if the headers of the functions are 112 exactly the same. But you can also exchange the Functor itself or even completely 113 replace the Executor. Also the other attributes of a ConsoleCommand can be modified 114 during the game, for example it can be activated or deactivated. 115 116 To do so, the function ModifyConsoleCommand() has to be used. It returns an instance 117 of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to 118 orxonox::ConsoleCommand, but with slight differences. You can use it the same way like 119 SetConsoleCommand(), meaning you can use command-chains to change different attributes at 120 the same time. ModifyConsoleCommand() must not be executed statically, but rather in a 121 function at some point of the execution of the program. 122 123 Example: 124 @code 125 void myOtherCoutFunction(const std::string& text) // Define a new static function 126 { 127 orxout() << "Uppercase: " << getUppercase(text) << endl; // Print the text in uppercase to the console 128 } 129 130 { 131 // ... // somewhere in the code 132 133 ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction); // Modify the underlying function of the command 134 135 // ... 136 } 137 @endcode 138 139 If you now enter the command into the shell, you'll see a different behavior: 140 @code 141 $ cout Hello World 142 Uppercase: HELLO WORLD 143 $ cout 144 Uppercase: NO TEXT 145 @endcode 146 147 A few important notes about changing functions: 148 149 Instead of changing the function with setFunction(), you can also create a command-stack 150 by using pushFunction() and popFunction(). It's important to note a few things about that, 151 because the underlying structure of Executor and Functor has a few pitfalls: 152 - If you push a new function-pointer, the same executor as before will be used (and, if 153 the headers match, even the same functor can be used, which is very fast) 154 - If you push a new Functor, the same executor as before will be used 155 - If you push a new Executor, everything is changed 156 157 Note that the executor contains the @b default @b values, so if you just exchange the 158 Functor, the default values remain the same. However if you decide to change the default 159 values at any point of the stack, <b>this will also change the default values on all 160 other stack-levels</b> that share the same executor. If you don't like this behavior, 161 you have to explicitly push a new executor before changing the default values, either by 162 calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of 163 the current executor to the stack. 164 165 Another important point are object pointers in case of non-static member-functions. 166 Whenever you set or push a new function, <b>you must add the object pointer again</b> 167 because objects are stored in the Functor which is usually exchanged if you change 168 the function. 169 170 You can also use a stack for objects, but note that this <b>object-stack is different for each 171 function</b> - so if you set a new function, the object-stack will be cleared. If you push 172 a new function, the old object-stack is stored in the stack, so it can be restored if 173 you pop the function. 174 175 %DeclareConsoleCommand(): 176 177 Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast 178 to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have 179 to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine 180 the header of the future command-function. This allows to declare a command statically, 181 thus it's possible to evaluate key-bindings of this command, but the actual function 182 can be assigned at a later point. 183 184 Example: 185 @code 186 DeclareConsoleCommand("cout", &prototype::void__string); 187 @endcode 188 189 If you try to execute the command now, you see the following (or something similar): 190 @code 191 $ cout Hello World 192 Error: Can't execute command "cout", command is not active. 193 @endcode 194 195 You first have to assign a function to use the command: 196 @code 197 { 198 // ... 199 200 ModifyConsoleCommand("cout").setFunction(&myCoutFunction); 201 202 // ... 203 } 204 @endcode 205 206 Now you can use it: 207 @code 208 $ cout Hello World 209 Text: Hello World 210 @endcode 211 212 Note that the initial function prototype::void__string is defined in the namespace 213 orxonox::prototype. If there's no function with the desired header, you can extend 214 the collection of functions or simply use another function that has the same header. 32 @brief Declaration of the orxonox::ConsoleCommand class. 215 33 */ 216 34 … … 223 41 #include <vector> 224 42 225 #include "util/VA_NARGS.h"226 43 #include "ArgumentCompletionFunctions.h" 227 44 #include "Executor.h" 228 229 230 /**231 @brief Defines a console command. The macro is overloaded for 2-4 parameters.232 233 This is an overloaded macro. Depending on the number of arguments a different234 overloaded implementation of the macro will be chosen.235 236 Console commands created with SetConsoleCommand() become active immediately and237 the given function-pointer (and optionally the object) will be used to execute238 the command.239 */240 #define SetConsoleCommand(...) \241 BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))242 /**243 @brief This macro is executed if you call SetConsoleCommand() with 2 arguments.244 @param name The name (string) of the console command245 @param functionpointer The function-pointer of the corresponding command-function246 */247 #define SetConsoleCommand2(name, functionpointer) \248 SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))249 /**250 @brief This macro is executed if you call SetConsoleCommand() with 3 arguments.251 @param group The group (string) of the console command252 @param name The name (string) of the console command253 @param functionpointer The function-pointer of the corresponding command-function254 */255 #define SetConsoleCommand3(group, name, functionpointer) \256 SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))257 /**258 @brief This macro is executed if you call SetConsoleCommand() with 4 arguments.259 @param group The group (string) of the console command260 @param name The name (string) of the console command261 @param functionpointer The function-pointer of the corresponding command-function262 @param object The object that will be assigned to the command. Used for member-functions.263 */264 #define SetConsoleCommand4(group, name, functionpointer, object) \265 SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))266 267 /// Internal macro268 #define SetConsoleCommandGeneric(group, name, functor) \269 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))270 271 272 /**273 @brief Declares a console command. The macro is overloaded for 2-3 parameters.274 275 This is an overloaded macro. Depending on the number of arguments a different276 overloaded implementation of the macro will be chosen.277 278 Console commands created with DeclareConsoleCommand() don't use the the given279 function-pointer to execute the command, it is only used to define the header280 of the future command-function. The command is inactive until you manually281 set a function with orxonox::ModifyConsoleCommand(). You can use a different282 function-pointer than in the final command, as long as it has the same header.283 */284 #define DeclareConsoleCommand(...) \285 BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))286 /**287 @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments.288 @param name The name (string) of the console command289 @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function290 */291 #define DeclareConsoleCommand2(name, functionpointer) \292 DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))293 /**294 @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments.295 @param group The group (string) of the console command296 @param name The name (string) of the console command297 @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function298 */299 #define DeclareConsoleCommand3(group, name, functionpointer) \300 DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))301 302 /// Internal macro303 #define DeclareConsoleCommandGeneric(group, name, functor) \304 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))305 306 45 307 46 namespace orxonox … … 365 104 366 105 public: 106 /** 107 * @brief Defines the name of a command, consisting of an optional group ("" means no group) and the name itself. 108 */ 109 struct CommandName 110 { 111 CommandName(const std::string& group, const std::string& name) : group_(group), name_(name) {} 112 std::string group_; 113 std::string name_; 114 }; 115 367 116 /** 368 117 @brief Helper class that is used to manipulate console commands. … … 522 271 523 272 public: 273 ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true); 524 274 ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true); 525 275 ~ConsoleCommand(); … … 620 370 { return this; } 621 371 372 inline const std::vector<CommandName>& getNames() 373 { return this->names_; } 374 622 375 private: 376 void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized); 377 623 378 bool headersMatch(const FunctorPtr& functor); 624 379 bool headersMatch(const ExecutorPtr& executor); … … 641 396 AccessLevel::Enum accessLevel_; ///< The access level (the state of the game in which you can access the command) 642 397 std::string baseName_; ///< The name that was first assigned to the command 398 std::vector<CommandName> names_; ///< All names and aliases of this command 643 399 FunctorPtr baseFunctor_; ///< The functor that defines the header of the command-function 644 400 … … 655 411 LanguageEntryLabel descriptionReturnvalue_; ///< A description of the return-value 656 412 LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS]; ///< A description for each argument 657 658 public:659 /// Returns the map with all groups and commands.660 static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()661 { return ConsoleCommand::getCommandMap(); }662 /// Returns the map with all groups and commands in lowercase.663 static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()664 { return ConsoleCommand::getCommandMapLC(); }665 666 /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist667 static inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)668 { return ConsoleCommand::getCommand("", name, bPrintError); }669 /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist670 static inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)671 { return ConsoleCommand::getCommandLC("", name, bPrintError); }672 673 static ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);674 static ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);675 676 static void destroyAll();677 678 private:679 static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();680 static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();681 682 static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);683 static void unregisterCommand(ConsoleCommand* command);684 413 }; 685 686 /**687 @brief Creates a new ConsoleCommand.688 @param name The name of the command689 @param executor The executor of the command690 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.691 */692 inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)693 { return new ConsoleCommand("", name, executor, bInitialized); }694 /**695 @brief Creates a new ConsoleCommand.696 @param group The group of the command697 @param name The name of the command698 @param executor The executor of the command699 @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.700 */701 inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)702 { return new ConsoleCommand(group, name, executor, bInitialized); }703 704 705 /**706 @brief Returns a manipulator for a command with the given name.707 708 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,709 but it can still be used without checks, because all functions of ConsoleCommandManipulator710 check internally if the command exists.711 */712 inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)713 { return ConsoleCommand::getCommand(name, true); }714 /**715 @brief Returns a manipulator for a command with the given group and name.716 717 @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,718 but it can still be used without checks, because all functions of ConsoleCommandManipulator719 check internally if the command exists.720 */721 inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)722 { return ConsoleCommand::getCommand(group, name, true); }723 414 } 724 415 -
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
r8858 r10624 41 41 #include "util/ExprParser.h" 42 42 #include "util/StringUtils.h" 43 #include "ConsoleCommand .h"43 #include "ConsoleCommandIncludes.h" 44 44 #include "CommandExecutor.h" 45 45 -
code/trunk/src/libraries/core/command/IRC.cc
r8858 r10624 39 39 #include "util/Exception.h" 40 40 #include "util/StringUtils.h" 41 #include "ConsoleCommand .h"41 #include "ConsoleCommandIncludes.h" 42 42 #include "TclThreadManager.h" 43 43 -
code/trunk/src/libraries/core/command/Shell.cc
r9667 r10624 42 42 #include "core/config/ConfigFileManager.h" 43 43 #include "core/config/ConfigValueIncludes.h" 44 #include "core/ PathConfig.h"44 #include "core/ApplicationPaths.h" 45 45 #include "core/input/InputBuffer.h" 46 46 #include "CommandExecutor.h" … … 84 84 85 85 // Choose the default level according to the path Orxonox was started (build directory or not) 86 OutputLevel defaultDebugLevel = ( PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);86 OutputLevel defaultDebugLevel = (ApplicationPaths::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User); 87 87 this->setLevelMax(defaultDebugLevel); 88 88 … … 164 164 void Shell::devModeChanged(bool value) 165 165 { 166 bool isNormal = (value == PathConfig::buildDirectoryRun());166 bool isNormal = (value == ApplicationPaths::buildDirectoryRun()); 167 167 if (isNormal) 168 168 { -
code/trunk/src/libraries/core/command/Shell.h
r9667 r10624 49 49 50 50 #include "util/output/BaseWriter.h" 51 #include "core/Core .h"51 #include "core/CoreConfig.h" 52 52 53 53 namespace orxonox -
code/trunk/src/libraries/core/command/TclBind.cc
r9550 r10624 37 37 #include "util/Exception.h" 38 38 #include "util/StringUtils.h" 39 #include "core/ PathConfig.h"39 #include "core/ApplicationPaths.h" 40 40 #include "CommandExecutor.h" 41 #include "ConsoleCommand .h"41 #include "ConsoleCommandIncludes.h" 42 42 #include "TclThreadManager.h" 43 43 … … 143 143 { 144 144 #ifdef DEPENDENCY_PACKAGE_ENABLE 145 if ( PathConfig::buildDirectoryRun())145 if (ApplicationPaths::buildDirectoryRun()) 146 146 return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl"); 147 147 else 148 return ( PathConfig::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");148 return (ApplicationPaths::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl"); 149 149 #else 150 150 return ""; -
code/trunk/src/libraries/core/command/TclThreadManager.cc
r8858 r10624 47 47 #include "core/CoreIncludes.h" 48 48 #include "CommandExecutor.h" 49 #include "ConsoleCommand .h"49 #include "ConsoleCommandIncludes.h" 50 50 #include "TclBind.h" 51 51 #include "TclThreadList.h" -
code/trunk/src/libraries/core/config/CMakeLists.txt
r9667 r10624 1 1 ADD_SOURCE_FILES(CORE_SRC_FILES 2 CommandLineParser.cc3 2 # ConfigFile.cc is already included in FilesystemBuildUnit.cc 4 3 ConfigFileEntryValue.cc -
code/trunk/src/libraries/core/config/ConfigFile.cc
r9559 r10624 38 38 #include "util/Convert.h" 39 39 #include "util/StringUtils.h" 40 #include "core/ PathConfig.h"40 #include "core/ConfigurablePaths.h" 41 41 #include "ConfigFileEntryComment.h" 42 42 #include "ConfigFileEntryValue.h" … … 81 81 if (!filepath.is_complete()) 82 82 { 83 filepath = PathConfig::getConfigPath() / filepath;83 filepath = ConfigurablePaths::getConfigPath() / filepath; 84 84 if (this->bCopyFallbackFile_) 85 85 { … … 87 87 if (!boost::filesystem::exists(filepath)) 88 88 { 89 boost::filesystem::path defaultFilepath( PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);89 boost::filesystem::path defaultFilepath(ConfigurablePaths::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_); 90 90 if (boost::filesystem::exists(defaultFilepath)) 91 91 { … … 216 216 boost::filesystem::path filepath(filename); 217 217 if (!filepath.is_complete()) 218 filepath = PathConfig::getConfigPath() / filename;218 filepath = ConfigurablePaths::getConfigPath() / filename; 219 219 std::ofstream file; 220 220 file.open(filepath.string().c_str(), std::fstream::out); -
code/trunk/src/libraries/core/config/Configurable.cc
r9667 r10624 32 32 namespace orxonox 33 33 { 34 RegisterClassNoArgs(Configurable) ;34 RegisterClassNoArgs(Configurable).virtualBase(); 35 35 36 36 Configurable::Configurable() -
code/trunk/src/libraries/core/config/SettingsConfigFile.cc
r9569 r10624 35 35 36 36 #include "util/StringUtils.h" 37 #include "core/command/ConsoleCommand .h"37 #include "core/command/ConsoleCommandIncludes.h" 38 38 #include "ConfigFileManager.h" 39 39 #include "ConfigValueContainer.h" -
code/trunk/src/libraries/core/input/InputManager.cc
r9667 r10624 48 48 #include "core/GraphicsManager.h" 49 49 #include "core/config/ConfigValueIncludes.h" 50 #include "core/co nfig/CommandLineParser.h"51 #include "core/command/ConsoleCommand .h"50 #include "core/commandline/CommandLineIncludes.h" 51 #include "core/command/ConsoleCommandIncludes.h" 52 52 #include "core/command/Functor.h" 53 53 … … 85 85 return (lval = (InputManager::State)(lval & rval)); 86 86 } 87 88 RegisterAbstractClass(InputManager).inheritsFrom<WindowEventListener>(); 87 89 88 90 // ############################################################ -
code/trunk/src/libraries/core/input/JoyStick.cc
r9667 r10624 47 47 48 48 std::vector<std::string> JoyStick::deviceNames_s; 49 50 RegisterAbstractClass(JoyStick).inheritsFrom<Configurable>(); 49 51 50 52 JoyStick::JoyStick(unsigned int id, OIS::InputManager* oisInputManager) -
code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc
r9667 r10624 36 36 std::vector<JoyStick*> JoyStickQuantityListener::joyStickList_s; 37 37 38 RegisterAbstractClass(JoyStickQuantityListener).inheritsFrom<Listable>(); 39 38 40 JoyStickQuantityListener::JoyStickQuantityListener() 39 41 { -
code/trunk/src/libraries/core/input/KeyBinder.cc
r9667 r10624 37 37 #include "core/config/ConfigValueIncludes.h" 38 38 #include "core/config/ConfigFile.h" 39 #include "core/PathConfig.h" 39 #include "core/ApplicationPaths.h" 40 #include "core/ConfigurablePaths.h" 40 41 #include "InputCommands.h" 41 42 #include "JoyStick.h" … … 43 44 namespace orxonox 44 45 { 46 RegisterAbstractClass(KeyBinder).inheritsFrom<JoyStickQuantityListener>(); 47 45 48 /** 46 49 @brief … … 253 256 orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl; 254 257 255 this->configFile_ = new ConfigFile(this->filename_, ! PathConfig::buildDirectoryRun());258 this->configFile_ = new ConfigFile(this->filename_, !ApplicationPaths::buildDirectoryRun()); 256 259 this->configFile_->load(); 257 260 258 if ( PathConfig::buildDirectoryRun())261 if (ApplicationPaths::buildDirectoryRun()) 259 262 { 260 263 // Dev users should have combined key bindings files 261 std::string defaultFilepath( PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);264 std::string defaultFilepath(ConfigurablePaths::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_); 262 265 std::ifstream file(defaultFilepath.c_str()); 263 266 if (file.is_open()) … … 287 290 addButtonToCommand(binding, it->second); 288 291 std::string str = binding; 289 if ( PathConfig::buildDirectoryRun() && binding.empty())292 if (ApplicationPaths::buildDirectoryRun() && binding.empty()) 290 293 str = "NoBinding"; 291 294 it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary); -
code/trunk/src/libraries/core/input/KeyBinderManager.cc
r9667 r10624 31 31 #include "util/Output.h" 32 32 #include "util/Exception.h" 33 #include " util/ScopedSingletonManager.h"33 #include "core/singleton/ScopedSingletonIncludes.h" 34 34 #include "core/config/ConfigValueIncludes.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "core/LuaState.h" 37 #include "core/command/ConsoleCommand .h"37 #include "core/command/ConsoleCommandIncludes.h" 38 38 #include "InputManager.h" 39 39 #include "KeyDetector.h" … … 41 41 namespace orxonox 42 42 { 43 ManageScopedSingleton(KeyBinderManager, ScopeID::G raphics, false);43 ManageScopedSingleton(KeyBinderManager, ScopeID::GRAPHICS, false); 44 44 45 45 static const std::string __CC_keybind_name = "keybind"; … … 52 52 SetConsoleCommand(__CC_unbind_name, &KeyBinderManager::unbind).defaultValues(""); 53 53 SetConsoleCommand(__CC_tunbind_name, &KeyBinderManager::tunbind).defaultValues(""); 54 55 RegisterAbstractClass(KeyBinderManager).inheritsFrom<Configurable>(); 54 56 55 57 KeyBinderManager::KeyBinderManager() -
code/trunk/src/libraries/core/input/KeyDetector.cc
r7284 r10624 29 29 #include "KeyDetector.h" 30 30 31 #include "util/ScopedSingletonManager.h"32 31 #include "core/CoreIncludes.h" 33 #include "core/command/ConsoleCommand.h" 32 #include "core/singleton/ScopedSingletonIncludes.h" 33 #include "core/command/ConsoleCommandIncludes.h" 34 34 #include "Button.h" 35 35 #include "InputManager.h" … … 38 38 namespace orxonox 39 39 { 40 ManageScopedSingleton(KeyDetector, ScopeID::G raphics, false);40 ManageScopedSingleton(KeyDetector, ScopeID::GRAPHICS, false); 41 41 42 42 static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed"; 43 43 DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide(); 44 45 RegisterAbstractClass(KeyDetector).inheritsFrom<KeyBinder>(); 44 46 45 47 KeyDetector::KeyDetector() -
code/trunk/src/libraries/core/input/Mouse.cc
r9667 r10624 31 31 #include <ois/OISMouse.h> 32 32 #include "core/CoreIncludes.h" 33 #include "core/command/ConsoleCommand .h"33 #include "core/command/ConsoleCommandIncludes.h" 34 34 #include "InputState.h" 35 35 … … 50 50 SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab); 51 51 #endif 52 53 RegisterAbstractClass(Mouse).inheritsFrom<WindowEventListener>(); 52 54 53 55 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager) -
code/trunk/src/libraries/core/object/CMakeLists.txt
r9667 r10624 2 2 Context.cc 3 3 Destroyable.cc 4 DestroyLaterManager.cc 4 5 Listable.cc 5 6 ObjectListBase.cc -
code/trunk/src/libraries/core/object/Context.cc
r9667 r10624 76 76 /*static*/ void Context::setRootContext(Context* context) 77 77 { 78 if (Context::rootContext_s)79 delete Context::rootContext_s;80 78 Context::rootContext_s = context; 79 } 80 81 /*static*/ void Context::destroyRootContext() 82 { 83 delete Context::rootContext_s; 84 Context::rootContext_s = NULL; 81 85 } 82 86 83 87 /*static*/ Context* Context::getRootContext() 84 88 { 85 if (!Context::rootContext_s) 86 Context::rootContext_s = new Context(NULL); 89 OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined"); 87 90 return Context::rootContext_s; 88 91 } … … 97 100 return this->objectLists_[classID]; 98 101 } 102 103 void Context::destroyObjectList(const Identifier* identifier) 104 { 105 ObjectListBase* objectList = this->getObjectList(identifier); 106 delete objectList; 107 this->objectLists_[identifier->getClassID()] = NULL; 108 } 99 109 } -
code/trunk/src/libraries/core/object/Context.h
r9667 r10624 47 47 public: 48 48 static void setRootContext(Context* context); 49 static void destroyRootContext(); 49 50 static Context* getRootContext(); 50 51 … … 71 72 } 72 73 74 void destroyObjectList(const Identifier* identifier); 75 73 76 private: 74 77 Context* parentContext_; -
code/trunk/src/libraries/core/object/Destroyable.cc
r9944 r10624 33 33 34 34 #include "Destroyable.h" 35 #include "DestroyLaterManager.h" 35 36 36 37 #include <cassert> … … 60 61 61 62 /** 62 @brief Deletes the object if no @ref orxonox::S martPtr "smartpointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.63 Always call destroy() instead of using 'delete' directly, otherwise s martpointers won't work.63 @brief Deletes the object if no @ref orxonox::StrongPtr "strong pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible. 64 Always call destroy() instead of using 'delete' directly, otherwise strong pointers won't work. 64 65 */ 65 66 void Destroyable::destroy() … … 74 75 } 75 76 } 77 78 /** 79 * Works like @ref destroy() but doesn't destroy the object until the current tick has ended. 80 */ 81 void Destroyable::destroyLater() 82 { 83 // register in DestroyLaterManager - this ensures that a strongPtr points to this object and keeps it alive for a while 84 DestroyLaterManager::getInstance().retain(this); 85 86 // request destruction -> object will be deleted after all strongPtrs (including the one in DestroyLaterManager) were destroyed. 87 this->destroy(); 88 } 76 89 } -
code/trunk/src/libraries/core/object/Destroyable.h
r9944 r10624 30 30 @file 31 31 @ingroup Object 32 @brief Declaration of Destroyable, the base class of all objects which can be used with S martPtr and WeakPtr.32 @brief Declaration of Destroyable, the base class of all objects which can be used with StrongPtr and WeakPtr. 33 33 */ 34 34 … … 43 43 { 44 44 /** 45 @brief Classes must inherit from this class if they should be used with S martPtr or WeakPtr.45 @brief Classes must inherit from this class if they should be used with StrongPtr or WeakPtr. 46 46 */ 47 47 class _CoreExport Destroyable 48 48 { 49 49 template <class T> 50 friend class S martPtr;50 friend class StrongPtr; 51 51 52 52 friend class DestructionListener; … … 57 57 58 58 void destroy(); 59 void destroyLater(); 59 60 60 /// Returns the number of @ref orxonox::S martPtr "smartpointers" that point to this object.61 /// Returns the number of @ref orxonox::StrongPtr "strong pointers" that point to this object. 61 62 inline unsigned int getReferenceCount() const 62 63 { return this->referenceCount_; } 63 64 64 65 protected: 65 /// This virtual function is called if destroy() is called and no S martPtr points to this object. Used in some cases to create a new SmartPtr to66 /// This virtual function is called if destroy() is called and no StrongPtr points to this object. Used in some cases to create a new StrongPtr to 66 67 /// prevent destruction. Don't call this function directly - use destroy() instead. 67 68 virtual void preDestroy() {} 68 69 69 70 private: 70 /// Increments the reference counter (for s martpointers).71 /// Increments the reference counter (for strong pointers). 71 72 inline void incrementReferenceCount() 72 73 { ++this->referenceCount_; } 73 /// Decrements the reference counter (for s martpointers).74 /// Decrements the reference counter (for strong pointers). 74 75 inline void decrementReferenceCount() 75 76 { … … 86 87 { this->destructionListeners_.erase(pointer); } 87 88 88 int referenceCount_; //!< Counts the references from s martpointers to this object89 int referenceCount_; //!< Counts the references from strong pointers to this object 89 90 bool requestedDestruction_; //!< Becomes true after someone called delete on this object 90 91 std::set<DestructionListener*> destructionListeners_; //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies) -
code/trunk/src/libraries/core/object/Iterator.h
r9667 r10624 76 76 @brief Constructor: Sets the element, whereon the iterator points, to zero. 77 77 */ 78 inline Iterator() : IteratorBase<T, Iterator<T> >( NULL) {}78 inline Iterator() : IteratorBase<T, Iterator<T> >() {} 79 79 80 80 /** … … 88 88 @param other The other Iterator 89 89 */ 90 inline Iterator(const Iterator <T>& other) : IteratorBase<T, Iterator<T> >(other) {}90 inline Iterator(const IteratorBase<T, Iterator<T> >& other) : IteratorBase<T, Iterator<T> >(other) {} 91 91 92 92 /** -
code/trunk/src/libraries/core/object/IteratorBase.h
r9667 r10624 37 37 38 38 #include "core/CorePrereqs.h" 39 40 #include <boost/static_assert.hpp> 41 #include <boost/type_traits/is_base_of.hpp> 39 42 40 43 #include "ObjectListBase.h" … … 49 52 class IteratorBase : public ObjectListElementRemovalListener 50 53 { 54 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value)); 55 56 protected: 57 /** 58 @brief Constructor: Sets the element, whereon the iterator points, to the given element. 59 This constructor is protected and only for internal usage (don't mess with the BaseElements directly). 60 */ 61 inline IteratorBase(ObjectListBaseElement* element = NULL) 62 { 63 this->element_ = element; 64 this->registerIterator(); 65 } 66 67 51 68 public: 52 69 /** 53 @brief Constructor: Sets the element, whereon the iterator points, to zero. 54 */ 55 inline IteratorBase(ObjectListBaseElement* element) 56 { 70 @brief Constructor: Sets the element, whereon the iterator points, to the given element. 71 */ 72 inline IteratorBase(ObjectListElement<T>* element) 73 { 74 this->element_ = element; 75 this->registerIterator(); 76 } 77 78 /** 79 @brief Constructor: Sets the element, whereon the iterator points, to the given element of another type. 80 The element's type O must be a derivative of the Iterator's type T. 81 */ 82 template <class O> 83 inline IteratorBase(ObjectListElement<O>* element) 84 { 85 (void)static_cast<T*>((O*)NULL); // Check type: The element's type O must be a derivative of the Iterator's type T. 57 86 this->element_ = element; 58 87 this->registerIterator(); -
code/trunk/src/libraries/core/object/Listable.cc
r9667 r10624 39 39 namespace orxonox 40 40 { 41 RegisterClass(Listable) ;41 RegisterClass(Listable).virtualBase(); 42 42 43 43 /** -
code/trunk/src/libraries/core/object/ObjectList.h
r9667 r10624 47 47 #include "core/CorePrereqs.h" 48 48 49 #include <boost/static_assert.hpp> 50 #include <boost/type_traits/is_base_of.hpp> 51 49 52 #include "ObjectListBase.h" 50 53 #include "ObjectListIterator.h" … … 66 69 class ObjectList 67 70 { 71 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value)); 72 68 73 public: 69 74 typedef ObjectListIterator<T> iterator; 70 75 76 /// Returns the size of the list (for the root context) 77 inline static size_t size() 78 { return size(Context::getRootContext()); } 71 79 /// Returns the size of the list 72 inline static size_t size( )80 inline static size_t size(Context* context) 73 81 { 74 return Context::getRootContext()->getObjectList<T>()->size();82 return context->getObjectList<T>()->size(); 75 83 } 76 84 85 /// Returns an Iterator to the first element in the list (for the root context). 86 inline static ObjectListElement<T>* begin() 87 { return begin(Context::getRootContext()); } 77 88 /// Returns an Iterator to the first element in the list. 78 inline static ObjectListElement<T>* begin( )89 inline static ObjectListElement<T>* begin(Context* context) 79 90 { 80 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();91 ObjectListBase* list = context->getObjectList<T>(); 81 92 return static_cast<ObjectListElement<T>*>(list->begin()); 82 93 } 83 94 95 /// Returns an Iterator to the element after the last element in the list (for the root context). 96 inline static ObjectListElement<T>* end() 97 { return end(Context::getRootContext()); } 84 98 /// Returns an Iterator to the element after the last element in the list. 85 inline static ObjectListElement<T>* end( )99 inline static ObjectListElement<T>* end(Context* context) 86 100 { 87 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();101 ObjectListBase* list = context->getObjectList<T>(); 88 102 return static_cast<ObjectListElement<T>*>(list->end()); 89 103 } 90 104 105 /// Returns an Iterator to the last element in the list (for the root context). 106 inline static ObjectListElement<T>* rbegin() 107 { return rbegin(Context::getRootContext()); } 91 108 /// Returns an Iterator to the last element in the list. 92 inline static ObjectListElement<T>* rbegin( )109 inline static ObjectListElement<T>* rbegin(Context* context) 93 110 { 94 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();111 ObjectListBase* list = context->getObjectList<T>(); 95 112 return static_cast<ObjectListElement<T>*>(list->rbegin()); 96 113 } 97 114 115 /// Returns an Iterator to the element before the first element in the list (for the root context). 116 inline static ObjectListElement<T>* rend() 117 { return rend(Context::getRootContext()); } 98 118 /// Returns an Iterator to the element before the first element in the list. 99 inline static ObjectListElement<T>* rend( )119 inline static ObjectListElement<T>* rend(Context* context) 100 120 { 101 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();121 ObjectListBase* list = context->getObjectList<T>(); 102 122 return static_cast<ObjectListElement<T>*>(list->rend()); 103 123 } -
code/trunk/src/libraries/core/object/ObjectListIterator.h
r9667 r10624 74 74 @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero. 75 75 */ 76 inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >( NULL) {}76 inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >() {} 77 77 78 78 /** -
code/trunk/src/libraries/core/object/WeakPtr.h
r9571 r10624 104 104 } 105 105 106 /// Constructor: Used to explicitly initialize the weak pointer with a null pointer107 inline WeakPtr(int) : pointer_(0), base_(0), callback_(0)108 {109 }110 111 106 /// Constructor: Initializes the weak pointer with a pointer to an object. 112 107 inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0) … … 132 127 { 133 128 this->unregisterAsDestructionListener(this->base_); 134 }135 136 /// Used to assign a null pointer.137 inline WeakPtr& operator=(int)138 {139 WeakPtr(0).swap(*this);140 return *this;141 129 } 142 130 -
code/trunk/src/libraries/network/CMakeLists.txt
r8858 r10624 34 34 MasterServerComm.cc 35 35 NetworkFunction.cc 36 NetworkFunctionIncludes.cc 37 NetworkFunctionManager.cc 38 NetworkStaticInitializationHandler.cc 36 39 Host.cc 37 40 Server.cc … … 43 46 ) 44 47 45 SET_SOURCE_FILES(NETWORK_HDR_FILES46 Client.h47 ClientConnection.h48 ClientConnectionListener.h49 Connection.h50 FunctionCall.h51 FunctionCallManager.h52 #GamestateClient.h53 GamestateHandler.h54 GamestateManager.h55 Host.h56 LANDiscoverable.h57 LANDiscovery.h58 WANDiscoverable.h59 WANDiscovery.h60 MasterServerComm.h61 NetworkChatListener.h62 NetworkFunction.h63 NetworkPrecompiledHeaders.h64 NetworkPrereqs.h65 Server.h66 MasterServer.h67 PeerList.h68 ServerList.h69 ServerConnection.h70 TrafficControl.h71 )72 73 48 ADD_SUBDIRECTORY(packet) 74 49 ADD_SUBDIRECTORY(synchronisable) 75 50 76 51 ORXONOX_ADD_LIBRARY(network 52 FIND_HEADER_FILES 77 53 TOLUA_FILES 78 54 Client.h … … 90 66 core 91 67 SOURCE_FILES 92 ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}68 ${NETWORK_SRC_FILES} 93 69 ) -
code/trunk/src/libraries/network/Client.cc
r9667 r10624 45 45 #include "util/Clock.h" 46 46 #include "util/Output.h" 47 #include "util/ScopedSingletonManager.h"48 47 #include "synchronisable/Synchronisable.h" 49 48 #include "packet/Chat.h" … … 52 51 #include "core/CoreIncludes.h" 53 52 #include "core/Game.h" 54 #include "core/config/CommandLineParser.h" 53 #include "core/commandline/CommandLineParser.h" 54 #include "core/singleton/ScopedSingletonIncludes.h" 55 55 56 56 namespace orxonox 57 57 { 58 58 59 ManageScopedSingleton( Client, ScopeID::R oot, true );59 ManageScopedSingleton( Client, ScopeID::ROOT, false ); 60 60 61 61 /** … … 194 194 void Client::connectionClosed() 195 195 { 196 ObjectList<Synchronisable>::iterator it;197 for(it = ObjectList<Synchronisable>::begin(); it; )198 {199 if( it->getSyncMode() != 0x0 )200 (it++)->destroy();201 else202 {203 ++it;204 }205 }206 196 Game::getInstance().popState(); 207 197 Game::getInstance().popState(); -
code/trunk/src/libraries/network/ClientConnectionListener.cc
r9667 r10624 35 35 namespace orxonox 36 36 { 37 RegisterAbstractClass(ClientConnectionListener).inheritsFrom (Class(Listable));37 RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>(); 38 38 39 39 ClientConnectionListener::ClientConnectionListener() -
code/trunk/src/libraries/network/FunctionCall.cc
r7503 r10624 32 32 #include "util/MultiType.h" 33 33 #include "NetworkFunction.h" 34 #include "NetworkFunctionManager.h" 34 35 35 36 namespace orxonox { … … 46 47 47 48 bool FunctionCall::execute(){ 48 if( this->bIsStatic_ ) 49 NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ ); 50 assert( fct != NULL ); 51 assert( this->nrOfArguments_==this->arguments_.size() ); 52 switch(this->nrOfArguments_) 49 53 { 50 NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( this->functionID_ ); 51 assert( this->nrOfArguments_==this->arguments_.size() ); 52 switch(this->nrOfArguments_) 53 { 54 case 0: 55 fct->call(); 56 break; 57 case 1: 58 fct->call(this->arguments_[0]); 59 break; 60 case 2: 61 fct->call(this->arguments_[0], this->arguments_[1]); 62 break; 63 case 3: 64 fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]); 65 break; 66 case 4: 67 fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]); 68 break; 69 case 5: 70 fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]); 71 break; 72 default: 73 assert(0); 74 } 54 case 0: 55 return fct->call(this->objectID_); 56 case 1: 57 return fct->call(this->objectID_, this->arguments_[0]); 58 case 2: 59 return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]); 60 case 3: 61 return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]); 62 case 4: 63 return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]); 64 case 5: 65 return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]); 66 default: 67 assert(0); 68 return true; // return true to avoid that this functions gets called over and over again 75 69 } 76 else // not a static function, so also handle with the objectID77 {78 NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( this->functionID_ );79 switch(this->nrOfArguments_)80 {81 case 0:82 if( !fct->call(this->objectID_) )83 return false;84 break;85 case 1:86 if( !fct->call(this->objectID_, this->arguments_[0]) )87 return false;88 break;89 case 2:90 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )91 return false;92 break;93 case 3:94 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )95 return false;96 break;97 case 4:98 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )99 return false;100 break;101 case 5:102 if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )103 return false;104 break;105 default:106 assert(0);107 }108 }109 return true;110 70 } 111 71 112 void FunctionCall::setCall Static( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType*mt5){72 void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ 113 73 114 74 // first determine the size that has to be reserved for this call 115 uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic75 uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID 116 76 uint32_t nrOfArguments = 0; 117 if( mt1)77 if(!mt1.null()) 118 78 { 119 79 nrOfArguments++; 120 callsize += mt1 ->getNetworkSize();121 this->arguments_.push_back( *mt1);122 if( mt2)80 callsize += mt1.getNetworkSize(); 81 this->arguments_.push_back(mt1); 82 if(!mt2.null()) 123 83 { 124 84 nrOfArguments++; 125 callsize += mt2 ->getNetworkSize();126 this->arguments_.push_back( *mt2);127 if( mt3)85 callsize += mt2.getNetworkSize(); 86 this->arguments_.push_back(mt2); 87 if(!mt3.null()) 128 88 { 129 89 nrOfArguments++; 130 callsize += mt3 ->getNetworkSize();131 this->arguments_.push_back( *mt3);132 if( mt4)90 callsize += mt3.getNetworkSize(); 91 this->arguments_.push_back(mt3); 92 if(!mt4.null()) 133 93 { 134 94 nrOfArguments++; 135 callsize += mt4 ->getNetworkSize();136 this->arguments_.push_back( *mt4);137 if( mt5)95 callsize += mt4.getNetworkSize(); 96 this->arguments_.push_back(mt4); 97 if(!mt5.null()) 138 98 { 139 99 nrOfArguments++; 140 callsize += mt5 ->getNetworkSize();141 this->arguments_.push_back( *mt5);100 callsize += mt5.getNetworkSize(); 101 this->arguments_.push_back(mt5); 142 102 } 143 103 } … … 146 106 } 147 107 this->nrOfArguments_ = nrOfArguments; 108 this->functionID_ = networkID; 109 this->objectID_ = objectID; 148 110 this->size_ = callsize; 149 this->bIsStatic_ = true;150 this->functionID_ = networkID;151 }152 153 void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){154 155 // first determine the size that has to be reserved for this call156 uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic157 uint32_t nrOfArguments = 0;158 if(mt1)159 {160 nrOfArguments++;161 callsize += mt1->getNetworkSize();162 this->arguments_.push_back(*mt1);163 if(mt2)164 {165 nrOfArguments++;166 callsize += mt2->getNetworkSize();167 this->arguments_.push_back(*mt2);168 if(mt3)169 {170 nrOfArguments++;171 callsize += mt3->getNetworkSize();172 this->arguments_.push_back(*mt3);173 if(mt4)174 {175 nrOfArguments++;176 callsize += mt4->getNetworkSize();177 this->arguments_.push_back(*mt4);178 if(mt5)179 {180 nrOfArguments++;181 callsize += mt5->getNetworkSize();182 this->arguments_.push_back(*mt5);183 }184 }185 }186 }187 }188 this->nrOfArguments_ = nrOfArguments;189 this->bIsStatic_ = false;190 this->functionID_ = networkID;191 this->size_ = callsize;192 this->objectID_ = objectID;193 111 } 194 112 … … 196 114 { 197 115 this->functionID_ = *(uint32_t*)mem; 198 this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t)); 199 this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)); 200 if( this->bIsStatic_ ) 201 { 202 mem += 2*sizeof(uint32_t)+sizeof(uint8_t); 203 } 204 else 205 { 206 this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)); 207 mem += 3*sizeof(uint32_t)+sizeof(uint8_t); 208 } 116 this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)); 117 this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)); 118 mem += 3*sizeof(uint32_t); 209 119 for( unsigned int i=0; i<this->nrOfArguments_; ++i ) 210 120 { … … 218 128 // now serialise the mt values and copy the function id and isStatic 219 129 *(uint32_t*)mem = this->functionID_; 220 *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_; 221 *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_; 222 if( this->bIsStatic_ ) 223 { 224 mem += 2*sizeof(uint32_t)+sizeof(uint8_t); 225 } 226 else 227 { 228 *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_; 229 mem += 3*sizeof(uint32_t)+sizeof(uint8_t); 230 } 130 *(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_; 131 *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_; 132 mem += 3*sizeof(uint32_t); 231 133 for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it ) 232 134 { -
code/trunk/src/libraries/network/FunctionCall.h
r7495 r10624 52 52 bool execute(); 53 53 54 void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 55 void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 54 void setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 56 55 57 56 void saveData( uint8_t*& mem ); … … 59 58 private: 60 59 uint32_t nrOfArguments_; 61 bool bIsStatic_;62 60 uint32_t functionID_; 63 uint32_t objectID_; 61 uint32_t objectID_; // equals OBJECTID_UNKNOWN for static functions 64 62 uint32_t size_; 65 63 std::vector<MultiType> arguments_; -
code/trunk/src/libraries/network/FunctionCallManager.cc
r8403 r10624 39 39 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_; 40 40 41 // Static calls42 41 43 void FunctionCallManager::addCall Static(uint32_t functionID, uint32_t peerID)42 void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 44 43 { 45 44 if(sPeerMap_.find(peerID)==sPeerMap_.end()) … … 48 47 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 49 48 } 50 FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID); 51 } 52 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1) 53 { 54 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 55 { 56 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 57 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 58 } 59 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1); 60 } 61 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2) 62 { 63 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 64 { 65 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 66 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 67 } 68 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2); 69 } 70 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 71 { 72 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 73 { 74 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 75 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 76 } 77 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3); 78 } 79 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 80 { 81 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 82 { 83 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 84 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 85 } 86 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4); 87 } 88 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 89 { 90 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 91 { 92 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 93 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 94 } 95 FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5); 96 } 97 98 99 // MemberCalls 100 101 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID) 102 { 103 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 104 { 105 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 106 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 107 } 108 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID); 109 } 110 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1) 111 { 112 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 113 { 114 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 115 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 116 } 117 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1); 118 } 119 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2) 120 { 121 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 122 { 123 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 124 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 125 } 126 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2); 127 } 128 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 129 { 130 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 131 { 132 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 133 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 134 } 135 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3); 136 } 137 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 138 { 139 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 140 { 141 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 142 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 143 } 144 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4); 145 } 146 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 147 { 148 if(sPeerMap_.find(peerID)==sPeerMap_.end()) 149 { 150 FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls; 151 FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID); 152 } 153 FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5); 49 FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5); 154 50 } 155 51 -
code/trunk/src/libraries/network/FunctionCallManager.h
r7801 r10624 46 46 { 47 47 public: 48 static void addCallStatic(uint32_t functionID, uint32_t peerID); 49 static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1); 50 static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2); 51 static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3); 52 static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4); 53 static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 54 55 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID); 56 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1); 57 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2); 58 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3); 59 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4); 60 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 48 static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 61 49 62 50 static void sendCalls(orxonox::Host* host); -
code/trunk/src/libraries/network/Host.cc
r9667 r10624 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/object/ObjectList.h" 36 #include "core/command/ConsoleCommand .h"36 #include "core/command/ConsoleCommandIncludes.h" 37 37 #include "NetworkChatListener.h" 38 38 … … 143 143 ////////////////////////////////////////////////////////////////////////// 144 144 145 RegisterAbstractClass(NetworkChatListener).inheritsFrom<Listable>(); 146 145 147 NetworkChatListener::NetworkChatListener() 146 148 { -
code/trunk/src/libraries/network/LANDiscovery.cc
r10622 r10624 32 32 #include <cstring> 33 33 34 #include "util/ScopedSingletonManager.h"35 34 #include "core/CoreIncludes.h" 35 #include "core/singleton/ScopedSingletonIncludes.h" 36 36 37 37 38 38 namespace orxonox 39 39 { 40 ManageScopedSingleton(LANDiscovery, ScopeID::G raphics, true);40 ManageScopedSingleton(LANDiscovery, ScopeID::GRAPHICS, false); 41 41 42 42 LANDiscovery::LANDiscovery() -
code/trunk/src/libraries/network/MasterServer.cc
r10622 r10624 28 28 29 29 #include "MasterServer.h" 30 #include "util/ScopedSingletonManager.h" 31 #include "core/command/ConsoleCommand.h" 30 #include "core/command/ConsoleCommandIncludes.h" 32 31 #include "core/CoreIncludes.h" 33 32 #include "core/CorePrereqs.h" 33 #include "core/singleton/ScopedSingletonIncludes.h" 34 34 #include "util/Output.h" 35 35 -
code/trunk/src/libraries/network/NetworkFunction.cc
r9667 r10624 28 28 29 29 #include "NetworkFunction.h" 30 #include " core/CoreIncludes.h"30 #include "NetworkFunctionManager.h" 31 31 32 32 namespace orxonox 33 33 { 34 std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_; 34 NetworkFunctionBase::NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer) 35 { 36 static uint32_t networkID = 0; 37 this->networkID_ = networkID++; 38 this->name_ = name; 39 this->pointer_ = pointer; 40 } 35 41 36 std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_; 37 std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_; 38 39 // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract 40 RegisterAbstractClass(NetworkFunctionBase).inheritsFrom(Class(Listable)); 41 RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom(Class(NetworkFunctionBase)); 42 RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom(Class(NetworkFunctionBase)); 43 44 NetworkFunctionBase::NetworkFunctionBase(const std::string& name) 45 { 46 RegisterObject(NetworkFunctionBase); 47 48 static uint32_t networkID = 0; 49 this->networkID_ = networkID++; 50 51 this->name_ = name; 52 NetworkFunctionBase::getNameMap()[name] = this; 53 } 54 NetworkFunctionBase::~NetworkFunctionBase() 55 { 56 } 57 58 59 void NetworkFunctionBase::destroyAllNetworkFunctions() 60 { 61 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap(); 62 std::map<std::string, NetworkFunctionBase*>::iterator it; 63 for( it=map.begin(); it!=map.end(); ++it ) 64 delete it->second; 65 } 66 67 68 /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap() 69 { 70 static std::map<std::string, NetworkFunctionBase*> nameMap_; 71 return nameMap_; 72 } 73 74 75 NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p): 76 NetworkFunctionBase(name) 77 { 78 RegisterObject(NetworkFunctionStatic); 79 80 this->functor_ = functor; 81 NetworkFunctionStatic::getFunctorMap()[p] = this; 82 NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this; 83 } 84 85 /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap() 86 { 87 static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_; 88 return functorMap_; 89 } 90 91 /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap() 92 { 93 static std::map<uint32_t, NetworkFunctionStatic*> idMap_; 94 return idMap_; 95 } 96 97 98 NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p): 99 NetworkFunctionBase(name) 100 { 101 RegisterObject(NetworkMemberFunctionBase); 102 103 this->functorMap_[p] = this; 104 this->idMap_[ this->getNetworkID() ] = this; 105 } 106 107 NetworkMemberFunctionBase::~NetworkMemberFunctionBase() 108 { 109 } 110 111 42 void NetworkFunctionBase::setNetworkID(uint32_t id) 43 { 44 this->networkID_ = id; 45 NetworkFunctionManager::getInstance().registerFunction(this); // register with new id 46 } 112 47 } -
code/trunk/src/libraries/network/NetworkFunction.h
r9667 r10624 36 36 #include <map> 37 37 #include <string> 38 #include <boost/preprocessor/cat.hpp> 39 #include <boost/static_assert.hpp> 40 41 #include "core/object/Listable.h" 42 #include "core/class/Identifier.h" 38 43 39 #include "core/command/Functor.h" 44 40 #include "FunctionCallManager.h" … … 60 56 { 61 57 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 62 return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1]; 63 #else //ORXONOX_COMPILER_GCC 64 return pointer[0]<b.pointer[0] ? true : ( pointer[1]<b.pointer[1] ? true : ( pointer[2]<b.pointer[2] ? true : pointer[3]<b.pointer[3] ) ); 65 #endif //ORXONOX_COMPILER_GCC 58 if (pointer[0] != b.pointer[0]) 59 return pointer[0] < b.pointer[0]; 60 else if (pointer[1] != b.pointer[1]) 61 return pointer[1] < b.pointer[1]; 62 else 63 return false; 64 #else 65 if (pointer[0] != b.pointer[0]) 66 return pointer[0] < b.pointer[0]; 67 else if (pointer[1] != b.pointer[1]) 68 return pointer[1] < b.pointer[1]; 69 else if (pointer[2] != b.pointer[2]) 70 return pointer[2] < b.pointer[2]; 71 else if (pointer[3] != b.pointer[3]) 72 return pointer[3] < b.pointer[3]; 73 else 74 return false; 75 #endif 66 76 } 67 77 }; … … 71 81 72 82 73 class _NetworkExport NetworkFunctionBase: virtual public Listable { 74 public: 75 NetworkFunctionBase(const std::string& name); 76 ~NetworkFunctionBase(); 77 78 virtual void setNetworkID(uint32_t id) { this->networkID_ = id; } 79 inline uint32_t getNetworkID() const { return this->networkID_; } 80 inline const std::string& getName() const { return name_; } 81 static inline bool isStatic( uint32_t networkID ) { return isStaticMap_[networkID]; } 82 83 static inline void setNetworkID(const std::string& name, uint32_t id) 84 { 85 std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap(); 86 assert( map.find(name)!=map.end() ); 87 map[name]->setNetworkID(id); 88 } 89 90 static void destroyAllNetworkFunctions(); 91 92 protected: 93 static std::map<uint32_t, bool> isStaticMap_; 94 95 private: 96 static std::map<std::string, NetworkFunctionBase*>& getNameMap(); 97 uint32_t networkID_; 98 std::string name_; 99 100 }; 101 102 103 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 104 public: 105 NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p); 106 107 inline void call(){ (*this->functor_)(); } 108 inline void call(const MultiType& mt1){ (*this->functor_)(mt1); } 109 inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); } 110 inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); } 111 inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); } 112 inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); } 113 114 virtual void setNetworkID( uint32_t id ) 115 { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; } 116 static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id) 117 { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; } 118 static NetworkFunctionStatic* getFunction( uint32_t id ) 119 { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; } 120 static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p ) 121 { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; } 122 123 private: 124 static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap(); 125 static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap(); 126 FunctorStaticPtr functor_; 127 128 }; 129 130 131 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase { 132 public: 133 NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p); 134 ~NetworkMemberFunctionBase(); 135 136 virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; } 137 static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; } 138 static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; } 139 static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; } 140 141 // 83 class _NetworkExport NetworkFunctionBase { 84 public: 85 NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer); 86 virtual ~NetworkFunctionBase() {} 87 88 void setNetworkID(uint32_t id); 89 inline uint32_t getNetworkID() const { return this->networkID_; } 90 inline const std::string& getName() const { return this->name_; } 91 inline const NetworkFunctionPointer& getPointer() const { return this->pointer_; } 92 142 93 virtual bool call(uint32_t objectID)=0; 143 94 virtual bool call(uint32_t objectID, const MultiType& mt1)=0; … … 148 99 149 100 private: 150 static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_; 151 static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_; 101 uint32_t networkID_; 102 std::string name_; 103 NetworkFunctionPointer pointer_; 104 105 }; 106 107 108 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 109 public: 110 NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p) 111 : NetworkFunctionBase(name, p) 112 , functor_(functor) 113 { } 114 115 // ignore the objectID because its a static function 116 virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; } 117 virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; } 118 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; } 119 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; } 120 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; } 121 virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; } 122 123 private: 124 FunctorStaticPtr functor_; 125 126 }; 127 128 129 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase { 130 public: 131 NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p) 132 : NetworkFunctionBase(name, p) 133 { } 152 134 }; 153 135 … … 155 137 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase { 156 138 public: 157 NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p); 139 NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p) 140 : NetworkMemberFunctionBase(name, p) 141 , functor_(functor) 142 { } 158 143 159 144 inline bool call(uint32_t objectID) … … 222 207 }; 223 208 224 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):225 NetworkMemberFunctionBase(name, p), functor_(functor)226 {227 209 } 228 210 229 template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)230 {231 if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)232 memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));233 T p2 = ptr;234 memcpy( &destptr, &p2, sizeof(T) );235 // for(unsigned int i=0; i<(sizeof(T)-1/4)+1; i++)236 // *((uint32_t*)destptr+i) = p2>>32*i;237 }238 239 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )240 {241 BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above242 NetworkFunctionPointer destptr;243 copyPtr( ptr, destptr );244 new NetworkFunctionStatic( createFunctor(ptr), name, destptr );245 return 0;246 }247 248 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )249 {250 BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above251 NetworkFunctionPointer destptr;252 copyPtr( ptr, destptr );253 new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );254 return 0;255 }256 257 #define registerStaticNetworkFunction( functionPointer ) \258 static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );259 #define registerMemberNetworkFunction( class, function ) \260 static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);261 // call it with functionPointer, clientID, args262 #define callStaticNetworkFunction( functionPointer, ...) \263 { \264 NetworkFunctionPointer p1; \265 copyPtr( functionPointer, p1 ); \266 FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \267 }268 // call it with class, function, objectID, clientID, args269 #define callMemberNetworkFunction( class, function, objectID, ...) \270 { \271 NetworkFunctionPointer p1; \272 copyPtr( &class::function, p1 ); \273 FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \274 }275 276 277 }278 279 211 #endif /* _NetworkFunction_H__ */ -
code/trunk/src/libraries/network/NetworkPrereqs.h
r8858 r10624 97 97 } 98 98 } 99 100 namespace StaticInitialization 101 { 102 typedef int Type; 103 static const Type NETWORK_FUNCTION = 6; 104 } 99 105 } 100 106 -
code/trunk/src/libraries/network/WANDiscoverable.cc
r10622 r10624 39 39 namespace orxonox 40 40 { 41 RegisterAbstractClass(WANDiscoverable).inheritsFrom<Configurable>(); 41 42 42 43 WANDiscoverable::WANDiscoverable(): bActive_(false) -
code/trunk/src/libraries/network/WANDiscovery.cc
r10622 r10624 37 37 namespace orxonox 38 38 { 39 RegisterAbstractClass(WANDiscovery).inheritsFrom<Configurable>(); 40 39 41 WANDiscovery::WANDiscovery() 40 42 { -
code/trunk/src/libraries/network/packet/FunctionCalls.cc
r8351 r10624 82 82 } 83 83 84 void FunctionCalls::addCall Static( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType*mt5)84 void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 85 85 { 86 86 assert(!isDataENetAllocated()); 87 87 88 88 this->functionCalls_.push(orxonox::FunctionCall()); 89 this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 ); 90 this->currentSize_ += this->functionCalls_.back().getSize(); 91 } 92 93 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5) 94 { 95 assert(!isDataENetAllocated()); 96 97 this->functionCalls_.push(orxonox::FunctionCall()); 98 this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 ); 89 this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 ); 99 90 this->currentSize_ += this->functionCalls_.back().getSize(); 100 91 } -
code/trunk/src/libraries/network/packet/FunctionCalls.h
r7801 r10624 56 56 virtual bool process(orxonox::Host* host); 57 57 58 void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 59 void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 58 void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 60 59 virtual bool send(orxonox::Host* host); 61 60 private: -
code/trunk/src/libraries/network/packet/FunctionIDs.cc
r9667 r10624 37 37 #include "core/object/ObjectList.h" 38 38 #include "network/NetworkFunction.h" 39 #include "network/NetworkFunctionManager.h" 39 40 40 41 namespace orxonox { … … 55 56 56 57 //calculate total needed size (for all strings and integers) 57 ObjectList<NetworkFunctionBase>::iterator it; 58 for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it) 58 const std::set<NetworkFunctionBase*>& set = NetworkFunctionManager::getInstance().getAllFunctions(); 59 std::set<NetworkFunctionBase*>::const_iterator it; 60 for (it = set.begin(); it != set.end(); ++it) 59 61 { 60 const std::string& functionname = it->getName();61 networkID = it->getNetworkID();62 const std::string& functionname = (*it)->getName(); 63 networkID = (*it)->getNetworkID(); 62 64 // now push the network id and the classname to the stack 63 65 tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) ); … … 126 128 unsigned char *functionname; 127 129 130 //clear the map of network ids 131 NetworkFunctionManager::getInstance().clearNetworkIDs(); 132 128 133 orxout(verbose, context::packets) << "=== processing functionids: " << endl; 129 134 std::pair<uint32_t, std::string> tempPair; … … 138 143 functionname = temp+2*sizeof(uint32_t); 139 144 orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl; 140 NetworkFunction Base::setNetworkID((const char*)functionname,networkID);145 NetworkFunctionManager::getInstance().getFunctionByName((const char*)functionname)->setNetworkID(networkID); 141 146 temp += 2*sizeof(uint32_t) + stringsize; 142 147 } -
code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
r7314 r10624 2 2 NetworkCallbackManager.cc 3 3 Synchronisable.cc 4 SynchronisableVariable.cc5 4 ) 6 5 -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r9667 r10624 78 78 } 79 79 80 // These functions implement loading / saving / etc. for S martPtr<T>80 // These functions implement loading / saving / etc. for StrongPtr<T> 81 81 82 82 /** @brief returns the size of the objectID needed to synchronise the pointer */ 83 template <class T> inline uint32_t returnSize( const S martPtr<T>& )83 template <class T> inline uint32_t returnSize( const StrongPtr<T>& ) 84 84 { 85 85 return sizeof(uint32_t); … … 87 87 88 88 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 89 template <class T> inline void loadAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )89 template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 90 90 { 91 91 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 92 *const_cast<typename Loki::TypeTraits<S martPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));92 *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 93 93 mem += returnSize( variable ); 94 94 } 95 95 96 96 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 97 template <class T> inline void saveAndIncrease( const S martPtr<T>& variable, uint8_t*& mem )97 template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem ) 98 98 { 99 99 if ( variable.get() ) … … 105 105 106 106 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 107 template <class T> inline bool checkEquality( const S martPtr<T>& variable, uint8_t* mem )107 template <class T> inline bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem ) 108 108 { 109 109 if ( variable.get() ) … … 125 125 { 126 126 // *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) )); 127 *const_cast<typename Loki::TypeTraits< SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));127 *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem))); 128 128 mem += returnSize( variable ); 129 129 } -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r9667 r10624 45 45 uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client 46 46 47 RegisterAbstractClass(Synchronisable).inheritsFrom (Class(OrxonoxInterface));47 RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>(); 48 48 49 49 /** … … 151 151 for(int i = 0; i<160; i++) 152 152 orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl; 153 orxout(user_error, context::network) << "Assertion failed: id"<< endl;153 orxout(user_error, context::network) << "Assertion failed: Could not find Identifier for ClassID " << header.getClassID() << endl; 154 154 orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl; 155 155 abort(); … … 182 182 no->setClassID(header.getClassID()); 183 183 assert(no->contextID_ == header.getContextID()); 184 if( context )185 {186 BaseObject* boContext = orxonox_cast<BaseObject*>(context);187 if (boContext)188 bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)189 }190 184 //assert(no->classID_ == header.getClassID()); 191 185 orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl; -
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
r8858 r10624 65 65 virtual uint8_t getMode()=0; 66 66 virtual ~SynchronisableVariableBase() {} 67 protected:68 static uint8_t state_;69 67 }; 70 68 … … 108 106 variable_( variable ), mode_( syncDirection ), callback_( cb ) 109 107 { 110 if ( state_ == 0x0 )111 {112 state_ = GameMode::isMaster() ? 0x1 : 0x2; // set the appropriate mode here113 }114 108 } 115 109 -
code/trunk/src/libraries/tools/ParticleInterface.cc
r9667 r10624 49 49 { 50 50 unsigned int ParticleInterface::counter_s = 0; 51 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 51 52 RegisterAbstractClass(ParticleInterface).inheritsFrom<TimeFactorListener>(); 52 53 53 54 ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel) -
code/trunk/src/libraries/tools/ParticleInterface.h
r5781 r10624 34 34 #include "util/OgreForwardRefs.h" 35 35 #include "tools/interfaces/TimeFactorListener.h" 36 37 #define getAllEmitters() \38 storeThisAsCurrentParticleInterface(); \39 for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \40 ParticleInterface::getCurrentParticleInterface()->getEmitter(i)41 36 42 37 namespace orxonox … … 80 75 void setDetailLevel(unsigned int level); 81 76 82 inline void storeThisAsCurrentParticleInterface()83 { ParticleInterface::currentParticleInterface_s = this; }84 inline static ParticleInterface* getCurrentParticleInterface()85 { return ParticleInterface::currentParticleInterface_s; }86 87 77 protected: 88 78 virtual void changedTimeFactor(float factor_new, float factor_old); … … 103 93 unsigned int globalDetailLevel_; //!< Global maximum detail level of particle effects (0: off, 1: low, 2: normal, 3: high) 104 94 105 static ParticleInterface* currentParticleInterface_s;106 95 static unsigned int counter_s; 107 96 }; -
code/trunk/src/libraries/tools/ResourceLocation.cc
r9667 r10624 35 35 #include "util/Exception.h" 36 36 #include "core/CoreIncludes.h" 37 #include "core/PathConfig.h" 37 #include "core/ApplicationPaths.h" 38 #include "core/ConfigurablePaths.h" 38 39 #include "core/XMLFile.h" 39 40 #include "core/XMLPort.h" … … 74 75 namespace bf = boost::filesystem; 75 76 bf::path path; 76 if (bf::exists( PathConfig::getDataPath() / this->getPath()))77 path = PathConfig::getDataPath() / this->getPath();78 else if ( PathConfig::buildDirectoryRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))79 path = PathConfig::getExternalDataPath() / this->getPath();77 if (bf::exists(ConfigurablePaths::getDataPath() / this->getPath())) 78 path = ConfigurablePaths::getDataPath() / this->getPath(); 79 else if (ApplicationPaths::buildDirectoryRun() && bf::exists(ConfigurablePaths::getExternalDataPath() / this->getPath())) 80 path = ConfigurablePaths::getExternalDataPath() / this->getPath(); 80 81 else 81 82 { -
code/trunk/src/libraries/tools/Timer.cc
r9667 r10624 40 40 #include "util/Clock.h" 41 41 #include "core/CoreIncludes.h" 42 #include "core/command/ConsoleCommand .h"42 #include "core/command/ConsoleCommandIncludes.h" 43 43 #include "core/command/CommandExecutor.h" 44 44 #include "core/command/Executor.h" … … 247 247 // RealTimer // 248 248 /////////////// 249 250 RegisterClassNoArgs(RealTimer); 251 249 252 /// @copydoc Timer::Timer 250 253 RealTimer::RealTimer() -
code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
r9667 r10624 46 46 float TimeFactorListener::timefactor_s = 1.0f; 47 47 48 RegisterAbstractClass(TimeFactorListener).inheritsFrom (Class(Listable));48 RegisterAbstractClass(TimeFactorListener).inheritsFrom<Listable>(); 49 49 50 50 TimeFactorListener::TimeFactorListener() … … 67 67 // Tickable 68 68 //---------------------------- 69 RegisterAbstractClass(Tickable).inheritsFrom (Class(OrxonoxInterface));69 RegisterAbstractClass(Tickable).inheritsFrom<OrxonoxInterface>(); 70 70 71 71 /** -
code/trunk/src/libraries/util/CMakeLists.txt
r9765 r10624 26 26 CRC32.cc 27 27 ExprParser.cc 28 Scope.cc29 ScopedSingletonManager.cc30 28 SharedPtr.cc 31 29 Sleep.cc -
code/trunk/src/libraries/util/SharedPtr.h
r8351 r10624 138 138 OtherClass* other3 = new OtherClass(object); // " 139 139 140 } // The S martPtr "object" is destroyed at the end of the scope,140 } // The SharedPtr "object" is destroyed at the end of the scope, 141 141 // but the three instances of OtherClass keep the object alive 142 142 // until they are all destroyed. -
code/trunk/src/libraries/util/Singleton.h
r8858 r10624 52 52 public: 53 53 TestSingleton(); // public constructor because we may want to manage this singleton 54 // with an orxonox::ScopedSingleton Manager (see below)54 // with an orxonox::ScopedSingletonWrapper 55 55 virtual ~TestSingleton(); // public destructor 56 56 … … 68 68 TestSingleton* TestSingleton::singletonPtr_s = NULL; 69 69 @endcode 70 71 Usually a singleton gets created automatically when it is first used, but it will never72 be destroyed (unless the singleton explicitly deletes itself). To allow controlled73 construction and destruction, the singleton can be put within a virtual scope. This is74 done by registering the singleton class with orxonox::ScopedSingletonManager. To75 do so, the ManageScopedSingleton() macro has to be called:76 77 @code78 ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file79 @endcode80 81 @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,82 because that's already done by the macro.83 84 Now the singleton TestSingleton gets automatically created if the scope Graphics becomes85 active and also gets destroyed if the scope is deactivated.86 87 Note that not all singletons must register with a scope, but it's recommended.88 70 89 71 If a class inherits from orxonox::Singleton, it also inherits its functions. The most important … … 112 94 #include "UtilPrereqs.h" 113 95 114 #include <cassert>115 96 #include <cstring> 97 #include <typeinfo> 98 99 #include "OrxAssert.h" 116 100 117 101 namespace orxonox … … 134 118 static T& getInstance() 135 119 { 136 assert(T::singletonPtr_s != NULL);120 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name()); 137 121 return *T::singletonPtr_s; 138 122 } … … 144 128 } 145 129 146 //! Update method called by ClassSingletonManager (if used)147 void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }148 //! Empty update method for the static polymorphism149 void preUpdate(const Clock& time) { }150 //! Update method called by ClassSingletonManager (if used)151 void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }152 //! Empty update method for the static polymorphism153 void postUpdate(const Clock& time) { }154 155 130 protected: 156 131 //! Constructor sets the singleton instance pointer 157 132 Singleton() 158 133 { 159 assert(T::singletonPtr_s == NULL);134 OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name()); 160 135 T::singletonPtr_s = static_cast<T*>(this); 161 136 } … … 164 139 virtual ~Singleton() 165 140 { 166 assert(T::singletonPtr_s != NULL);141 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name()); 167 142 T::singletonPtr_s = NULL; 168 143 } -
code/trunk/src/libraries/util/UtilPrereqs.h
r9550 r10624 62 62 63 63 //----------------------------------------------------------------------- 64 // Enums65 //-----------------------------------------------------------------------66 67 namespace orxonox68 {69 namespace ScopeID70 {71 //!A list of available scopes for the Scope template.72 enum Value73 {74 Root,75 Graphics76 };77 }78 }79 80 //-----------------------------------------------------------------------81 64 // Forward declarations 82 65 //----------------------------------------------------------------------- … … 96 79 class OutputManager; 97 80 class OutputStream; 98 template <ScopeID::Value>99 class Scope;100 template <class, ScopeID::Value>101 class ScopedSingleton;102 81 class ScopeListener; 103 82 template <class T> -
code/trunk/src/libraries/util/output/OutputDefinitions.h
r10317 r10624 170 170 { 171 171 REGISTER_OUTPUT_SUBCONTEXT(misc, executor); 172 REGISTER_OUTPUT_SUBCONTEXT(misc, factory);173 172 REGISTER_OUTPUT_SUBCONTEXT(misc, gui); 174 173 REGISTER_OUTPUT_SUBCONTEXT(misc, overlays); -
code/trunk/src/modules/designtools/ScreenshotManager.cc
r9667 r10624 45 45 #include "core/config/ConfigValueIncludes.h" 46 46 #include "core/GraphicsManager.h" 47 #include "core/ PathConfig.h"47 #include "core/ConfigurablePaths.h" 48 48 #include "core/Resource.h" 49 #include "core/command/ConsoleCommand .h"50 #include " util/ScopedSingletonManager.h"49 #include "core/command/ConsoleCommandIncludes.h" 50 #include "core/singleton/ScopedSingletonIncludes.h" 51 51 #include "util/StringUtils.h" 52 52 … … 61 61 SetConsoleCommand("printScreenHD", &ScreenshotManager::makeScreenshot_s); 62 62 63 ManageScopedSingleton(ScreenshotManager, ScopeID::Graphics, false); 63 ManageScopedSingleton(ScreenshotManager, ScopeID::GRAPHICS, false); 64 65 RegisterAbstractClass(ScreenshotManager).inheritsFrom<Configurable>(); 64 66 65 67 /** … … 152 154 { 153 155 // Save it. 154 finalImage->save( PathConfig::getInstance().getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);156 finalImage->save(ConfigurablePaths::getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_); 155 157 delete finalImage; 156 158 orxout(user_info) << "Finished taking " << this->gridSize_*this->windowWidth_ << "x" << this->gridSize_*this->windowHeight_ << " pixel HD screenshot. Storing in log/." << endl; -
code/trunk/src/modules/designtools/SkyboxGenerator.cc
r9667 r10624 38 38 #include <OgreCamera.h> 39 39 40 #include "util/ScopedSingletonManager.h"41 40 #include "core/CoreIncludes.h" 42 41 #include "core/config/ConfigValueIncludes.h" 43 42 #include "core/GraphicsManager.h" 44 #include "core/ PathConfig.h"43 #include "core/ConfigurablePaths.h" 45 44 #include "core/Resource.h" 46 #include "core/command/ConsoleCommand .h"45 #include "core/command/ConsoleCommandIncludes.h" 47 46 #include "core/command/CommandExecutor.h" 47 #include "core/singleton/ScopedSingletonIncludes.h" 48 48 49 49 #include "controllers/HumanController.h" … … 60 60 SetConsoleCommand("SkyboxGenerator", "createSkybox", &SkyboxGenerator::createSkybox).addShortcut(); 61 61 62 ManageScopedSingleton(SkyboxGenerator, ScopeID::Graphics, false); 62 ManageScopedSingleton(SkyboxGenerator, ScopeID::GRAPHICS, false); 63 64 RegisterAbstractClass(SkyboxGenerator).inheritsFrom<Configurable>().inheritsFrom<Tickable>(); 63 65 64 66 /** … … 173 175 this->setupRenderWindow(renderWindow); 174 176 // Add the log path to the standard resource group. 175 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( PathConfig::getInstance().getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());177 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup()); 176 178 177 179 orxout(internal_status) << "Setting up SkyboxGenerator..." << endl; … … 208 210 this->restoreRenderWindow(renderWindow); 209 211 // Remove the log path from the standard resource group. 210 Ogre::ResourceGroupManager::getSingleton().removeResourceLocation( PathConfig::getInstance().getLogPathString(), Resource::getDefaultResourceGroup());212 Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(ConfigurablePaths::getLogPathString(), Resource::getDefaultResourceGroup()); 211 213 212 214 // Reset the flow parameters for the next skybox generation. … … 306 308 void SkyboxGenerator::saveImage(Ogre::Image* image, const std::string& name) const 307 309 { 308 image->save( PathConfig::getInstance().getLogPathString()+name);310 image->save(ConfigurablePaths::getLogPathString()+name); 309 311 delete image; 310 312 // Loading the resizing, then saving again. This seems stupid, but resizing doesn't seem to work otherwise. … … 313 315 image->load(name, Resource::getDefaultResourceGroup()); 314 316 image->resize(this->size_, this->size_); 315 image->save( PathConfig::getInstance().getLogPathString()+name);317 image->save(ConfigurablePaths::getLogPathString()+name); 316 318 delete image; 317 319 ScreenshotManager::getInstance().cleanup(); // Free memory in ScreenshotManager. -
code/trunk/src/modules/docking/Dock.cc
r9945 r10624 37 37 #include "core/LuaState.h" 38 38 #include "core/GUIManager.h" 39 #include "core/command/ConsoleCommand .h"40 #include "network/NetworkFunction .h"39 #include "core/command/ConsoleCommandIncludes.h" 40 #include "network/NetworkFunctionIncludes.h" 41 41 42 42 #include "infos/HumanPlayer.h" … … 184 184 } 185 185 else 186 callStaticNetworkFunction( Dock::showDockingDialog, player->getClientID());186 callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID()); 187 187 188 188 } … … 201 201 } 202 202 else 203 callStaticNetworkFunction( Dock::showDockingDialog, player->getClientID());203 callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID()); 204 204 205 205 } -
code/trunk/src/modules/docking/DockingAnimation.cc
r9667 r10624 39 39 namespace orxonox 40 40 { 41 RegisterAbstractClass(DockingAnimation).inheritsFrom (Class(BaseObject));41 RegisterAbstractClass(DockingAnimation).inheritsFrom<BaseObject>(); 42 42 43 43 DockingAnimation::DockingAnimation(Context* context) : BaseObject(context) -
code/trunk/src/modules/docking/DockingEffect.cc
r9667 r10624 37 37 namespace orxonox 38 38 { 39 RegisterAbstractClass(DockingEffect).inheritsFrom (Class(BaseObject));39 RegisterAbstractClass(DockingEffect).inheritsFrom<BaseObject>(); 40 40 41 41 DockingEffect::DockingEffect(Context* context) : BaseObject(context) -
code/trunk/src/modules/dodgerace/CMakeLists.txt
r10284 r10624 8 8 9 9 ORXONOX_ADD_LIBRARY(dodgerace 10 MODULE10 PLUGIN 11 11 FIND_HEADER_FILES 12 12 LINK_LIBRARIES -
code/trunk/src/modules/dodgerace/DodgeRace.cc
r10236 r10624 35 35 #include "DodgeRaceShip.h" // Necessary for getPlayer function. Do NOT include this in Header! 36 36 #include "DodgeRaceCube.h" 37 #include "core/CoreIncludes.h" 37 38 38 39 namespace orxonox … … 43 44 { 44 45 RegisterObject(DodgeRace); 45 init(); 46 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 47 this->center_ = 0; 48 49 this->setHUDTemplate("DodgeRaceHUD"); 50 } 51 52 void DodgeRace::init() 53 { 46 54 47 bEndGame = false; 55 48 lives = 1; … … 65 58 //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this))); 66 59 comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this))); 60 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 61 this->center_ = 0; 62 63 this->setHUDTemplate("DodgeRaceHUD"); 67 64 } 68 65 … … 74 71 for (int i = 0; i < 7; i++) 75 72 { 76 WeakPtr<BigExplosion>chunk = new BigExplosion(this->center_->getContext());73 BigExplosion* chunk = new BigExplosion(this->center_->getContext()); 77 74 chunk->setPosition(Vector3(600, 0, 100.f * i - 300)); 78 75 chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() … … 90 87 if (getPlayer() != NULL) 91 88 { 92 //WeakPtr<DodgeRaceShip> ship = getPlayer();93 94 89 currentPosition = getPlayer()->getWorldPosition().x; 95 90 counter = counter + (currentPosition - lastPosition); … … 112 107 for(int i = 0; i<6; i++) 113 108 { 114 WeakPtr<DodgeRaceCube>cube = new DodgeRaceCube(this->center_->getContext());109 DodgeRaceCube* cube = new DodgeRaceCube(this->center_->getContext()); 115 110 cubeList.push_back(cube); 116 111 switch(pattern) … … 137 132 } 138 133 139 WeakPtr<DodgeRaceShip>DodgeRace::getPlayer()134 DodgeRaceShip* DodgeRace::getPlayer() 140 135 { 141 136 if (player == NULL) … … 168 163 { 169 164 orxout() << "start" << endl; 170 init();171 165 for(unsigned int i=0; i< cubeList.size();i++) 172 166 { … … 199 193 /* 200 194 orxout() << "prespawn" << endl; 201 init();202 195 for(int i=0; i< cubeList.size();i++) 203 196 { -
code/trunk/src/modules/dodgerace/DodgeRace.h
r10236 r10624 44 44 45 45 46 #include "core/CoreIncludes.h"47 46 #include "core/EventIncludes.h" 48 47 #include "core/command/Executor.h" … … 69 68 public: 70 69 DodgeRace(Context* context); 71 72 void init();73 70 74 71 virtual void start(); … … 106 103 Timer endGameTimer; 107 104 108 WeakPtr<DodgeRaceShip>getPlayer();105 DodgeRaceShip* getPlayer(); 109 106 WeakPtr<DodgeRaceShip> player; 110 107 std::vector<DodgeRaceCube*> cubeList; -
code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc
r10232 r10624 54 54 } 55 55 56 void DodgeRaceCenterPoint::changedGametype()57 {58 SUPER(DodgeRaceCenterPoint, changedGametype);59 60 // Check, whether it's still DodgeRace.61 this->checkGametype();62 }63 64 56 void DodgeRaceCenterPoint::checkGametype() 65 57 { 66 58 if (this->getGametype() != NULL && this->getGametype()->isA(Class(DodgeRace))) 67 59 { 68 DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype() .get());60 DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype()); 69 61 DodgeRaceGametype->setCenterpoint(this); 70 62 } -
code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h
r10234 r10624 52 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 53 54 virtual void changedGametype(); //!< Is called when the gametype has changed.55 54 private: 56 55 void checkGametype(); -
code/trunk/src/modules/dodgerace/DodgeRaceCube.cc
r10236 r10624 33 33 #include "DodgeRaceCube.h" 34 34 #include "DodgeRace.h" 35 #include "core/CoreIncludes.h" 35 36 36 37 namespace orxonox -
code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc
r10236 r10624 82 82 if (this->getOwner() && this->getOwner()->getGametype()) 83 83 { 84 this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype() .get());84 this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype()); 85 85 } 86 86 else -
code/trunk/src/modules/dodgerace/DodgeRaceShip.cc
r10236 r10624 33 33 34 34 #include "DodgeRaceShip.h" 35 #include "core/CoreIncludes.h" 35 36 36 37 namespace orxonox … … 89 90 90 91 // Camera 91 WeakPtr<Camera>camera = this->getCamera();92 Camera* camera = this->getCamera(); 92 93 if (camera != NULL) 93 94 { … … 149 150 } 150 151 151 WeakPtr<DodgeRace>DodgeRaceShip::getGame()152 DodgeRace* DodgeRaceShip::getGame() 152 153 { 153 154 if (game == NULL) -
code/trunk/src/modules/dodgerace/DodgeRaceShip.h
r10284 r10624 38 38 #include "dodgerace/DodgeRacePrereqs.h" 39 39 40 #include "core/CoreIncludes.h"41 40 #include "core/XMLPort.h" 42 41 #include "worldentities/pawns/SpaceShip.h" … … 79 78 private: 80 79 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 81 WeakPtr<DodgeRace>getGame();80 DodgeRace* getGame(); 82 81 WeakPtr<DodgeRace> game; 83 82 WeakPtr<WorldEntity> lastEntity; -
code/trunk/src/modules/gametypes/CMakeLists.txt
r9526 r10624 10 10 11 11 ORXONOX_ADD_LIBRARY(gametypes 12 MODULE12 PLUGIN 13 13 FIND_HEADER_FILES 14 14 TOLUA_FILES -
code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc
r9667 r10624 61 61 SUPER(OldRaceCheckPoint, tick, dt); 62 62 63 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype() .get());63 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype()); 64 64 assert(gametype); 65 65 if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) … … 82 82 DistanceTrigger::triggered(bIsTriggered); 83 83 84 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype() .get());84 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype()); 85 85 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered) 86 86 { … … 107 107 if (this->bTimeLimit_ != 0) 108 108 { 109 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype() .get());109 OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype()); 110 110 if (gametype) 111 111 { -
code/trunk/src/modules/gametypes/SpaceRaceManager.cc
r9667 r10624 46 46 { 47 47 RegisterObject(SpaceRaceManager); 48 this->race_ = orxonox_cast<SpaceRace*>(this->getGametype() .get());48 this->race_ = orxonox_cast<SpaceRace*>(this->getGametype()); 49 49 assert(race_); 50 50 //amountOfPlayers=(race_->getPlayers()).size(); … … 139 139 void SpaceRaceManager::checkpointReached(RaceCheckPoint* newCheckpoint, PlayerInfo* player) 140 140 { 141 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype() .get());141 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype()); 142 142 assert(gametype); 143 143 if (!gametype) -
code/trunk/src/modules/invader/CMakeLists.txt
r9958 r10624 13 13 14 14 ORXONOX_ADD_LIBRARY(invader 15 MODULE15 PLUGIN 16 16 FIND_HEADER_FILES 17 17 LINK_LIBRARIES -
code/trunk/src/modules/invader/Invader.cc
r9961 r10624 62 62 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 63 63 this->center_ = 0; 64 init();65 this->setHUDTemplate("InvaderHUD");66 }67 68 void Invader::init()69 {70 64 bEndGame = false; 71 65 lives = 3; … … 78 72 enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this))); 79 73 comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this))); 74 this->setHUDTemplate("InvaderHUD"); 80 75 } 81 76 … … 87 82 for (int i = 0; i < 7; i++) 88 83 { 89 WeakPtr<BigExplosion>chunk = new BigExplosion(this->center_->getContext());84 BigExplosion* chunk = new BigExplosion(this->center_->getContext()); 90 85 chunk->setPosition(Vector3(600, 0, 100.f * i - 300)); 91 86 chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() … … 99 94 } 100 95 101 WeakPtr<InvaderShip>Invader::getPlayer()96 InvaderShip* Invader::getPlayer() 102 97 { 103 98 if (player == NULL) … … 116 111 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++) 117 112 { 118 WeakPtr<InvaderEnemy>newPawn;113 InvaderEnemy* newPawn; 119 114 if (rand() % 42/(1 + level*level) == 0) 120 115 { … … 155 150 void Invader::start() 156 151 { 157 init();158 152 // Set variable to temporarily force the player to spawn. 159 153 this->bForceSpawn_ = true; -
code/trunk/src/modules/invader/Invader.h
r9943 r10624 71 71 // checks if multiplier should be reset. 72 72 void comboControll(); 73 void init();74 73 int lives; 75 74 int multiplier; … … 78 77 private: 79 78 void toggleShowLevel(){bShowLevel = !bShowLevel;} 80 WeakPtr<InvaderShip>getPlayer();79 InvaderShip* getPlayer(); 81 80 WeakPtr<InvaderCenterPoint> center_; 82 81 WeakPtr<InvaderShip> player; -
code/trunk/src/modules/invader/InvaderCenterPoint.cc
r9943 r10624 54 54 } 55 55 56 void InvaderCenterPoint::changedGametype()57 {58 SUPER(InvaderCenterPoint, changedGametype);59 60 // Check, whether it's still Invader.61 this->checkGametype();62 }63 64 56 void InvaderCenterPoint::checkGametype() 65 57 { 66 58 if (this->getGametype() != NULL && this->getGametype()->isA(Class(Invader))) 67 59 { 68 Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype() .get());60 Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype()); 69 61 InvaderGametype->setCenterpoint(this); 70 62 } -
code/trunk/src/modules/invader/InvaderCenterPoint.h
r9943 r10624 49 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 50 50 51 virtual void changedGametype(); //!< Is called when the gametype has changed.52 51 private: 53 52 void checkGametype(); -
code/trunk/src/modules/invader/InvaderEnemy.cc
r9961 r10624 69 69 } 70 70 71 WeakPtr<Invader>InvaderEnemy::getGame()71 Invader* InvaderEnemy::getGame() 72 72 { 73 73 if (game == NULL) -
code/trunk/src/modules/invader/InvaderEnemy.h
r9943 r10624 49 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 50 50 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator); 51 virtual void setPlayer( WeakPtr<InvaderShip>player){this->player = player;}51 virtual void setPlayer(InvaderShip* player){this->player = player;} 52 52 53 53 int level; 54 54 protected: 55 WeakPtr<Invader>getGame();55 Invader* getGame(); 56 56 WeakPtr<Invader> game; 57 57 WeakPtr<InvaderShip> player; -
code/trunk/src/modules/invader/InvaderHUDinfo.cc
r9961 r10624 128 128 if (this->getOwner() && this->getOwner()->getGametype()) 129 129 { 130 this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype() .get());130 this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype()); 131 131 } 132 132 else -
code/trunk/src/modules/invader/InvaderShip.cc
r9943 r10624 91 91 92 92 // Camera 93 WeakPtr<Camera>camera = this->getCamera();93 Camera* camera = this->getCamera(); 94 94 if (camera != NULL) 95 95 { … … 142 142 { 143 143 // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint; 144 WeakPtr<InvaderEnemy>enemy = orxonox_cast<InvaderEnemy*>(otherObject);145 WeakPtr<Projectile>shot = orxonox_cast<Projectile*>(otherObject);144 InvaderEnemy* enemy = orxonox_cast<InvaderEnemy*>(otherObject); 145 Projectile* shot = orxonox_cast<Projectile*>(otherObject); 146 146 // ensure that this gets only called once per enemy. 147 147 if (enemy != NULL && lastEnemy != enemy) … … 171 171 } 172 172 173 WeakPtr<Invader>InvaderShip::getGame()173 Invader* InvaderShip::getGame() 174 174 { 175 175 if (game == NULL) -
code/trunk/src/modules/invader/InvaderShip.h
r9943 r10624 70 70 virtual void death(); 71 71 private: 72 WeakPtr<Invader>getGame();72 Invader* getGame(); 73 73 WeakPtr<Invader> game; 74 74 Camera* camera; -
code/trunk/src/modules/invader/InvaderWeapon.cc
r10216 r10624 68 68 // Create the projectile.projectile 69 69 projectile = new Projectile(this->getContext()); 70 WeakPtr<Model>model = new Model(projectile->getContext());70 Model* model = new Model(projectile->getContext()); 71 71 model->setMeshSource(mesh_); 72 72 model->setCastShadows(false); -
code/trunk/src/modules/jump/CMakeLists.txt
r10284 r10624 24 24 25 25 ORXONOX_ADD_LIBRARY(jump 26 MODULE26 PLUGIN 27 27 FIND_HEADER_FILES 28 28 LINK_LIBRARIES -
code/trunk/src/modules/jump/JumpCenterpoint.cc
r10262 r10624 80 80 } 81 81 82 void JumpCenterpoint::changedGametype()83 {84 SUPER(JumpCenterpoint, changedGametype);85 86 checkGametype();87 }88 89 82 void JumpCenterpoint::checkGametype() 90 83 { 91 84 if (getGametype() != NULL && this->getGametype()->isA(Class(Jump))) 92 85 { 93 Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype() .get());86 Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype()); 94 87 jumpGametype->setCenterpoint(this); 95 88 } -
code/trunk/src/modules/jump/JumpCenterpoint.h
r10262 r10624 114 114 virtual ~JumpCenterpoint() {} 115 115 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML. 116 virtual void changedGametype();117 116 void setPlatformStaticTemplate(const std::string& balltemplate) 118 117 { this->platformStaticTemplate_ = balltemplate; } -
code/trunk/src/modules/jump/JumpEnemy.cc
r10262 r10624 151 151 An array (of size 2) of weak pointers, to be set as the new bats. 152 152 */ 153 void JumpEnemy::setFigure( WeakPtr<JumpFigure>newFigure)153 void JumpEnemy::setFigure(JumpFigure* newFigure) 154 154 { 155 155 figure_ = newFigure; -
code/trunk/src/modules/jump/JumpEnemy.h
r10262 r10624 68 68 69 69 virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed); 70 void setFigure( WeakPtr<JumpFigure> bats);70 void setFigure(JumpFigure* newFigure); 71 71 virtual void touchFigure(); 72 72 bool dead_; -
code/trunk/src/modules/jump/JumpItem.cc
r10262 r10624 109 109 } 110 110 111 void JumpItem::setFigure( WeakPtr<JumpFigure>newFigure)111 void JumpItem::setFigure(JumpFigure* newFigure) 112 112 { 113 113 figure_ = newFigure; -
code/trunk/src/modules/jump/JumpItem.h
r10262 r10624 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 54 virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed); 55 virtual void setFigure( WeakPtr<JumpFigure> bats);55 virtual void setFigure(JumpFigure* newFigure); 56 56 virtual void touchFigure(); 57 57 -
code/trunk/src/modules/jump/JumpPlatform.cc
r10262 r10624 125 125 } 126 126 127 void JumpPlatform::setFigure( WeakPtr<JumpFigure>newFigure)127 void JumpPlatform::setFigure(JumpFigure* newFigure) 128 128 { 129 129 figure_ = newFigure; -
code/trunk/src/modules/jump/JumpPlatform.h
r10262 r10624 49 49 virtual void tick(float dt); 50 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 51 void setFigure( WeakPtr<JumpFigure> bats); //!< Set the bats for the ball.51 void setFigure(JumpFigure* newFigure); 52 52 virtual void touchFigure(); 53 53 -
code/trunk/src/modules/jump/JumpProjectile.cc
r10262 r10624 84 84 } 85 85 86 void JumpProjectile::setFigure( WeakPtr<JumpFigure>figure)86 void JumpProjectile::setFigure(JumpFigure* figure) 87 87 { 88 88 figure_ = figure; -
code/trunk/src/modules/jump/JumpProjectile.h
r10262 r10624 56 56 { return Vector2(this->fieldWidth_, this->fieldHeight_); } 57 57 58 void setFigure( WeakPtr<JumpFigure>figure);58 void setFigure(JumpFigure* figure); 59 59 60 60 protected: -
code/trunk/src/modules/jump/JumpScore.cc
r10437 r10624 118 118 if (this->getOwner() != NULL && this->getOwner()->getGametype()) 119 119 { 120 this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype() .get());120 this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype()); 121 121 } 122 122 else -
code/trunk/src/modules/mini4dgame/CMakeLists.txt
r10284 r10624 6 6 7 7 ORXONOX_ADD_LIBRARY(mini4dgame 8 MODULE8 PLUGIN 9 9 FIND_HEADER_FILES 10 10 LINK_LIBRARIES -
code/trunk/src/modules/mini4dgame/Mini4Dgame.cc
r10230 r10624 45 45 #include "core/config/ConfigValueIncludes.h" 46 46 #include "infos/PlayerInfo.h" 47 #include "core/command/ConsoleCommand .h"47 #include "core/command/ConsoleCommandIncludes.h" 48 48 49 49 #include "gamestates/GSLevel.h" -
code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc
r10230 r10624 901 901 /** 902 902 @brief 903 Is called when the gametype has changed.904 */905 void Mini4DgameBoard::changedGametype()906 {907 SUPER(Mini4DgameBoard, changedGametype);908 909 // Check, whether it's still Mini4Dgame.910 this->checkGametype();911 }912 913 /**914 @brief915 903 Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint. 916 904 */ … … 919 907 if (this->getGametype() != NULL && this->getGametype()->isA(Class(Mini4Dgame))) 920 908 { 921 Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype() .get());909 Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype()); 922 910 Mini4DgameGametype->setGameboard(this); 923 911 } -
code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h
r10230 r10624 81 81 Mini4DgameWinner getWinner(); 82 82 83 void changedGametype();84 83 void checkGametype(); 85 84 -
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r9667 r10624 37 37 #include "core/EventIncludes.h" 38 38 #include "core/XMLPort.h" 39 #include "network/NetworkFunction .h"39 #include "network/NetworkFunctionIncludes.h" 40 40 #include "network/Host.h" 41 41 … … 118 118 if(!GameMode::isStandalone()) 119 119 { 120 callMemberNetworkFunction( NotificationDispatcher,broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);120 callMemberNetworkFunction(&NotificationDispatcher::broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST); 121 121 } 122 122 } … … 148 148 else if(GameMode::isServer()) 149 149 { 150 callMemberNetworkFunction( NotificationDispatcher,dispatch, this->getObjectID(), clientId, clientId);150 callMemberNetworkFunction(&NotificationDispatcher::dispatch, this->getObjectID(), clientId, clientId); 151 151 } 152 152 } -
code/trunk/src/modules/notifications/NotificationManager.cc
r9667 r10624 37 37 #include "core/CoreIncludes.h" 38 38 #include "core/LuaState.h" 39 #include " util/ScopedSingletonManager.h"39 #include "core/singleton/ScopedSingletonIncludes.h" 40 40 41 41 #include "interfaces/NotificationListener.h" … … 47 47 { 48 48 49 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 49 ManageScopedSingleton(NotificationManager, ScopeID::ROOT, false); 50 51 RegisterAbstractClass(NotificationManager).inheritsFrom<NotificationListener>(); 50 52 51 53 /** -
code/trunk/src/modules/objects/Planet.cc
r9675 r10624 85 85 86 86 SUPER(Planet, tick, dt); 87 }88 89 void Planet::init()90 {91 87 } 92 88 -
code/trunk/src/modules/objects/Planet.h
r9667 r10624 52 52 virtual ~Planet(); 53 53 54 void init();55 54 virtual void tick(float dt); 56 55 -
code/trunk/src/modules/objects/Script.cc
r9667 r10624 37 37 #include "core/XMLPort.h" 38 38 #include "network/Host.h" 39 #include "network/NetworkFunction .h"39 #include "network/NetworkFunctionIncludes.h" 40 40 41 41 #include "PlayerManager.h" … … 198 198 for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++) 199 199 { 200 callStaticNetworkFunction( Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());200 callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics()); 201 201 if(this->times_ != Script::INF) // Decrement the number of remaining executions. 202 202 { … … 210 210 else 211 211 { 212 callStaticNetworkFunction( Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());212 callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics()); 213 213 if(this->times_ != Script::INF) // Decrement the number of remaining executions. 214 214 this->remainingExecutions_--; … … 248 248 if(GameMode::isServer() && this->isOnLoad()) 249 249 { 250 callStaticNetworkFunction( Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());250 callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics()); 251 251 } 252 252 } -
code/trunk/src/modules/objects/SpaceBoundaries.cc
r9941 r10624 210 210 for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ ) 211 211 { 212 Pawn* currentPawn = current->get();212 Pawn* currentPawn = *current; 213 213 if( currentPawn && currentPawn->getNode() ) 214 214 { -
code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc
r10189 r10624 40 40 namespace orxonox 41 41 { 42 RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom (Class(CollisionShape));42 RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom<CollisionShape>(); 43 43 44 44 /** -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
r9667 r10624 58 58 } 59 59 60 BoxCollisionShape::~BoxCollisionShape()61 {62 // TODO: Move to CollisionShape?63 if (this->isInitialized())64 delete this->collisionShape_;65 }66 67 60 void BoxCollisionShape::registerVariables() 68 61 { -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
r9667 r10624 58 58 public: 59 59 BoxCollisionShape(Context* context); 60 virtual ~BoxCollisionShape();61 60 62 61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
r10189 r10624 54 54 } 55 55 56 ConeCollisionShape::~ConeCollisionShape()57 {58 if (this->isInitialized())59 delete this->collisionShape_;60 }61 62 56 /** 63 57 @brief -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
r10189 r10624 56 56 public: 57 57 ConeCollisionShape(Context* context); 58 virtual ~ConeCollisionShape();59 58 60 59 private: -
code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc
r10262 r10624 54 54 } 55 55 56 CylinderCollisionShape::~CylinderCollisionShape()57 {58 if (this->isInitialized())59 delete this->collisionShape_;60 }61 62 56 /** 63 57 @brief -
code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h
r10262 r10624 53 53 public: 54 54 CylinderCollisionShape(Context* context); 55 virtual ~CylinderCollisionShape();56 55 57 56 private: -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
r9667 r10624 59 59 } 60 60 61 PlaneCollisionShape::~PlaneCollisionShape()62 {63 if (this->isInitialized())64 delete this->collisionShape_;65 }66 67 61 void PlaneCollisionShape::registerVariables() 68 62 { -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
r9667 r10624 58 58 public: 59 59 PlaneCollisionShape(Context* context); 60 virtual ~PlaneCollisionShape();61 60 62 61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
r9667 r10624 58 58 } 59 59 60 SphereCollisionShape::~SphereCollisionShape()61 {62 if (this->isInitialized())63 delete this->collisionShape_;64 }65 66 60 void SphereCollisionShape::registerVariables() 67 61 { -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
r9667 r10624 56 56 public: 57 57 SphereCollisionShape(Context* context); 58 virtual ~SphereCollisionShape();59 58 60 59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); -
code/trunk/src/modules/objects/triggers/CheckPoint.cc
r9667 r10624 93 93 DistanceTrigger::triggered(bIsTriggered); 94 94 95 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype() .get());95 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype()); 96 96 if (gametype) 97 97 { -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
r9667 r10624 100 100 101 101 // Check for objects that were in range but no longer are. Iterate through all objects, that are in range. 102 for(std:: map<WorldEntity*, WeakPtr<WorldEntity>*>::iterator it = this->range_.begin(); it != this->range_.end(); )102 for(std::set<WeakPtr<WorldEntity> >::iterator it = this->range_.begin(); it != this->range_.end(); ) 103 103 { 104 WorldEntity* entity = it->second->get(); 105 WorldEntity* key = it->first; 106 it++; // Incrementing the iterator in advance, since we don't need the current anymore and we potentially are going to delete the current element thus invalidating the iterator. 104 WorldEntity* entity = *it; 105 107 106 // If the entity no longer exists. 108 107 if(entity == NULL) 109 108 { 110 this->r emoveFromRange(key);109 this->range_.erase(it++); 111 110 continue; 112 111 } … … 116 115 if (distanceVec.length() > this->distance_) 117 116 { 118 // If for some reason the entity could not be removed. 119 if(!this->removeFromRange(key)) 120 continue; 117 this->range_.erase(it++); 121 118 122 119 // If no queue has been created, yet. … … 129 126 state->originator = entity; 130 127 queue->push(state); 128 } 129 else 130 { 131 ++it; 131 132 } 132 133 } … … 260 261 bool DistanceMultiTrigger::addToRange(WorldEntity* entity) 261 262 { 262 WeakPtr<WorldEntity>* weakptr = new WeakPtr<WorldEntity>(entity); 263 std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, weakptr)); 264 265 if(!pair.second) 266 { 267 delete weakptr; 268 return false; 269 } 270 271 return true; 272 } 273 274 /** 275 @brief 276 Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger. 277 @param entity 278 A pointer ot the entity. 279 @return 280 Returns true if successful. 281 */ 282 bool DistanceMultiTrigger::removeFromRange(WorldEntity* entity) 283 { 284 WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; 285 bool erased = this->range_.erase(entity) > 0; 286 if(erased) 287 delete weakptr; 288 return erased; 289 } 290 263 std::pair<std::set<WeakPtr<WorldEntity> >::iterator, bool> pair = this->range_.insert(entity); 264 return pair.second; 265 } 291 266 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r9667 r10624 140 140 141 141 bool addToRange(WorldEntity* entity); // Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger. 142 bool removeFromRange(WorldEntity* entity); // Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.143 142 144 143 private: … … 154 153 ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. 155 154 156 std:: map<WorldEntity*, WeakPtr<WorldEntity>*> range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.155 std::set<WeakPtr<WorldEntity> > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger. 157 156 158 157 }; -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r9667 r10624 147 147 { 148 148 // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done. 149 if(this->cache_ .get()!= NULL)150 { 151 if((this->cache_ .get()->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)149 if(this->cache_ != NULL) 150 { 151 if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_) 152 152 return true; 153 153 else … … 213 213 214 214 // Add the entity to the cache. 215 this->cache_ = WeakPtr<WorldEntity>(entity);215 this->cache_ = entity; 216 216 217 217 return true; -
code/trunk/src/modules/objects/triggers/Trigger.cc
r9667 r10624 38 38 #include "core/GameMode.h" 39 39 #include "core/XMLPort.h" 40 #include "core/command/ConsoleCommand .h"40 #include "core/command/ConsoleCommandIncludes.h" 41 41 42 42 #include "Scene.h" -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r9667 r10624 115 115 private: 116 116 WeakPtr<Pawn> owner_; 117 S martPtr<OverlayText> textoverlay_;117 StrongPtr<OverlayText> textoverlay_; 118 118 bool bUseBarColour_; 119 119 ColourValue textColour_; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r10294 r10624 41 41 #include "util/Math.h" 42 42 #include "util/Convert.h" 43 #include "core/command/ConsoleCommand .h"43 #include "core/command/ConsoleCommandIncludes.h" 44 44 #include "core/CoreIncludes.h" 45 45 #include "core/XMLPort.h" -
code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc
r9667 r10624 87 87 { 88 88 this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner()); 89 this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype() .get());89 this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype()); 90 90 } 91 91 else -
code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc
r9667 r10624 87 87 { 88 88 this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner()); 89 this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype() .get());89 this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype()); 90 90 } 91 91 else -
code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
r9667 r10624 118 118 119 119 if (this->getOwner() && this->getOwner()->getGametype()) 120 this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype() .get());120 this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype()); 121 121 else 122 122 this->owner_ = 0; -
code/trunk/src/modules/pickup/CollectiblePickup.cc
r9667 r10624 40 40 namespace orxonox 41 41 { 42 RegisterAbstractClass(CollectiblePickup).inheritsFrom (Class(Pickupable));42 RegisterAbstractClass(CollectiblePickup).inheritsFrom<Pickupable>(); 43 43 44 44 /** -
code/trunk/src/modules/pickup/PickupManager.cc
r9667 r10624 38 38 #include "core/GUIManager.h" 39 39 #include "core/class/Identifier.h" 40 #include "core/singleton/ScopedSingletonIncludes.h" 40 41 #include "network/Host.h" 41 #include "network/NetworkFunction.h" 42 #include "util/ScopedSingletonManager.h" 42 #include "network/NetworkFunctionIncludes.h" 43 43 44 44 #include "infos/PlayerInfo.h" … … 51 51 namespace orxonox 52 52 { 53 ManageScopedSingleton(PickupManager, ScopeID::R oot, false);53 ManageScopedSingleton(PickupManager, ScopeID::ROOT, false); 54 54 55 55 // Initialization of the name of the PickupInventory GUI. … … 62 62 registerStaticNetworkFunction(PickupManager::usePickupNetworked); 63 63 64 RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>(); 65 64 66 /** 65 67 @brief … … 94 96 95 97 // Destroying all the WeakPointers that are still there. 96 for(std::map<uint32_t, WeakPtr<Pickupable>*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)97 delete it->second;98 98 this->pickups_.clear(); 99 99 … … 212 212 else 213 213 { 214 callStaticNetworkFunction( PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());214 callStaticNetworkFunction(&PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable()); 215 215 } 216 216 } … … 286 286 // Add the Pickupable to the indexes_ and pickups_ lists. 287 287 this->indexes_[pickup] = index; 288 this->pickups_[index] = new WeakPtr<Pickupable>(pickup);288 this->pickups_[index] = pickup; 289 289 } 290 290 else // If it was dropped, it is removed from the required lists. … … 294 294 index = it->second; 295 295 296 // Remove the Pickupable form the indexes_ and pickups_ list. 297 WeakPtr<Pickupable>* ptr = this->pickups_[index]; 296 // Remove the Pickupable from the indexes_ and pickups_ list. 298 297 this->indexes_.erase(it); 299 298 this->pickups_.erase(index); 300 delete ptr;301 299 } 302 300 … … 316 314 if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end()) 317 315 { 318 callStaticNetworkFunction( PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);316 callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp); 319 317 } 320 318 else 321 319 { 322 callStaticNetworkFunction( PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);320 callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp); 323 321 } 324 322 } … … 400 398 if(this->pickups_.empty()) 401 399 return; 402 Pickupable* pickupable = this->pickups_.find(pickup)->second ->get();400 Pickupable* pickupable = this->pickups_.find(pickup)->second; 403 401 if(pickupable != NULL) 404 402 pickupable->drop(); … … 407 405 else 408 406 { 409 callStaticNetworkFunction( PickupManager::dropPickupNetworked, 0, pickup);407 callStaticNetworkFunction(&PickupManager::dropPickupNetworked, 0, pickup); 410 408 } 411 409 } … … 443 441 if(this->pickups_.empty()) 444 442 return; 445 Pickupable* pickupable = this->pickups_.find(pickup)->second ->get();443 Pickupable* pickupable = this->pickups_.find(pickup)->second; 446 444 if(pickupable != NULL) 447 445 pickupable->setUsed(use); … … 450 448 else 451 449 { 452 callStaticNetworkFunction( PickupManager::usePickupNetworked, 0, pickup, use);450 callStaticNetworkFunction(&PickupManager::usePickupNetworked, 0, pickup, use); 453 451 } 454 452 } -
code/trunk/src/modules/pickup/PickupManager.h
r9667 r10624 161 161 std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_. 162 162 163 std::map<uint32_t, WeakPtr<Pickupable> *> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.163 std::map<uint32_t, WeakPtr<Pickupable> > pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable. 164 164 std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it. 165 165 -
code/trunk/src/modules/pickup/PickupSpawner.cc
r9667 r10624 145 145 if(GameMode::isMaster() && this->isActive()) 146 146 { 147 WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 147 // TODO: why is this a WeakPtr when the comment says StrongPtr? 148 WeakPtr<PickupSpawner> spawner = this; // Create a strong pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 148 149 149 150 // Remove PickupCarriers from the blocked list if they have exceeded their time. -
code/trunk/src/modules/pickup/items/ShrinkPickup.cc
r9667 r10624 182 182 183 183 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 184 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();184 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 185 185 int size = cameraPositions.size(); 186 186 for(int index = 0; index < size; index++) … … 208 208 209 209 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 210 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();210 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 211 211 int size = cameraPositions.size(); 212 212 for(int index = 0; index < size; index++) … … 263 263 264 264 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 265 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();265 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 266 266 int size = cameraPositions.size(); 267 267 for(int index = 0; index < size; index++) … … 304 304 305 305 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 306 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();306 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 307 307 int size = cameraPositions.size(); 308 308 for(int index = 0; index < size; index++) -
code/trunk/src/modules/pong/CMakeLists.txt
r8729 r10624 12 12 13 13 ORXONOX_ADD_LIBRARY(pong 14 MODULE14 PLUGIN 15 15 FIND_HEADER_FILES 16 16 LINK_LIBRARIES -
code/trunk/src/modules/pong/PongCenterpoint.cc
r9667 r10624 80 80 /** 81 81 @brief 82 Is called when the gametype has changed.83 */84 void PongCenterpoint::changedGametype()85 {86 SUPER(PongCenterpoint, changedGametype);87 88 // Check, whether it's still Pong.89 this->checkGametype();90 }91 92 /**93 @brief94 82 Checks whether the gametype is Pong and if it is, sets its centerpoint. 95 83 */ … … 98 86 if (this->getGametype() != NULL && this->getGametype()->isA(Class(Pong))) 99 87 { 100 Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype() .get());88 Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype()); 101 89 pongGametype->setCenterpoint(this); 102 90 } -
code/trunk/src/modules/pong/PongCenterpoint.h
r9667 r10624 126 126 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML. 127 127 128 virtual void changedGametype(); //!< Is called when the gametype has changed.129 130 128 /** 131 129 @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.) -
code/trunk/src/modules/pong/PongScore.cc
r9939 r10624 170 170 171 171 if (this->getOwner() != NULL && this->getOwner()->getGametype()) 172 this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype() .get());172 this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype()); 173 173 else 174 174 this->owner_ = 0; -
code/trunk/src/modules/questsystem/Quest.cc
r9667 r10624 45 45 namespace orxonox 46 46 { 47 RegisterAbstractClass(Quest).inheritsFrom (Class(QuestItem));47 RegisterAbstractClass(Quest).inheritsFrom<QuestItem>(); 48 48 49 49 /** -
code/trunk/src/modules/questsystem/QuestEffect.cc
r9667 r10624 37 37 namespace orxonox 38 38 { 39 RegisterAbstractClass(QuestEffect).inheritsFrom (Class(BaseObject));39 RegisterAbstractClass(QuestEffect).inheritsFrom<BaseObject>(); 40 40 41 41 /** -
code/trunk/src/modules/questsystem/QuestManager.cc
r9667 r10624 36 36 #include "util/Exception.h" 37 37 #include "util/OrxAssert.h" 38 #include " util/ScopedSingletonManager.h"38 #include "core/singleton/ScopedSingletonIncludes.h" 39 39 #include "core/command/ConsoleCommand.h" 40 40 #include "core/GUIManager.h" … … 49 49 namespace orxonox 50 50 { 51 ManageScopedSingleton(QuestManager, ScopeID::R oot, false);51 ManageScopedSingleton(QuestManager, ScopeID::ROOT, false); 52 52 53 53 /** -
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
r9667 r10624 42 42 namespace orxonox 43 43 { 44 RegisterAbstractClass(ChangeQuestStatus).inheritsFrom (Class(QuestEffect));44 RegisterAbstractClass(ChangeQuestStatus).inheritsFrom<QuestEffect>(); 45 45 46 46 /** -
code/trunk/src/modules/tetris/CMakeLists.txt
r9348 r10624 8 8 9 9 ORXONOX_ADD_LIBRARY(tetris 10 MODULE10 PLUGIN 11 11 FIND_HEADER_FILES 12 12 LINK_LIBRARIES -
code/trunk/src/modules/tetris/Tetris.cc
r9834 r10624 104 104 } 105 105 106 for (std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)106 for (std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 107 107 (*it)->destroy(); 108 108 this->stones_.clear(); … … 136 136 return false; 137 137 138 for(std::list<S martPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)138 for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 139 139 { 140 140 const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone … … 192 192 193 193 // check for collisions with all stones 194 for(std::list<S martPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)194 for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 195 195 { 196 196 //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount()); … … 469 469 { 470 470 stonesPerRow = 0; 471 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )472 { 473 std::list<S martPtr<TetrisStone> >::iterator it_temp = it++;471 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 472 { 473 std::list<StrongPtr<TetrisStone> >::iterator it_temp = it++; 474 474 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize()); 475 475 if(correctPosition == row) … … 491 491 void Tetris::clearRow(unsigned int row) 492 492 {// clear the full row 493 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )493 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ) 494 494 { 495 495 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row) … … 502 502 } 503 503 // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug. 504 for(std::list<S martPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)504 for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it) 505 505 { 506 506 if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row) -
code/trunk/src/modules/tetris/Tetris.h
r10622 r10624 69 69 70 70 PlayerInfo* getPlayer(void) const; //!< Get the player. 71 WeakPtr<TetrisCenterpoint>getCenterpoint(void)71 TetrisCenterpoint* getCenterpoint(void) 72 72 { return this->center_; } 73 73 … … 93 93 94 94 WeakPtr<TetrisCenterpoint> center_; //!< The playing field. 95 std::list<S martPtr<TetrisStone> > stones_; //!< A list of all stones in play.95 std::list<StrongPtr<TetrisStone> > stones_; //!< A list of all stones in play. 96 96 WeakPtr<TetrisBrick> activeBrick_; 97 97 WeakPtr<TetrisBrick> futureBrick_; -
code/trunk/src/modules/tetris/TetrisBrick.cc
r10262 r10624 169 169 if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris))) 170 170 { 171 Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype() .get());171 Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype()); 172 172 return tetrisGametype; 173 173 } -
code/trunk/src/modules/tetris/TetrisCenterpoint.cc
r9667 r10624 80 80 /** 81 81 @brief 82 Is called when the gametype has changed.83 */84 void TetrisCenterpoint::changedGametype()85 {86 SUPER(TetrisCenterpoint, changedGametype);87 88 // Check, whether it's still Tetris.89 this->checkGametype();90 }91 92 /**93 @brief94 82 Checks whether the gametype is Tetris and if it is, sets its centerpoint. 95 83 */ … … 98 86 if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris))) 99 87 { 100 Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype() .get());88 Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype()); 101 89 tetrisGametype->setCenterpoint(this); 102 90 } -
code/trunk/src/modules/tetris/TetrisCenterpoint.h
r9667 r10624 64 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML. 65 65 66 virtual void changedGametype(); //!< Is called when the gametype has changed.67 68 66 /** 69 67 @brief Set the width of the playing field. -
code/trunk/src/modules/tetris/TetrisScore.cc
r10262 r10624 118 118 119 119 if (this->getOwner() != NULL && this->getOwner()->getGametype()) 120 this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype() .get());120 this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype()); 121 121 else 122 122 this->owner_ = 0; -
code/trunk/src/modules/towerdefense/CMakeLists.txt
r10622 r10624 11 11 12 12 ORXONOX_ADD_LIBRARY(towerdefense 13 MODULE13 PLUGIN 14 14 FIND_HEADER_FILES 15 15 LINK_LIBRARIES -
code/trunk/src/modules/towerdefense/TDCoordinate.h
r10622 r10624 2 2 #define _TDCoordinate_H__ 3 3 4 #include "core/CoreIncludes.h"5 4 #include "TDCoordinate.h" 6 5 //#include "towerdefense/TowerDefense.h" … … 13 12 //Class to save the Coordinates in a class instead of struct 14 13 //Convert 2d coordinates to 3d in order to set waypoints 15 class _TowerDefenseExport TDCoordinate : public OrxonoxClass14 class _TowerDefenseExport TDCoordinate 16 15 { 17 16 public: -
code/trunk/src/modules/towerdefense/TowerDefense.cc
r10622 r10624 85 85 #include "core/CoreIncludes.h" 86 86 /* Part of a temporary hack to allow the player to add towers */ 87 #include "core/command/ConsoleCommand .h"87 #include "core/command/ConsoleCommandIncludes.h" 88 88 #include <cmath> 89 89 -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r10622 r10624 83 83 /** 84 84 @brief 85 Is called when the gametype has changed.86 */87 void TowerDefenseCenterpoint::changedGametype()88 {89 SUPER(TowerDefenseCenterpoint, changedGametype);90 91 // Check, whether it's still TowerDefense.92 this->checkGametype();93 }94 95 /**96 @brief97 85 Checks whether the gametype is TowerDefense and if it is, sets its centerpoint. 98 86 */ … … 102 90 { 103 91 // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point 104 TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype() .get());92 TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype()); 105 93 towerDefenseGametype->setCenterpoint(this); 106 94 } -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
r10622 r10624 53 53 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 virtual void changedGametype();56 55 57 56 /** -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
r10622 r10624 29 29 this->setCollisionType(WorldEntity::Dynamic); 30 30 //needed to keep track of the PlayerStats coded in TowerDefense.h 31 this->td = orxonox_cast<TowerDefense*>(this->getGametype() .get());31 this->td = orxonox_cast<TowerDefense*>(this->getGametype()); 32 32 once_=false; 33 33 … … 53 53 } 54 54 55 WeakPtr<TowerDefense>TowerDefenseEnemy::getGame()55 TowerDefense* TowerDefenseEnemy::getGame() 56 56 { 57 57 if (game == NULL) -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
r10258 r10624 47 47 48 48 private: 49 WeakPtr<TowerDefense>getGame();49 TowerDefense* getGame(); 50 50 WeakPtr<TowerDefense> game; 51 51 TowerDefense* td; -
code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
r10258 r10624 80 80 if (this->getOwner() && this->getOwner()->getGametype()) 81 81 { 82 this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype() .get());82 this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype()); 83 83 } 84 84 else -
code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
r9667 r10624 54 54 this->particles_->setKeepParticlesInLocalSpace(0); 55 55 56 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 56 for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i) 57 this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT); 57 58 } 58 59 else -
code/trunk/src/orxonox/CMakeLists.txt
r10216 r10624 29 29 Main.cc 30 30 MoodManager.cc 31 PawnManager.cc32 31 PlayerManager.cc 33 ShipPartManager.cc34 32 Radar.cc 35 33 # Test.cc -
code/trunk/src/orxonox/CameraManager.cc
r9667 r10624 35 35 #include <OgreCompositorManager.h> 36 36 37 #include "util/ScopedSingletonManager.h"38 37 #include "core/GameMode.h" 39 38 #include "core/GraphicsManager.h" 40 39 #include "core/object/ObjectList.h" 40 #include "core/singleton/ScopedSingletonIncludes.h" 41 41 #include "tools/Shader.h" 42 42 #include "graphics/Camera.h" … … 44 44 namespace orxonox 45 45 { 46 ManageScopedSingleton(CameraManager, ScopeID::G raphics, false);46 ManageScopedSingleton(CameraManager, ScopeID::GRAPHICS, false); 47 47 48 48 CameraManager::CameraManager() -
code/trunk/src/orxonox/Level.cc
r9667 r10624 35 35 #include "core/XMLFile.h" 36 36 #include "core/XMLPort.h" 37 #include "core/module/PluginReference.h" 37 38 38 39 #include "infos/PlayerInfo.h" … … 49 50 RegisterObject(Level); 50 51 52 this->setLevel(WeakPtr<Level>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency) 51 53 52 54 this->registerVariables(); … … 63 65 64 66 if (this->xmlfile_) 65 Loader::unload(this->xmlfile_); 67 Loader::getInstance().unload(this->xmlfile_); 68 69 this->unloadPlugins(); 66 70 } 67 71 } … … 71 75 SUPER(Level, XMLPort, xmlelement, mode); 72 76 77 XMLPortParam(Level, "plugins", setPluginsString, getPluginsString, xmlelement, mode); 73 78 XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype"); 74 79 … … 95 100 this->xmlfile_ = new XMLFile(mask, this->xmlfilename_); 96 101 97 Loader:: open(this->xmlfile_);102 Loader::getInstance().load(this->xmlfile_); 98 103 } 99 104 … … 105 110 Template::getTemplate(*it)->applyOn(this); 106 111 } 112 } 113 114 void Level::setPluginsString(const std::string& pluginsString) 115 { 116 // unload old plugins 117 this->unloadPlugins(); 118 119 // load new plugins 120 this->pluginsString_ = pluginsString; 121 SubString tokens(pluginsString, ","); 122 for (size_t i = 0; i < tokens.size(); ++i) 123 this->plugins_.push_back(new PluginReference(tokens[i])); 124 } 125 126 void Level::unloadPlugins() 127 { 128 // use destroyLater() - this ensures that plugins are not unloaded too early. 129 // Note: When a level gets unloaded, the Level object is usually the last object that gets destroyed. This is because all other 130 // objects inside a level have a StrongPtr (in BaseObject) that references the Level object. This means that the Level 131 // object is only destroyed, when all StrongPtrs that pointed to it were destroyed. But at the time when the last StrongPtr 132 // is destroyed, the other object is not yet fully destroyed because the StrongPtr is destroyed in ~BaseObject (and this 133 // means that e.g. ~Identifiable was not yet called for this object). This means that technically there are still other 134 // objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need 135 // to call destroyLater() to ensure that no instances from this plugin exist anymore. 136 for (std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it) 137 (*it)->destroyLater(); 138 this->plugins_.clear(); 107 139 } 108 140 … … 121 153 122 154 Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this)); 123 this->setGametype(rootgametype); 124 125 for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it) 126 (*it)->setGametype(rootgametype); 155 156 // store a weak-pointer to the gametype to avoid a circular dependency between this level and the gametype (which has a strong-reference on this level) 157 this->setGametype(WeakPtr<Gametype>(rootgametype)); 158 159 rootgametype->init(); // call init() AFTER the gametype was set 127 160 128 161 if (LevelManager::exists()) … … 134 167 { 135 168 this->objects_.push_back(object); 136 object->setGametype(this->getGametype());137 object->setLevel(this);138 169 } 139 170 … … 170 201 { 171 202 orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl; 172 player->s etGametype(this->getGametype());203 player->switchGametype(this->getGametype()); 173 204 } 174 205 … … 176 207 { 177 208 orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl; 178 player->s etGametype(0);209 player->switchGametype(0); 179 210 } 180 211 } -
code/trunk/src/orxonox/Level.h
r9667 r10624 65 65 // MeshLodInformation* getLodInfo(unsigned int index) const; 66 66 67 void setPluginsString(const std::string& pluginsString); 68 inline const std::string& getPluginsString() const 69 { return this->pluginsString_; } 70 71 void unloadPlugins(); 72 67 73 void setGametypeString(const std::string& gametype); 68 74 inline const std::string& getGametypeString() const … … 70 76 71 77 void networkcallback_applyXMLFile(); 78 79 std::string pluginsString_; 80 std::list<PluginReference*> plugins_; 72 81 73 82 std::string gametype_; -
code/trunk/src/orxonox/LevelManager.cc
r10258 r10624 36 36 #include <map> 37 37 38 #include " util/ScopedSingletonManager.h"39 #include "core/co nfig/CommandLineParser.h"38 #include "core/singleton/ScopedSingletonIncludes.h" 39 #include "core/commandline/CommandLineIncludes.h" 40 40 #include "core/config/ConfigValueIncludes.h" 41 41 #include "core/CoreIncludes.h" … … 51 51 SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)"); 52 52 53 ManageScopedSingleton(LevelManager, ScopeID::Root, false); 53 ManageScopedSingleton(LevelManager, ScopeID::ROOT, false); 54 55 RegisterAbstractClass(LevelManager).inheritsFrom<Configurable>(); 54 56 55 57 /** … … 274 276 // Load the LevelInfo object from the level file. 275 277 XMLFile file = XMLFile(*it); 276 Loader:: load(&file, mask, false, true);278 Loader::getInstance().load(&file, mask, false, true); 277 279 278 280 // Find the LevelInfo object we've just loaded (if there was one) … … 282 284 283 285 // We don't need the loaded stuff anymore 284 Loader:: unload(&file);286 Loader::getInstance().unload(&file); 285 287 286 288 if(info == NULL) -
code/trunk/src/orxonox/Main.cc
r9667 r10624 36 36 #include "Main.h" 37 37 38 #include "core/co nfig/CommandLineParser.h"38 #include "core/commandline/CommandLineIncludes.h" 39 39 #include "core/Game.h" 40 40 #include "core/LuaState.h" -
code/trunk/src/orxonox/MoodManager.cc
r9667 r10624 29 29 #include "MoodManager.h" 30 30 31 #include " util/ScopedSingletonManager.h"31 #include "core/singleton/ScopedSingletonIncludes.h" 32 32 #include "core/config/ConfigValueIncludes.h" 33 33 #include "core/CoreIncludes.h" … … 36 36 namespace orxonox 37 37 { 38 ManageScopedSingleton(MoodManager, ScopeID::R oot, false);38 ManageScopedSingleton(MoodManager, ScopeID::ROOT, false); 39 39 40 40 // Note: I'm (Kevin Young) not entirely sure whether that's good code style: 41 41 const std::string MoodManager::defaultMood_ = "default"; 42 43 RegisterAbstractClass(MoodListener).inheritsFrom<OrxonoxInterface>(); 44 RegisterAbstractClass(MoodManager).inheritsFrom<Configurable>(); 42 45 43 46 MoodManager::MoodManager() -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r10281 r10624 73 73 class LevelInfoItem; 74 74 class LevelManager; 75 class PawnManager;76 75 class PlayerManager; 77 76 class Radar; -
code/trunk/src/orxonox/PlayerManager.cc
r9667 r10624 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/GameMode.h" 33 #include " util/ScopedSingletonManager.h"33 #include "core/singleton/ScopedSingletonIncludes.h" 34 34 35 35 #include "Level.h" … … 39 39 namespace orxonox 40 40 { 41 ManageScopedSingleton(PlayerManager, ScopeID::Root, false); 41 ManageScopedSingleton(PlayerManager, ScopeID::ROOT, false); 42 43 RegisterAbstractClass(PlayerManager).inheritsFrom<ClientConnectionListener>(); 42 44 43 45 PlayerManager::PlayerManager() -
code/trunk/src/orxonox/Radar.cc
r9667 r10624 37 37 38 38 //#include "util/Math.h" 39 #include "core/CoreIncludes.h" 39 40 #include "core/object/ObjectList.h" 40 41 #include "core/command/ConsoleCommand.h" … … 45 46 namespace orxonox 46 47 { 48 RegisterAbstractClass(Radar).inheritsFrom<Tickable>(); 47 49 48 50 Radar::Radar() -
code/trunk/src/orxonox/Scene.cc
r10316 r10624 44 44 #include "core/GUIManager.h" 45 45 #include "core/XMLPort.h" 46 #include "core/command/ConsoleCommand .h"46 #include "core/command/ConsoleCommandIncludes.h" 47 47 #include "tools/BulletConversions.h" 48 48 #include "tools/BulletDebugDrawer.h" … … 62 62 RegisterObject(Scene); 63 63 64 this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN); 64 this->setScene(WeakPtr<Scene>(this), this->getObjectID()); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency) 65 65 66 this->bShadows_ = true; 66 67 this->bDebugDrawPhysics_ = false; 67 68 this->debugDrawer_ = NULL; 68 69 this->soundReferenceDistance_ = 20.0; 70 this->bIsUpdatingPhysics_ = false; 69 71 70 72 if (GameMode::showsGraphics()) … … 141 143 registerVariable(this->bHasPhysics_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics)); 142 144 registerVariable(this->bShadows_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows)); 143 registerVariable(this->getLevel(), VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::changedLevel));144 145 } 145 146 … … 266 267 // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds. 267 268 // Under that mark, the simulation will "loose time" and get unusable. 268 physicalWorld_->stepSimulation(dt, 60); 269 this->bIsUpdatingPhysics_ = true; 270 this->physicalWorld_->stepSimulation(dt, 60); 271 this->bIsUpdatingPhysics_ = false; 269 272 270 273 if (this->bDebugDrawPhysics_) 271 physicalWorld_->debugDrawWorld();274 this->physicalWorld_->debugDrawWorld(); 272 275 } 273 276 } … … 313 316 { 314 317 this->objects_.push_back(object); 315 object->setScene(this, this->getObjectID());316 318 } 317 319 … … 363 365 { 364 366 // get the WorldEntity pointers 365 S martPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());366 S martPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());367 StrongPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer()); 368 StrongPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer()); 367 369 368 370 // get the CollisionShape pointers -
code/trunk/src/orxonox/Scene.h
r10196 r10624 110 110 111 111 public: 112 inline bool hasPhysics() 112 inline bool hasPhysics() const 113 113 { return this->physicalWorld_ != 0; } 114 114 void setPhysicalWorld(bool wantsPhysics); … … 128 128 void addPhysicalObject(WorldEntity* object); 129 129 void removePhysicalObject(WorldEntity* object); 130 131 inline bool isUpdatingPhysics() const 132 { return this->bIsUpdatingPhysics_; } 130 133 131 134 void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha); … … 163 166 BulletDebugDrawer* debugDrawer_; 164 167 bool bDebugDrawPhysics_; 168 bool bIsUpdatingPhysics_; 165 169 }; 166 170 } -
code/trunk/src/orxonox/Test.cc
r9667 r10624 29 29 #include "core/CoreIncludes.h" 30 30 #include "core/config/ConfigValueIncludes.h" 31 #include "core/command/ConsoleCommand .h"32 #include "network/NetworkFunction .h"31 #include "core/command/ConsoleCommandIncludes.h" 32 #include "network/NetworkFunctionIncludes.h" 33 33 #include "Test.h" 34 34 #include "util/MultiType.h" … … 105 105 void Test::call(unsigned int clientID) 106 106 { 107 callStaticNetworkFunction( 108 callStaticNetworkFunction( 107 callStaticNetworkFunction(&Test::printV1, clientID ); 108 callStaticNetworkFunction(&Test::printV1, clientID ); 109 109 } 110 110 111 111 void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4) 112 112 { 113 callMemberNetworkFunction( Test,printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );113 callMemberNetworkFunction( &Test::printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 ); 114 114 } 115 115 … … 130 130 // if(!Core::isMaster()) 131 131 // call2(0, "bal", "a", "n", "ce"); 132 // callMemberNetworkFunction( Test,checkU1, this->getObjectID(), 0 );132 // callMemberNetworkFunction( &Test::checkU1, this->getObjectID(), 0 ); 133 133 } 134 134 -
code/trunk/src/orxonox/chat/ChatHistory.cc
r9667 r10624 28 28 29 29 #include "ChatHistory.h" 30 #include "util/ScopedSingletonManager.h" 30 #include "core/singleton/ScopedSingletonIncludes.h" 31 #include "core/ConfigurablePaths.h" 31 32 32 33 #ifndef CHATTEST … … 34 35 { 35 36 /* singleton */ 36 ManageScopedSingleton( ChatHistory, ScopeID::Root, false ); 37 ManageScopedSingleton( ChatHistory, ScopeID::ROOT, false ); 38 39 RegisterAbstractClass(ChatHistory).inheritsFrom<ChatListener>(); 40 37 41 #endif 38 42 … … 118 122 */ 119 123 #ifndef CHATTEST 120 this->hist_logfile.open( ( PathConfig::getInstance().getLogPathString() +124 this->hist_logfile.open( (ConfigurablePaths::getLogPathString() + 121 125 "chatlog.log").c_str(), 122 126 std::fstream::out | std::fstream::app ); -
code/trunk/src/orxonox/chat/ChatHistory.h
r8858 r10624 41 41 #include "util/Singleton.h" 42 42 #include "core/BaseObject.h" 43 #include "core/PathConfig.h"44 43 #include "chat/ChatListener.h" 45 44 #include "infos/PlayerInfo.h" -
code/trunk/src/orxonox/chat/ChatInputHandler.cc
r9675 r10624 47 47 #endif 48 48 49 #include " util/ScopedSingletonManager.h"49 #include "core/singleton/ScopedSingletonIncludes.h" 50 50 #include "core/CoreIncludes.h" 51 51 #include "core/GUIManager.h" 52 #include "core/command/ConsoleCommand .h"52 #include "core/command/ConsoleCommandIncludes.h" 53 53 #include "core/input/InputBuffer.h" 54 54 #include "core/input/InputManager.h" … … 62 62 { 63 63 /* singleton */ 64 ManageScopedSingleton( ChatInputHandler, ScopeID::G raphics, false );64 ManageScopedSingleton( ChatInputHandler, ScopeID::GRAPHICS, false ); 65 65 66 66 /* add commands to console */ 67 67 SetConsoleCommand( "startchat", &ChatInputHandler::activate_static ); 68 68 SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static ); 69 70 RegisterAbstractClass(ChatInputHandler).inheritsFrom<ChatListener>(); 69 71 70 72 /* constructor */ -
code/trunk/src/orxonox/chat/ChatManager.cc
r9667 r10624 30 30 #include "ChatListener.h" 31 31 32 #include "util/ScopedSingletonManager.h"33 32 #include "core/CoreIncludes.h" 34 #include "core/command/ConsoleCommand.h" 33 #include "core/singleton/ScopedSingletonIncludes.h" 34 #include "core/command/ConsoleCommandIncludes.h" 35 35 #include "network/Host.h" 36 36 … … 40 40 namespace orxonox 41 41 { 42 ManageScopedSingleton(ChatManager, ScopeID::R oot, false);42 ManageScopedSingleton(ChatManager, ScopeID::ROOT, false); 43 43 44 44 SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST); 45 46 RegisterAbstractClass(ChatManager).inheritsFrom<NetworkChatListener>(); 45 47 46 48 ChatManager::ChatManager() … … 113 115 // ChatListener // 114 116 ////////////////////////////////////////////////////////////////////////// 115 RegisterAbstractClass(ChatListener).inheritsFrom (Class(Listable));117 RegisterAbstractClass(ChatListener).inheritsFrom<Listable>(); 116 118 117 119 ChatListener::ChatListener() -
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
r10216 r10624 41 41 #include "CompoundCollisionShape.h" 42 42 #include "WorldEntityCollisionShape.h" 43 #include "Scene.h" 43 44 44 45 namespace orxonox 45 46 { 46 RegisterAbstractClass(CollisionShape).inheritsFrom (Class(BaseObject)).inheritsFrom(Class(Synchronisable));47 RegisterAbstractClass(CollisionShape).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>(); 47 48 48 49 /** … … 74 75 { 75 76 // Detach from parent CompoundCollisionShape. 76 if (this->isInitialized() && this->parent_) 77 this->parent_->detach(this); 77 if (this->isInitialized()) 78 { 79 if (this->getScene() && this->getScene()->isUpdatingPhysics()) 80 orxout(internal_error) << "Don't destroy collision shapes while the physics is updated! This will lead to crashes. Try to use destroyLater() instead" << endl; 81 82 if (this->parent_) 83 this->parent_->detach(this); 84 85 if (this->collisionShape_) 86 delete this->collisionShape_; 87 } 78 88 } 79 89 -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r9667 r10624 71 71 it->first->notifyDetached(); 72 72 it->first->destroy(); 73 if (this->collisionShape_ == it->second) 74 this->collisionShape_ = NULL; // don't destroy it twice 73 75 } 74 76 75 77 delete this->compoundShape_; 78 if (this->collisionShape_ == this->compoundShape_) 79 this->collisionShape_ = NULL; // don't destroy it twice 76 80 } 77 81 } -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r9667 r10624 37 37 namespace orxonox 38 38 { 39 RegisterClass(WorldEntityCollisionShape); 40 39 41 WorldEntityCollisionShape::WorldEntityCollisionShape(Context* context) : CompoundCollisionShape(context) 40 42 { … … 44 46 // suppress synchronisation 45 47 this->setSyncMode(ObjectDirection::None); 46 }47 48 WorldEntityCollisionShape::~WorldEntityCollisionShape()49 {50 // Called always by WE destructor51 48 } 52 49 -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
r9667 r10624 39 39 public: 40 40 WorldEntityCollisionShape(Context* context); 41 virtual ~WorldEntityCollisionShape();42 41 43 42 inline void setWorldEntityOwner(WorldEntity* worldEntityOwner) -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r10294 r10624 30 30 #include "core/CoreIncludes.h" 31 31 #include "core/XMLPort.h" 32 #include "core/command/ConsoleCommand .h"32 #include "core/command/ConsoleCommandIncludes.h" 33 33 #include "worldentities/pawns/Pawn.h" 34 34 #include "worldentities/pawns/SpaceShip.h" -
code/trunk/src/orxonox/controllers/FormationController.cc
r10622 r10624 33 33 34 34 #include "core/XMLPort.h" 35 #include "core/command/ConsoleCommand .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 36 37 37 #include "worldentities/ControllableEntity.h" -
code/trunk/src/orxonox/controllers/HumanController.cc
r9979 r10624 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/command/ConsoleCommand .h"32 #include "core/command/ConsoleCommandIncludes.h" 33 33 #include "worldentities/ControllableEntity.h" 34 34 #include "worldentities/pawns/Pawn.h" … … 59 59 SetConsoleCommand("HumanController", __CC_suicide_name, &HumanController::suicide ).addShortcut(); 60 60 SetConsoleCommand("HumanController", "toggleGodMode", &HumanController::toggleGodMode ).addShortcut(); 61 SetConsoleCommand("HumanController", "addBots", &HumanController::addBots ).addShortcut().defaultValues(1);62 SetConsoleCommand("HumanController", "killBots", &HumanController::killBots ).addShortcut().defaultValues(0);63 61 SetConsoleCommand("HumanController", "cycleNavigationFocus", &HumanController::cycleNavigationFocus).addShortcut(); 64 62 SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut(); … … 318 316 } 319 317 320 void HumanController::addBots(unsigned int amount)321 {322 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())323 HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);324 }325 326 void HumanController::killBots(unsigned int amount)327 {328 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())329 HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);330 }331 332 318 Pawn* HumanController::getLocalControllerEntityAsPawn() 333 319 { -
code/trunk/src/orxonox/controllers/HumanController.h
r9979 r10624 83 83 static void FFChangeMode(); 84 84 85 static void addBots(unsigned int amount);86 static void killBots(unsigned int amount = 0);87 88 85 static void pauseControl(); // tolua_export 89 86 static void resumeControl(); // tolua_export -
code/trunk/src/orxonox/controllers/NewHumanController.cc
r10216 r10624 37 37 38 38 #include "core/CoreIncludes.h" 39 #include "core/command/ConsoleCommand .h"39 #include "core/command/ConsoleCommandIncludes.h" 40 40 #include "core/input/KeyBinder.h" 41 41 #include "core/input/KeyBinderManager.h" -
code/trunk/src/orxonox/gamestates/GSClient.cc
r9667 r10624 30 30 31 31 #include "util/Exception.h" 32 #include "core/co nfig/CommandLineParser.h"32 #include "core/commandline/CommandLineIncludes.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r10299 r10624 44 44 #include "core/Loader.h" 45 45 #include "core/XMLFile.h" 46 #include "core/command/ConsoleCommand .h"46 #include "core/command/ConsoleCommandIncludes.h" 47 47 48 48 #include "LevelManager.h" 49 #include "Level.h" 49 50 #include "PlayerManager.h" 50 51 #include "GSRoot.h" … … 95 96 } 96 97 98 this->prepareObjectTracking(); 99 97 100 if (GameMode::isMaster()) 98 101 { … … 128 131 if (GameMode::isMaster()) 129 132 this->unloadLevel(); 133 else 134 this->unloadLevelAsClient(); 135 136 this->performObjectTracking(); 130 137 131 138 if (GameMode::showsGraphics()) … … 161 168 } 162 169 163 void GSLevel:: loadLevel()170 void GSLevel::prepareObjectTracking() 164 171 { 165 172 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 166 173 this->staticObjects_.insert(*it); 167 168 // call the loader 169 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 170 bool loaded = Loader::open(startFile_); 171 172 Core::getInstance().updateLastLevelTimestamp(); 173 if(!loaded) 174 GSRoot::delayedStartMainMenu(); 175 } 176 177 void GSLevel::unloadLevel() 178 { 179 Loader::unload(startFile_); 180 delete startFile_; 181 174 } 175 176 void GSLevel::performObjectTracking() 177 { 182 178 orxout(internal_info) << "Remaining objects:" << endl; 183 179 unsigned int i = 0; … … 187 183 if (find == this->staticObjects_.end()) 188 184 { 189 orxout(internal_ info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;185 orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl; 190 186 } 191 187 } … … 194 190 else 195 191 orxout(internal_warning) << i << " objects remaining. Try harder!" << endl; 192 } 193 194 void GSLevel::loadLevel() 195 { 196 // call the loader 197 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 198 bool loaded = Loader::getInstance().load(startFile_); 199 200 Core::getInstance().getConfig()->updateLastLevelTimestamp(); 201 if(!loaded) 202 GSRoot::delayedStartMainMenu(); 203 } 204 205 void GSLevel::unloadLevel() 206 { 207 Loader::getInstance().unload(startFile_); 208 delete startFile_; 209 } 210 211 /** 212 * Unloads a level when the game instance is (or was) a client in a multiplayer session. 213 * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown. 214 */ 215 void GSLevel::unloadLevelAsClient() 216 { 217 for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); ) 218 { 219 StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it 220 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); ) 221 (it++)->destroy(); 222 } 223 224 for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ) 225 { 226 if (it->getSyncMode() != 0x0) 227 (it++)->destroy(); 228 else 229 ++it; 230 } 196 231 } 197 232 … … 252 287 /////////////////////////////////////////////////////////////////////////// 253 288 254 RegisterAbstractClass(GSLevelMemento).inheritsFrom (Class(OrxonoxInterface));289 RegisterAbstractClass(GSLevelMemento).inheritsFrom<OrxonoxInterface>(); 255 290 256 291 GSLevelMemento::GSLevelMemento() -
code/trunk/src/orxonox/gamestates/GSLevel.h
r10281 r10624 53 53 void reloadLevel(); 54 54 55 pr otected:55 private: 56 56 void loadLevel(); 57 57 void unloadLevel(); 58 void unloadLevelAsClient(); 59 60 void prepareObjectTracking(); 61 void performObjectTracking(); 58 62 59 63 InputState* gameInputState_; //!< input state for normal ingame playing -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r9944 r10624 36 36 #include "core/GraphicsManager.h" 37 37 #include "core/GUIManager.h" 38 #include "core/command/ConsoleCommand .h"38 #include "core/command/ConsoleCommandIncludes.h" 39 39 #include "core/input/KeyBinderManager.h" 40 40 #include "network/Client.h" … … 63 63 SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide(); 64 64 65 RegisterAbstractClass(GSMainMenu).inheritsFrom<Configurable>(); 66 65 67 GSMainMenu::GSMainMenu(const GameStateInfo& info) 66 68 : GameState(info) -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r9348 r10624 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" 35 #include "core/command/ConsoleCommand .h"36 #include "network/NetworkFunction .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 #include "network/NetworkFunctionIncludes.h" 37 37 #include "tools/Timer.h" 38 38 #include "tools/interfaces/Tickable.h" … … 68 68 GSRoot::~GSRoot() 69 69 { 70 NetworkFunctionBase::destroyAllNetworkFunctions();71 70 } 72 71 -
code/trunk/src/orxonox/gamestates/GSServer.cc
r10197 r10624 30 30 31 31 #include "util/Output.h" 32 #include "core/co nfig/CommandLineParser.h"32 #include "core/commandline/CommandLineIncludes.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r9945 r10624 310 310 if (spaceship) 311 311 { 312 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);313 if(ptr == NULL)314 return;315 312 spaceship->addSpeedFactor(5); 316 313 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 317 executor->setDefaultValue(0, ptr);314 executor->setDefaultValue(0, spaceship); 318 315 new Timer(10, false, executor, true); 319 316 } … … 593 590 } 594 591 595 void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function 596 { 597 if (*ptr) 598 { 599 (*ptr)->addSpeedFactor(1.0f/5.0f); 600 } 601 delete ptr; 592 void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship)// helper function 593 { 594 if (spaceship) 595 { 596 spaceship->addSpeedFactor(1.0f/5.0f); 597 } 602 598 } 603 599 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r9676 r10624 77 77 virtual void rewardPig(); 78 78 void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost. 79 void resetSpeedFactor( WeakPtr<SpaceShip>* ptr);79 void resetSpeedFactor(SpaceShip* spaceship); 80 80 void tick (float dt);// used to end the game 81 81 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/trunk/src/orxonox/gametypes/Gametype.cc
r10281 r10624 34 34 #include "core/config/ConfigValueIncludes.h" 35 35 #include "core/GameMode.h" 36 #include "core/command/ConsoleCommand .h"36 #include "core/command/ConsoleCommandIncludes.h" 37 37 #include "gamestates/GSLevel.h" 38 38 … … 49 49 namespace orxonox 50 50 { 51 static const std::string __CC_addBots_name = "addBots"; 52 static const std::string __CC_killBots_name = "killBots"; 53 54 SetConsoleCommand("Gametype", __CC_addBots_name, &Gametype::addBots ).addShortcut().defaultValues(1); 55 SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0); 56 51 57 RegisterUnloadableClass(Gametype); 52 58 … … 55 61 RegisterObject(Gametype); 56 62 63 this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency) 64 57 65 this->gtinfo_ = new GametypeInfo(context); 58 66 59 this->setGametype(SmartPtr<Gametype>(this, false));60 61 67 this->defaultControllableEntity_ = Class(Spectator); 68 this->scoreboard_ = 0; 62 69 63 70 this->bAutoStart_ = false; … … 74 81 this->setConfigValues(); 75 82 83 ModifyConsoleCommand(__CC_addBots_name).setObject(this); 84 ModifyConsoleCommand(__CC_killBots_name).setObject(this); 85 } 86 87 Gametype::~Gametype() 88 { 89 if (this->isInitialized()) 90 { 91 if (this->gtinfo_) 92 this->gtinfo_->destroy(); 93 94 ModifyConsoleCommand(__CC_addBots_name).setObject(NULL); 95 ModifyConsoleCommand(__CC_killBots_name).setObject(NULL); 96 } 97 } 98 99 /** 100 * @brief Initializes sub-objects of the Gametype. This must be called after the constructor. 101 * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor. 102 */ 103 void Gametype::init() 104 { 76 105 // load the corresponding score board 77 106 if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty()) 78 107 { 79 this->scoreboard_ = new OverlayGroup( context);108 this->scoreboard_ = new OverlayGroup(this->getContext()); 80 109 this->scoreboard_->addTemplate(this->scoreboardTemplate_); 81 this->scoreboard_->setGametype(this);82 }83 else84 this->scoreboard_ = 0;85 86 /* HACK HACK HACK */87 this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );88 this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );89 /* HACK HACK HACK */90 }91 92 Gametype::~Gametype()93 {94 if (this->isInitialized())95 {96 this->gtinfo_->destroy();97 if( this->dedicatedAddBots_ )98 delete this->dedicatedAddBots_;99 if( this->dedicatedKillBots_ )100 delete this->dedicatedKillBots_;101 110 } 102 111 } … … 406 415 { 407 416 // If in developer's mode, there is no start countdown. 408 if(Core::getInstance(). inDevMode())417 if(Core::getInstance().getConfig()->inDevMode()) 409 418 this->start(); 410 419 else -
code/trunk/src/orxonox/gametypes/Gametype.h
r10281 r10624 72 72 virtual ~Gametype(); 73 73 74 virtual void init(); 75 74 76 void setConfigValues(); 75 77 … … 176 178 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states); 177 179 178 SmartPtr<GametypeInfo> gtinfo_;180 WeakPtr<GametypeInfo> gtinfo_; 179 181 180 182 bool bAutoStart_; … … 199 201 std::string scoreboardTemplate_; 200 202 201 /* HACK HACK HACK */202 ConsoleCommand* dedicatedAddBots_;203 ConsoleCommand* dedicatedKillBots_;204 /* HACK HACK HACK */205 203 Timer showMenuTimer_; 206 204 }; -
code/trunk/src/orxonox/gametypes/Mission.cc
r10258 r10624 33 33 34 34 #include "core/CoreIncludes.h" 35 #include "core/command/ConsoleCommand .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 36 #include "infos/PlayerInfo.h" 37 37 #include "network/Host.h" -
code/trunk/src/orxonox/infos/GametypeInfo.cc
r9667 r10624 37 37 #include "core/GameMode.h" 38 38 #include "network/Host.h" 39 #include "network/NetworkFunction .h"39 #include "network/NetworkFunctionIncludes.h" 40 40 #include "util/Convert.h" 41 41 … … 369 369 this->changedReadyToSpawn(ready); 370 370 else 371 callMemberNetworkFunction( GametypeInfo,changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);371 callMemberNetworkFunction(&GametypeInfo::changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready); 372 372 } 373 373 } … … 388 388 this->changedSpawned(spawned); 389 389 else 390 callMemberNetworkFunction( GametypeInfo,changedSpawned, this->getObjectID(), player->getClientID(), spawned);390 callMemberNetworkFunction(&GametypeInfo::changedSpawned, this->getObjectID(), player->getClientID(), spawned); 391 391 } 392 392 } … … 399 399 if (GameMode::isMaster()) 400 400 { 401 callMemberNetworkFunction( GametypeInfo,dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message);401 callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message); 402 402 this->dispatchAnnounceMessage(message); 403 403 } … … 411 411 this->dispatchAnnounceMessage(message); 412 412 else 413 callMemberNetworkFunction( GametypeInfo,dispatchAnnounceMessage, this->getObjectID(), clientID, message);413 callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), clientID, message); 414 414 } 415 415 } … … 422 422 this->dispatchKillMessage(message); 423 423 else 424 callMemberNetworkFunction( GametypeInfo,dispatchKillMessage, this->getObjectID(), clientID, message);424 callMemberNetworkFunction(&GametypeInfo::dispatchKillMessage, this->getObjectID(), clientID, message); 425 425 } 426 426 } … … 433 433 this->dispatchDeathMessage(message); 434 434 else 435 callMemberNetworkFunction( GametypeInfo,dispatchDeathMessage, this->getObjectID(), clientID, message);435 callMemberNetworkFunction(&GametypeInfo::dispatchDeathMessage, this->getObjectID(), clientID, message); 436 436 } 437 437 } … … 444 444 this->dispatchStaticMessage(message, colour); 445 445 else 446 callMemberNetworkFunction( GametypeInfo,dispatchStaticMessage, this->getObjectID(), clientID, message, colour);446 callMemberNetworkFunction(&GametypeInfo::dispatchStaticMessage, this->getObjectID(), clientID, message, colour); 447 447 } 448 448 } … … 455 455 this->dispatchFadingMessage(message); 456 456 else 457 callMemberNetworkFunction( GametypeInfo,dispatchFadingMessage, this->getObjectID(), clientID, message);457 callMemberNetworkFunction(&GametypeInfo::dispatchFadingMessage, this->getObjectID(), clientID, message); 458 458 } 459 459 } -
code/trunk/src/orxonox/infos/HumanPlayer.cc
r9667 r10624 160 160 } 161 161 162 void HumanPlayer:: changedGametype()163 { 164 PlayerInfo:: changedGametype();162 void HumanPlayer::switchGametype(Gametype* gametype) 163 { 164 PlayerInfo::switchGametype(gametype); 165 165 166 166 if (this->isInitialized() && this->isLocalPlayer()) -
code/trunk/src/orxonox/infos/HumanPlayer.h
r9667 r10624 51 51 void setClientID(unsigned int clientID); 52 52 53 virtual void changedGametype();53 virtual void switchGametype(Gametype* gametype); 54 54 55 55 inline void setHumanHUDTemplate(const std::string& name) -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r9945 r10624 40 40 namespace orxonox 41 41 { 42 RegisterAbstractClass(PlayerInfo).inheritsFrom (Class(Info));42 RegisterAbstractClass(PlayerInfo).inheritsFrom<Info>(); 43 43 44 44 PlayerInfo::PlayerInfo(Context* context) : Info(context) … … 57 57 this->gtinfo_ = 0; 58 58 this->gtinfoID_ = OBJECTID_UNKNOWN; 59 this->updateGametypeInfo( );59 this->updateGametypeInfo(this->getGametype()); 60 60 61 61 this->registerVariables(); … … 95 95 } 96 96 97 void PlayerInfo::changedGametype() 98 { 99 this->updateGametypeInfo(); 97 void PlayerInfo::switchGametype(Gametype* gametype) 98 { 99 Gametype* oldGametype = this->getGametype(); 100 this->setGametype(StrongPtr<Gametype>(gametype)); 101 Gametype* newGametype = this->getGametype(); 102 103 104 this->updateGametypeInfo(newGametype); 100 105 101 106 if (this->isInitialized()) 102 107 { 103 if ( this->getOldGametype())108 if (oldGametype) 104 109 { 105 if ( this->getGametype())106 this->getOldGametype()->playerSwitched(this, this->getGametype());110 if (newGametype) 111 oldGametype->playerSwitched(this, newGametype); 107 112 else 108 this->getOldGametype()->playerLeft(this);113 oldGametype->playerLeft(this); 109 114 } 110 115 111 if ( this->getGametype())116 if (newGametype) 112 117 { 113 if ( this->getOldGametype())114 this->getGametype()->playerSwitchedBack(this, this->getOldGametype());118 if (oldGametype) 119 newGametype->playerSwitchedBack(this, oldGametype); 115 120 else 116 this->getGametype()->playerEntered(this);121 newGametype->playerEntered(this); 117 122 } 118 123 } 119 124 } 120 125 121 void PlayerInfo::updateGametypeInfo( )126 void PlayerInfo::updateGametypeInfo(Gametype* gametype) 122 127 { 123 128 this->gtinfo_ = 0; 124 129 this->gtinfoID_ = OBJECTID_UNKNOWN; 125 130 126 if ( this->getGametype() && this->getGametype()->getGametypeInfo())127 { 128 this->gtinfo_ = this->getGametype()->getGametypeInfo();131 if (gametype && gametype->getGametypeInfo()) 132 { 133 this->gtinfo_ = gametype->getGametypeInfo(); 129 134 this->gtinfoID_ = this->gtinfo_->getObjectID(); 130 135 } … … 186 191 187 192 this->controllableEntity_->destroyHud(); // HACK-ish 188 this->previousControllableEntity_.push_back( WeakPtr<ControllableEntity>(this->controllableEntity_));193 this->previousControllableEntity_.push_back(this->controllableEntity_); 189 194 this->controllableEntity_ = entity; 190 195 this->controllableEntityID_ = entity->getObjectID(); -
code/trunk/src/orxonox/infos/PlayerInfo.h
r9667 r10624 45 45 46 46 virtual void changedName(); 47 virtual void changedGametype();47 virtual void switchGametype(Gametype* gametype); 48 48 49 49 virtual void changedController() {} … … 94 94 void networkcallback_changedcontrollableentityID(); 95 95 void networkcallback_changedgtinfoID(); 96 void updateGametypeInfo( );96 void updateGametypeInfo(Gametype* gametype); 97 97 98 98 bool bReadyToSpawn_; -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r9667 r10624 50 50 // GametypeMessageListener 51 51 //---------------------------- 52 RegisterAbstractClass(GametypeMessageListener).inheritsFrom (Class(OrxonoxInterface));52 RegisterAbstractClass(GametypeMessageListener).inheritsFrom<OrxonoxInterface>(); 53 53 54 54 GametypeMessageListener::GametypeMessageListener() … … 60 60 // PlayerTrigger 61 61 //---------------------------- 62 RegisterAbstractClass(PlayerTrigger).inheritsFrom (Class(OrxonoxInterface));62 RegisterAbstractClass(PlayerTrigger).inheritsFrom<OrxonoxInterface>(); 63 63 64 64 PlayerTrigger::PlayerTrigger() … … 72 72 { 73 73 assert(pawn); 74 this->pawn_ = WeakPtr<Pawn>(pawn);74 this->pawn_ = pawn; 75 75 if (pawn) 76 this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer());76 this->player_ = pawn->getPlayer(); 77 77 } 78 78 … … 80 80 // RadarListener 81 81 //---------------------------- 82 RegisterAbstractClass(RadarListener).inheritsFrom (Class(OrxonoxInterface));82 RegisterAbstractClass(RadarListener).inheritsFrom<OrxonoxInterface>(); 83 83 84 84 RadarListener::RadarListener() … … 90 90 // TeamColourable 91 91 //---------------------------- 92 RegisterAbstractClass(TeamColourable).inheritsFrom (Class(OrxonoxInterface));92 RegisterAbstractClass(TeamColourable).inheritsFrom<OrxonoxInterface>(); 93 93 94 94 TeamColourable::TeamColourable() … … 100 100 // Rewardable 101 101 //---------------------------- 102 RegisterAbstractClass(Rewardable).inheritsFrom (Class(OrxonoxInterface));102 RegisterAbstractClass(Rewardable).inheritsFrom<OrxonoxInterface>(); 103 103 104 104 Rewardable::Rewardable() -
code/trunk/src/orxonox/interfaces/NotificationListener.cc
r9667 r10624 34 34 #include "core/CoreIncludes.h" 35 35 #include "network/Host.h" 36 #include "network/NetworkFunction .h"36 #include "network/NetworkFunctionIncludes.h" 37 37 #include "util/SubString.h" 38 38 … … 51 51 registerStaticNetworkFunction(NotificationListener::sendHelper); 52 52 53 RegisterAbstractClass(NotificationListener).inheritsFrom<OrxonoxInterface>(); 54 53 55 NotificationListener::NotificationListener() 54 56 { … … 82 84 else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId) 83 85 { 84 callStaticNetworkFunction( NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);86 callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType); 85 87 } 86 88 else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast) 87 89 { 88 90 // TODO: Works as intended? 89 callStaticNetworkFunction( NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);91 callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType); 90 92 } 91 93 } -
code/trunk/src/orxonox/interfaces/PickupCarrier.cc
r9667 r10624 41 41 namespace orxonox 42 42 { 43 RegisterAbstractClass(PickupCarrier).inheritsFrom (Class(OrxonoxInterface));43 RegisterAbstractClass(PickupCarrier).inheritsFrom<OrxonoxInterface>(); 44 44 45 45 /** -
code/trunk/src/orxonox/interfaces/PickupListener.cc
r9667 r10624 40 40 namespace orxonox 41 41 { 42 RegisterAbstractClass(PickupListener).inheritsFrom<OrxonoxInterface>(); 42 43 43 44 /** -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r9667 r10624 46 46 namespace orxonox 47 47 { 48 RegisterAbstractClass(Pickupable).inheritsFrom (Class(OrxonoxInterface)).inheritsFrom(Class(Rewardable));48 RegisterAbstractClass(Pickupable).inheritsFrom<OrxonoxInterface>().inheritsFrom<Rewardable>(); 49 49 50 50 /** -
code/trunk/src/orxonox/interfaces/Pickupable.h
r9667 r10624 187 187 188 188 //! SUPER functions. 189 SUPER_FUNCTION( 10, Pickupable, changedUsed, false);190 SUPER_FUNCTION(1 1, Pickupable, changedCarrier, false);191 SUPER_FUNCTION(1 2, Pickupable, changedPickedUp, false);189 SUPER_FUNCTION(9, Pickupable, changedUsed, false); 190 SUPER_FUNCTION(10, Pickupable, changedCarrier, false); 191 SUPER_FUNCTION(11, Pickupable, changedPickedUp, false); 192 192 } 193 193 -
code/trunk/src/orxonox/interfaces/PlayerTrigger.h
r9667 r10624 63 63 */ 64 64 inline Pawn* getTriggeringPawn(void) const 65 { return this->pawn_ .get(); }65 { return this->pawn_; } 66 66 67 67 /** -
code/trunk/src/orxonox/interfaces/RadarViewable.cc
r9667 r10624 38 38 namespace orxonox 39 39 { 40 RegisterAbstractClass(RadarViewable).inheritsFrom (Class(OrxonoxInterface));40 RegisterAbstractClass(RadarViewable).inheritsFrom<OrxonoxInterface>(); 41 41 42 42 /** -
code/trunk/src/orxonox/interfaces/RadarViewable.h
r9939 r10624 37 37 #include "util/Math.h" 38 38 #include "core/class/OrxonoxInterface.h" 39 #include "core/object/S martPtr.h"39 #include "core/object/StrongPtr.h" 40 40 41 41 namespace orxonox … … 163 163 //Radar 164 164 const WorldEntity* wePtr_; 165 S martPtr<Radar> radar_;165 StrongPtr<Radar> radar_; 166 166 float radarObjectCamouflage_; 167 167 Shape radarObjectShape_; -
code/trunk/src/orxonox/items/ShipPart.cc
r10262 r10624 50 50 51 51 ShipPart::ShipPart(Context* context) 52 : Item(context) 52 : Item(context), parent_(NULL) 53 53 { 54 54 RegisterObject(ShipPart); 55 this->setAlive(true); 56 this->setEventExecution(true); 55 this->eventExecution_ = true; 57 56 this->healthMem_ = 100; 58 57 } … … 60 59 ShipPart::~ShipPart() 61 60 { 62 61 if (this->parent_) 62 { 63 // Remove this ShipPart from the parent. 64 this->parent_->removeShipPart(this); 65 } 63 66 } 64 67 … … 86 89 void ShipPart::death() 87 90 { 88 //if (!(this->isAlive()))89 //return;90 91 91 this->explode(); 92 this->setAlive(false);93 92 94 93 if(eventExecution_) … … 101 100 } 102 101 103 // Remove this ShipPart from the parent. 104 this->parent_->removeShipPart(this); 105 delete this; 102 this->destroyLater(); 106 103 } 107 104 … … 203 200 { 204 201 this->health_ = health; 205 }206 207 void ShipPart::setAlive(bool var)208 {209 this->alive_ = var;210 orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl;211 202 } 212 203 … … 240 231 } 241 232 if (this->health_ < 0) 242 this->alive_ = false; 243 //this->death(); 233 this->death(); 244 234 245 235 // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented. -
code/trunk/src/orxonox/items/ShipPart.h
r10262 r10624 72 72 { return this->parent_; } 73 73 74 void setAlive(bool var);75 inline bool isAlive()76 { return this->alive_; }77 78 74 inline void setEventExecution(bool var) 79 75 { this->eventExecution_ = var; } … … 121 117 std::vector<PartDestructionEvent*> eventList_; // The list of all PartDestructionEvent assigned to this ShipPart. 122 118 123 bool alive_;124 119 bool eventExecution_; 125 120 -
code/trunk/src/orxonox/overlays/InGameConsole.cc
r9667 r10624 45 45 #include "util/Math.h" 46 46 #include "util/DisplayStringConversions.h" 47 #include "util/ScopedSingletonManager.h"48 47 #include "util/output/MemoryWriter.h" 49 48 #include "util/output/OutputManager.h" 50 49 #include "core/CoreIncludes.h" 51 50 #include "core/config/ConfigValueIncludes.h" 52 #include "core/command/ConsoleCommand.h" 51 #include "core/command/ConsoleCommandIncludes.h" 52 #include "core/singleton/ScopedSingletonIncludes.h" 53 53 #include "core/GUIManager.h" 54 54 #include "core/input/InputManager.h" … … 65 65 SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole); 66 66 67 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 67 ManageScopedSingleton(InGameConsole, ScopeID::GRAPHICS, false); 68 69 RegisterAbstractClass(InGameConsole).inheritsFrom<WindowEventListener>().inheritsFrom<UpdateListener>(); 68 70 69 71 /** -
code/trunk/src/orxonox/overlays/InGameConsole.h
r8858 r10624 39 39 #include "core/WindowEventListener.h" 40 40 #include "core/command/Shell.h" 41 #include "core/UpdateListener.h" 41 42 42 43 namespace orxonox 43 44 { 44 class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener 45 class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener, public UpdateListener 45 46 { 46 47 friend class Singleton<InGameConsole>; … … 53 54 54 55 void preUpdate(const Clock& time); 56 void postUpdate(const Clock& time) { /*no action*/ } 55 57 56 58 static void openConsole(); -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r9667 r10624 48 48 #include "core/CoreIncludes.h" 49 49 #include "core/XMLPort.h" 50 #include "core/command/ConsoleCommand .h"50 #include "core/command/ConsoleCommandIncludes.h" 51 51 52 52 #include "OverlayGroup.h" -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r9667 r10624 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 #include "core/command/ConsoleCommand .h"38 #include "core/command/ConsoleCommandIncludes.h" 39 39 #include "OrxonoxOverlay.h" 40 #include "gametypes/Gametype.h" 40 41 41 42 namespace orxonox … … 61 62 OverlayGroup::~OverlayGroup() 62 63 { 63 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)64 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 64 65 (*it)->destroy(); 65 66 this->hudElements_.clear(); … … 85 86 void OverlayGroup::setScale(const Vector2& scale) 86 87 { 87 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)88 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 88 89 (*it)->scale(scale / this->scale_); 89 90 this->scale_ = scale; … … 93 94 void OverlayGroup::setScroll(const Vector2& scroll) 94 95 { 95 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)96 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 96 97 (*it)->scroll(scroll - this->scroll_); 97 98 this->scroll_ = scroll; … … 106 107 void OverlayGroup::addElement(OrxonoxOverlay* element) 107 108 { 108 hudElements_.insert( SmartPtr<OrxonoxOverlay>(element));109 hudElements_.insert(element); 109 110 element->setOverlayGroup( this ); 110 111 if (this->owner_) … … 122 123 bool OverlayGroup::removeElement(OrxonoxOverlay* element) 123 124 { 124 if(this->hudElements_.erase( SmartPtr<OrxonoxOverlay>(element)) == 0)125 if(this->hudElements_.erase(element) == 0) 125 126 return false; 126 127 return true; … … 132 133 if (index < this->hudElements_.size()) 133 134 { 134 std::set< S martPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();135 std::set< StrongPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin(); 135 136 for (unsigned int i = 0; i != index; ++it, ++i) 136 137 ; 137 return it->get();138 return *it; 138 139 } 139 140 else … … 146 147 SUPER( OverlayGroup, changedVisibility ); 147 148 148 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)149 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 149 150 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed 150 151 } 151 152 152 //! Changes the gametype of all elements153 void OverlayGroup::changedGametype()154 {155 SUPER( OverlayGroup, changedGametype );156 157 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)158 (*it)->setGametype(this->getGametype());159 }160 161 153 void OverlayGroup::setOwner(BaseObject* owner) 162 154 { 163 155 this->owner_ = owner; 164 156 165 for (std::set< S martPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)157 for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 166 158 (*it)->setOwner(owner); 167 159 } -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r9667 r10624 65 65 static void scrollGroup(const std::string& name, const Vector2& scroll); 66 66 67 inline const std::set< S martPtr<OrxonoxOverlay> >& getOverlays() const67 inline const std::set< StrongPtr<OrxonoxOverlay> >& getOverlays() const 68 68 { return this->hudElements_; } 69 69 70 70 virtual void changedVisibility(); 71 virtual void changedGametype();72 71 73 72 void setOwner(BaseObject* owner); … … 92 91 93 92 private: 94 std::set< S martPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group.93 std::set< StrongPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 95 94 Vector2 scale_; //!< Current scale (independent of the elements). 96 95 Vector2 scroll_; //!< Current scrolling offset. -
code/trunk/src/orxonox/sound/AmbientSound.cc
r9939 r10624 36 36 namespace orxonox 37 37 { 38 RegisterAbstractClass(AmbientSound).inheritsFrom<BaseSound>().inheritsFrom<MoodListener>(); 39 38 40 AmbientSound::AmbientSound() 39 41 : bPlayOnLoad_(false) … … 49 51 if (GameMode::playsSound()) 50 52 { 51 // Smoothly fade out by keeping a S martPtr53 // Smoothly fade out by keeping a StrongPtr 52 54 SoundManager::getInstance().unregisterAmbientSound(this); 53 55 } -
code/trunk/src/orxonox/sound/BaseSound.cc
r9939 r10624 43 43 namespace orxonox 44 44 { 45 RegisterAbstractClass(BaseSound).inheritsFrom (Class(Listable));45 RegisterAbstractClass(BaseSound).inheritsFrom<Listable>(); 46 46 47 47 BaseSound::BaseSound() -
code/trunk/src/orxonox/sound/SoundBuffer.h
r6764 r10624 46 46 friend class SoundManager; 47 47 #if !defined(_MSC_VER) || _MSC_VER >= 1500 48 // Make sure nobody deletes an instance (using s martpointers)48 // Make sure nobody deletes an instance (using strong pointers) 49 49 template <class T> 50 50 friend void boost::checked_delete(T*); -
code/trunk/src/orxonox/sound/SoundManager.cc
r9939 r10624 38 38 #include "util/Math.h" 39 39 #include "util/Clock.h" 40 #include " util/ScopedSingletonManager.h"40 #include "core/singleton/ScopedSingletonIncludes.h" 41 41 #include "core/config/ConfigValueIncludes.h" 42 42 #include "core/CoreIncludes.h" … … 50 50 namespace orxonox 51 51 { 52 ManageScopedSingleton(SoundManager, ScopeID::G raphics, true);52 ManageScopedSingleton(SoundManager, ScopeID::GRAPHICS, true); 53 53 54 54 std::string SoundManager::getALErrorString(ALenum code) … … 65 65 } 66 66 } 67 68 RegisterAbstractClass(SoundManager).inheritsFrom<Configurable>().inheritsFrom<UpdateListener>(); 67 69 68 70 SoundManager::SoundManager() … … 163 165 SoundManager::~SoundManager() 164 166 { 165 // Erase fade lists because of the s martpointers167 // Erase fade lists because of the strong pointers 166 168 this->bDestructorCalled_ = true; 167 169 this->fadeInList_.clear(); … … 417 419 } 418 420 419 void SoundManager::fadeIn( const SmartPtr<AmbientSound>&sound)421 void SoundManager::fadeIn(AmbientSound* sound) 420 422 { 421 423 // If we're already fading out --> remove that 422 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)424 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++) 423 425 { 424 426 if (*it == sound) … … 433 435 } 434 436 435 void SoundManager::fadeOut( const SmartPtr<AmbientSound>&sound)437 void SoundManager::fadeOut(AmbientSound* sound) 436 438 { 437 439 // If we're already fading in --> remove that 438 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)440 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++) 439 441 { 440 442 if (*it == sound) … … 459 461 460 462 // FADE IN 461 for (std::list<S martPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )463 for (std::list<StrongPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); ) 462 464 { 463 465 if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f) … … 474 476 475 477 // FADE OUT 476 for (std::list<S martPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )478 for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); ) 477 479 { 478 480 if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f) -
code/trunk/src/orxonox/sound/SoundManager.h
r9667 r10624 40 40 #include "util/Singleton.h" 41 41 #include "core/config/Configurable.h" 42 #include "core/object/SmartPtr.h" 42 #include "core/object/StrongPtr.h" 43 #include "core/UpdateListener.h" 43 44 44 45 // tolua_begin … … 59 60 class _OrxonoxExport SoundManager 60 61 // tolua_end 61 : public Singleton<SoundManager>, public Configurable 62 : public Singleton<SoundManager>, public Configurable, public UpdateListener 62 63 { // tolua_export 63 64 friend class Singleton<SoundManager>; … … 68 69 69 70 void preUpdate(const Clock& time); 71 void postUpdate(const Clock& time) { /*no action*/ } 70 72 void setConfigValues(); 71 73 … … 104 106 private: 105 107 void processCrossFading(float dt); 106 void fadeIn( const SmartPtr<AmbientSound>&sound);107 void fadeOut( const SmartPtr<AmbientSound>&sound);108 void fadeIn(AmbientSound* sound); 109 void fadeOut(AmbientSound* sound); 108 110 109 111 void checkFadeStepValidity(); … … 127 129 //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading 128 130 float crossFadeStep_; 129 std::list<S martPtr<AmbientSound> > fadeInList_;130 std::list<S martPtr<AmbientSound> > fadeOutList_;131 std::list<StrongPtr<AmbientSound> > fadeInList_; 132 std::list<StrongPtr<AmbientSound> > fadeOutList_; 131 133 132 134 // Volume related -
code/trunk/src/orxonox/sound/WorldAmbientSound.cc
r9945 r10624 33 33 #include "core/XMLPort.h" 34 34 #include "AmbientSound.h" 35 #include "core/command/ConsoleCommand .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 36 #include <exception> 37 37 -
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
r9939 r10624 45 45 namespace orxonox 46 46 { 47 RegisterAbstractClass(WeaponMode).inheritsFrom (Class(BaseObject));47 RegisterAbstractClass(WeaponMode).inheritsFrom<BaseObject>(); 48 48 49 49 WeaponMode::WeaponMode(Context* context) : BaseObject(context) -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r9799 r10624 36 36 #include "core/GameMode.h" 37 37 #include "core/XMLPort.h" 38 #include "network/NetworkFunction .h"38 #include "network/NetworkFunctionIncludes.h" 39 39 40 40 #include "Scene.h" … … 108 108 this->camera_->destroy(); 109 109 110 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)110 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 111 111 (*it)->destroy(); 112 112 … … 165 165 { 166 166 unsigned int i = 0; 167 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)167 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 168 168 { 169 169 if (i == index) … … 180 180 181 181 unsigned int counter = 0; 182 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)182 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 183 183 { 184 184 if ((*it) == this->currentCameraPosition_) … … 215 215 { 216 216 this->cameraPositions_.front()->attachCamera(this->camera_); 217 this->currentCameraPosition_ = this->cameraPositions_.front() .get();217 this->currentCameraPosition_ = this->cameraPositions_.front(); 218 218 } 219 219 else if (this->cameraPositions_.size() > 0) 220 220 { 221 for (std::list<S martPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)221 for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 222 222 { 223 223 if ((*it) == this->camera_->getParent()) … … 307 307 else 308 308 { 309 callMemberNetworkFunction( ControllableEntity,fire, this->getObjectID(), 0, firemode);309 callMemberNetworkFunction(&ControllableEntity::fire, this->getObjectID(), 0, firemode); 310 310 } 311 311 } … … 323 323 if ( target != 0 ) 324 324 { 325 callMemberNetworkFunction( ControllableEntity,setTargetInternal, this->getObjectID(), 0, target->getObjectID() );325 callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, target->getObjectID() ); 326 326 } 327 327 else 328 328 { 329 callMemberNetworkFunction( ControllableEntity,setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );329 callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN ); 330 330 } 331 331 } … … 477 477 if (parent) 478 478 { 479 for (std::list<S martPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)479 for (std::list<StrongPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 480 480 if ((*it)->getIsAbsolute()) 481 481 parent->attach((*it)); -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r10437 r10624 121 121 void addCameraPosition(CameraPosition* position); 122 122 CameraPosition* getCameraPosition(unsigned int index) const; 123 inline const std::list<S martPtr<CameraPosition> >& getCameraPositions() const123 inline const std::list<StrongPtr<CameraPosition> >& getCameraPositions() const 124 124 { return this->cameraPositions_; } 125 125 unsigned int getCurrentCameraIndex() const; … … 162 162 163 163 inline Controller* getController() const 164 { return this->controller_ .get(); }164 { return this->controller_; } 165 165 void setController(Controller* val); 166 166 … … 168 168 virtual void setTarget( WorldEntity* target ); 169 169 virtual WorldEntity* getTarget() 170 { return this->target_ .get(); }170 { return this->target_; } 171 171 void setTargetInternal( uint32_t targetID ); 172 172 … … 242 242 bool bMouseLook_; 243 243 float mouseLookSpeed_; 244 std::list<S martPtr<CameraPosition> > cameraPositions_;244 std::list<StrongPtr<CameraPosition> > cameraPositions_; 245 245 CameraPosition* currentCameraPosition_; 246 246 std::string cameraPositionTemplate_; -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r10288 r10624 61 61 BOOST_STATIC_ASSERT((int)Ogre::Node::TS_WORLD == (int)WorldEntity::World); 62 62 63 RegisterAbstractClass(WorldEntity).inheritsFrom (Class(BaseObject)).inheritsFrom(Class(Synchronisable));63 RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>(); 64 64 65 65 /** … … 130 130 WorldEntity* entity = *it; 131 131 132 // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to s martpointers pointing to it132 // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to strong pointers pointing to it 133 133 entity->setPosition(entity->getWorldPosition()); 134 134 this->detach(entity); // detach also erases the element from the children set -
code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc
r9667 r10624 40 40 RegisterObject(Destroyer); 41 41 42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype() .get());42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype()); 43 43 if (gametype) 44 44 { -
code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10270 r10624 37 37 #include "util/Math.h" 38 38 #include "gametypes/Gametype.h" 39 #include "core/command/ConsoleCommand .h"39 #include "core/command/ConsoleCommandIncludes.h" 40 40 41 41 #include "items/ShipPart.h" … … 69 69 if (this->isInitialized()) 70 70 { 71 71 while (!this->partList_.empty()) 72 this->partList_[0]->destroy(); 72 73 } 73 74 } … … 177 178 if (it->second->getName() == name) 178 179 { 179 it->second-> setAlive(false);180 it->second->death(); 180 181 return; 181 182 } … … 196 197 if (it->second->getName() == name) 197 198 { 198 it->second-> setAlive(false);199 it->second->death(); 199 200 return; 200 201 } -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r10622 r10624 326 326 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 327 327 { 328 // Set bAlive_ to false and wait for PawnManagerto do the destruction328 // Set bAlive_ to false and wait for destroyLater() to do the destruction 329 329 this->bAlive_ = false; 330 this->destroyLater(); 330 331 331 332 this->setDestroyWhenPlayerLeft(false); -
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r9667 r10624 34 34 #include "core/GameMode.h" 35 35 #include "core/command/CommandExecutor.h" 36 #include "core/command/ConsoleCommand .h"36 #include "core/command/ConsoleCommandIncludes.h" 37 37 38 38 #include "tools/BillboardSet.h" -
code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r9667 r10624 45 45 this->state_ = BaseState::Uncontrolled; 46 46 47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype() .get());47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype()); 48 48 if (gametype) 49 49 { … … 58 58 this->fireEvent(); 59 59 60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype() .get());60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype()); 61 61 if (!gametype) 62 62 return;
Note: See TracChangeset
for help on using the changeset viewer.