Changeset 2344 for code/branches/objecthierarchy2/src/orxonox
- Timestamp:
- Dec 4, 2008, 8:28:14 PM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/LevelManager.cc
r2173 r2344 42 42 assert(singletonRef_s == 0); 43 43 singletonRef_s = this; 44 45 PlayerManager::getInstance(); // ensure existence of PlayerManager46 44 } 47 45 -
code/branches/objecthierarchy2/src/orxonox/Main.cc
r2103 r2344 43 43 #include "core/ConfigFileManager.h" 44 44 #include "core/CommandLine.h" 45 #include "core/CommandExecutor.h" 46 #include "core/Identifier.h" 47 #include "core/Core.h" 48 #include "core/Language.h" 45 49 46 50 #include "gamestates/GSRoot.h" … … 92 96 93 97 // create a signal handler (only works for linux) 94 SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); 98 SignalHandler signalHandler; 99 signalHandler.doCatch(argv[0], "orxonox.log"); 95 100 96 101 // Parse command line arguments … … 109 114 ConfigFileManager* configFileManager = new ConfigFileManager(); 110 115 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString()); 116 // create the Core settings to configure the output level 117 Language* language = new Language(); 118 Core* core = new Core(); 111 119 112 // create the gamestates 113 GSRoot root; 114 GSGraphics graphics; 115 GSStandalone standalone; 116 GSServer server; 117 GSClient client; 118 GSDedicated dedicated; 119 GSGUI gui; 120 GSIOConsole ioConsole; 120 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 121 { 122 // create the gamestates 123 GSRoot root; 124 GSGraphics graphics; 125 GSStandalone standalone; 126 GSServer server; 127 GSClient client; 128 GSDedicated dedicated; 129 GSGUI gui; 130 GSIOConsole ioConsole; 121 131 122 // make the hierarchy123 root.addChild(&graphics);124 graphics.addChild(&standalone);125 graphics.addChild(&server);126 graphics.addChild(&client);127 graphics.addChild(&gui);128 root.addChild(&ioConsole);129 root.addChild(&dedicated);132 // make the hierarchy 133 root.addChild(&graphics); 134 graphics.addChild(&standalone); 135 graphics.addChild(&server); 136 graphics.addChild(&client); 137 graphics.addChild(&gui); 138 root.addChild(&ioConsole); 139 root.addChild(&dedicated); 130 140 131 // Here happens the game 132 root.start(); 141 // Here happens the game 142 root.start(); 143 } 133 144 134 // Destroy ConfigFileManager again. 145 // destroy singletons 146 delete core; 147 delete language; 135 148 delete configFileManager; 149 150 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 151 Identifier::destroyAllIdentifiers(); 152 // destroy command line arguments 153 CommandLine::destroyAllArguments(); 154 // Also delete external console command that don't belong to an Identifier 155 CommandExecutor::destroyExternalCommands(); 136 156 137 157 return 0; -
code/branches/objecthierarchy2/src/orxonox/PlayerManager.cc
r2171 r2344 38 38 namespace orxonox 39 39 { 40 PlayerManager* PlayerManager::singletonRef_s = 0; 41 40 42 PlayerManager::PlayerManager() 41 43 { 42 44 RegisterRootObject(PlayerManager); 45 46 assert(singletonRef_s == 0); 47 singletonRef_s = this; 43 48 44 49 this->getConnectedClients(); … … 47 52 PlayerManager::~PlayerManager() 48 53 { 49 } 50 51 PlayerManager& PlayerManager::getInstance() 52 { 53 static PlayerManager instance; 54 return instance; 54 assert(singletonRef_s); 55 singletonRef_s = 0; 55 56 } 56 57 -
code/branches/objecthierarchy2/src/orxonox/PlayerManager.h
r2171 r2344 43 43 virtual ~PlayerManager(); 44 44 45 static PlayerManager& getInstance(); 45 static PlayerManager& getInstance() 46 { assert(singletonRef_s); return *singletonRef_s; } 46 47 47 48 PlayerInfo* getClient(unsigned int clientID) const; … … 54 55 55 56 std::map<unsigned int, PlayerInfo*> clients_; 57 58 static PlayerManager* singletonRef_s; 56 59 }; 57 60 } -
code/branches/objecthierarchy2/src/orxonox/Settings.cc
r2087 r2344 83 83 } 84 84 85 LuaBind::getInstance() ->setIncludePath(this->dataPath_);85 LuaBind::getInstance().setIncludePath(this->dataPath_); 86 86 } 87 87 -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSGraphics.cc
r2171 r2344 164 164 FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen); 165 165 functor1->setObject(this); 166 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen")); 166 ccPrintScreen_ = createConsoleCommand(functor1, "printScreen"); 167 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 167 168 } 168 169 … … 170 171 { 171 172 using namespace Ogre; 173 174 delete this->ccPrintScreen_; 172 175 173 176 // remove our WindowEventListener first to avoid bad calls after the window has been destroyed -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSGraphics.h
r2103 r2344 112 112 unsigned int detailLevelParticle_; //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high) 113 113 std::string defaultMasterKeybindings_; //!< Filename of default master keybindings. 114 115 // console commands 116 ConsoleCommand* ccPrintScreen_; 114 117 }; 115 118 } -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.cc
r2173 r2344 47 47 #include "CameraManager.h" 48 48 #include "LevelManager.h" 49 #include "PlayerManager.h" 49 50 #include "Settings.h" 50 51 … … 99 100 // create the global LevelManager 100 101 this->levelManager_ = new LevelManager(); 102 this->playerManager_ = new PlayerManager(); 101 103 102 104 // reset game speed to normal … … 114 116 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); 115 117 functor1->setObject(this); 116 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind")); 118 ccKeybind_ = createConsoleCommand(functor1, "keybind"); 119 CommandExecutor::addConsoleCommandShortcut(ccKeybind_); 117 120 FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind); 118 121 functor2->setObject(this); 119 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind")); 122 ccTkeybind_ = createConsoleCommand(functor2, "tkeybind"); 123 CommandExecutor::addConsoleCommandShortcut(ccTkeybind_); 120 124 // set our console command as callback for the key detector 121 125 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); … … 130 134 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 131 135 functor->setObject(this); 132 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 136 ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 137 CommandExecutor::addConsoleCommandShortcut(ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 133 138 } 134 139 } … … 136 141 void GSLevel::leave() 137 142 { 143 // destroy console commands 144 delete this->ccKeybind_; 145 delete this->ccSetTimeFactor_; 146 delete this->ccTkeybind_; 147 138 148 // this call will delete every BaseObject! 139 149 // But currently this will call methods of objects that exist no more … … 156 166 if (this->levelManager_) 157 167 delete this->levelManager_; 168 169 if (this->playerManager_) 170 delete this->playerManager_; 158 171 159 172 if (Core::showsGraphics()) -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.h
r2103 r2344 70 70 CameraManager* cameraManager_; 71 71 LevelManager* levelManager_; 72 PlayerManager* playerManager_; 72 73 73 74 //##### ConfigValues ##### … … 75 76 //! Filename of default keybindings. 76 77 std::string defaultKeybindings_; 78 79 // console commands 80 ConsoleCommand* ccKeybind_; 81 ConsoleCommand* ccTkeybind_; 82 ConsoleCommand* ccSetTimeFactor_; 77 83 78 84 private: -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc
r2171 r2344 40 40 #include "core/TclBind.h" 41 41 #include "core/TclThreadManager.h" 42 #include "core/LuaBind.h" 42 43 #include "tools/Timer.h" 43 44 #include "objects/Tickable.h" … … 87 88 // creates the class hierarchy for all classes with factories 88 89 Factory::createClassHierarchy(); 90 91 // Create the lua interface 92 this->luaBind_ = new LuaBind(); 89 93 90 94 // instantiate Settings class … … 117 121 FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame); 118 122 functor1->setObject(this); 119 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit")); 123 ccExit_ = createConsoleCommand(functor1, "exit"); 124 CommandExecutor::addConsoleCommandShortcut(ccExit_); 120 125 121 126 // add console commands 122 127 FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState); 123 128 functor2->setObject(this); 124 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState")); 129 ccSelectGameState_ = createConsoleCommand(functor2, "selectGameState"); 130 CommandExecutor::addConsoleCommandShortcut(ccSelectGameState_); 125 131 } 126 132 127 133 void GSRoot::leave() 128 134 { 129 // TODO: remove and destroy console commands 135 // destroy console commands 136 delete this->ccExit_; 137 delete this->ccSelectGameState_; 130 138 131 139 delete this->shell_; … … 133 141 delete this->tclBind_; 134 142 135 delete settings_;136 143 delete this->settings_; 144 delete this->luaBind_; 137 145 } 138 146 -
code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.h
r1891 r2344 59 59 TclThreadManager* tclThreadManager_; 60 60 Shell* shell_; 61 LuaBind* luaBind_; 62 63 // console commands 64 ConsoleCommand* ccExit_; 65 ConsoleCommand* ccSelectGameState_; 61 66 }; 62 67 } -
code/branches/objecthierarchy2/src/orxonox/gui/GUIManager.cc
r2087 r2344 96 96 { 97 97 // destroy our own tolua interfaces 98 //lua_pushnil(luaState_);99 //lua_setglobal(luaState_, "Orxonox");100 //lua_pushnil(luaState_);101 //lua_setglobal(luaState_, "Core");98 lua_pushnil(luaState_); 99 lua_setglobal(luaState_, "Orxonox"); 100 lua_pushnil(luaState_); 101 lua_setglobal(luaState_, "Core"); 102 102 // TODO: deleting the script module fails an assertation. 103 103 // However there is not much we can do about it since it occurs too when 104 104 // we don't open Core or Orxonox. Might be a CEGUI issue. 105 105 // The memory leak is not a problem anyway.. 106 //delete scriptModule_;106 delete scriptModule_; 107 107 } 108 108 -
code/branches/objecthierarchy2/src/orxonox/objects/Script.cc
r2087 r2344 64 64 void Script::execute() 65 65 { 66 LuaBind *lua = LuaBind::getInstance();67 lua ->loadString(this->code_);68 lua ->run();66 LuaBind& lua = LuaBind::getInstance(); 67 lua.loadString(this->code_); 68 lua.run(); 69 69 } 70 70 }
Note: See TracChangeset
for help on using the changeset viewer.