Changeset 888 for code/branches/network/src/orxonox
- Timestamp:
- Mar 13, 2008, 3:25:10 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/Orxonox.cc
r871 r888 63 63 #include "network/Server.h" 64 64 #include "network/Client.h" 65 #include "network/NetworkFrameListener.h" 65 #include "network/NetworkPrereqs.h" 66 network::Client *client_g; 67 network::Server *server_g; 68 66 69 67 70 // objects … … 97 100 updateAI(); 98 101 99 if(mode_ == PRESENTATION)100 server_g->tick(evt.timeSinceLastFrame);101 else if(mode_ == CLIENT)102 client_g->tick(evt.timeSinceLastFrame);102 // if(mode_ == SERVER) 103 // server_g->tick(evt.timeSinceLastFrame); 104 // else if(mode_ == CLIENT) 105 // client_g->tick(evt.timeSinceLastFrame); 103 106 104 107 usleep(10); … … 162 165 //TODO: give config file to Ogre 163 166 std::string mode; 164 // if(argc>=2) 165 // mode = std::string(argv[1]); 166 // else 167 // mode = ""; 167 168 168 169 ArgReader ar = ArgReader(argc, argv); 169 170 ar.checkArgument("mode", mode, false); 170 171 ar.checkArgument("data", this->dataPath_, false); 171 172 ar.checkArgument("ip", serverIp_, false); 172 //mode = "presentation";173 173 if(ar.errorHandling()) die(); 174 if(mode == std::string(" server"))174 if(mode == std::string("client")) 175 175 { 176 mode_ = CLIENT; 177 clientInit(path); 178 } 179 else if(mode== std::string("server")){ 180 mode_ = SERVER; 176 181 serverInit(path); 177 mode_ = SERVER;178 }179 else if(mode == std::string("client"))180 {181 clientInit(path);182 mode_ = CLIENT;183 }184 else if(mode == std::string("presentation"))185 {186 serverInit(path);187 mode_ = PRESENTATION;188 182 } 189 183 else{ 184 mode_ = STANDALONE; 190 185 standaloneInit(path); 191 mode_ = STANDALONE;192 193 } 194 186 } 187 } 188 189 195 190 /** 196 191 * start modules … … 198 193 void Orxonox::start() 199 194 { 195 switch(mode_){ 196 case CLIENT: 197 clientStart(); 198 break; 199 case SERVER: 200 serverStart(); 201 break; 202 default: 203 standaloneStart(); 204 } 205 } 206 207 void Orxonox::clientStart(){ 208 209 210 } 211 212 void Orxonox::serverStart(){ 200 213 //TODO: start modules 201 214 ogre_->startRender(); … … 205 218 setupScene(); 206 219 setupInputSystem(); 207 if(mode_!=CLIENT){ // remove this in future ---- presentation hack 208 } 209 else 210 std::cout << "client here" << std::endl; 220 211 221 createFrameListener(); 212 switch(mode_){ 213 case PRESENTATION: 214 //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); 215 //std::cout << "could not add framelistener" << std::endl; 216 server_g->open(); 217 break; 218 case CLIENT: 219 client_g->establishConnection(); 220 break; 221 case SERVER: 222 case STANDALONE: 223 default: 224 break; 225 } 222 server_g->open(); 223 224 startRenderLoop(); 225 } 226 227 void Orxonox::standaloneStart(){ 228 //TODO: start modules 229 ogre_->startRender(); 230 //TODO: run engine 231 Factory::createClassHierarchy(); 232 createScene(); 233 setupScene(); 234 setupInputSystem(); 235 236 createFrameListener(); 237 226 238 startRenderLoop(); 227 239 } … … 246 258 } 247 259 248 void Orxonox::standaloneInit(std::string path) 249 { 260 261 void Orxonox::serverInit(std::string path) 262 { 263 COUT(2) << "initialising server" << std::endl; 264 250 265 ogre_->setConfigPath(path); 251 266 ogre_->setup(); 252 267 root_ = ogre_->getRoot(); 253 268 if(!ogre_->load()) die(/* unable to load */); 254 255 //defineResources(); 256 //setupRenderSystem(); 257 //createRenderWindow(); 258 //initializeResourceGroups(); 259 /*createScene(); 260 setupScene(); 261 setupInputSystem(); 262 createFrameListener(); 263 Factory::createClassHierarchy(); 264 startRenderLoop();*/ 265 } 266 267 void Orxonox::playableServer(std::string path) 268 { 269 ogre_->setConfigPath(path); 270 ogre_->setup(); 271 root_ = ogre_->getRoot(); 272 defineResources(); 273 setupRenderSystem(); 274 createRenderWindow(); 275 initializeResourceGroups(); 276 setupInputSystem(); 277 Factory::createClassHierarchy(); 278 createScene(); 279 setupScene(); 280 createFrameListener(); 281 try{ 282 server_g = new network::Server(); //!< add port and bindadress 283 server_g->open(); //!< open server and create listener thread 284 if(ogre_ && ogre_->getRoot()) 285 ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server 286 COUT(3) << "Info: network framelistener added" << std::endl; 287 } 288 catch(...) 289 { 290 COUT(1) << "Error: There was a problem initialising the server :(" << std::endl; 291 } 292 startRenderLoop(); 293 } 294 295 void Orxonox::standalone(){ 296 297 298 299 } 300 301 void Orxonox::serverInit(std::string path) 302 { 303 COUT(2) << "initialising server" << std::endl; 304 ogre_->setConfigPath(path); 305 ogre_->setup(); 306 server_g = new network::Server(); // FIXME add some settings if wanted 307 if(!ogre_->load()) die(/* unable to load */); 308 // FIXME add network framelistener 269 270 server_g = new network::Server(); 309 271 } 310 272 311 273 void Orxonox::clientInit(std::string path) 312 274 { 313 COUT(2) << "initialising client" << std::endl; 275 COUT(2) << "initialising client" << std::endl;\ 276 314 277 ogre_->setConfigPath(path); 315 278 ogre_->setup(); … … 317 280 client_g = new network::Client(); 318 281 else 319 client_g = new network::Client(serverIp_, 55556);282 client_g = new network::Client(serverIp_, NETWORK_PORT); 320 283 if(!ogre_->load()) die(/* unable to load */); 321 ogre_->getRoot()->addFrameListener(new network::ClientFrameListener()); 284 } 285 286 void Orxonox::standaloneInit(std::string path) 287 { 288 COUT(2) << "initialising standalone mode" << std::endl; 289 290 ogre_->setConfigPath(path); 291 ogre_->setup(); 292 root_ = ogre_->getRoot(); 293 if(!ogre_->load()) die(/* unable to load */); 322 294 } 323 295 -
code/branches/network/src/orxonox/Orxonox.h
r871 r888 25 25 26 26 enum gameMode{ 27 STANDALONE,28 27 SERVER, 29 28 CLIENT, 30 PRESENTATION29 STANDALONE 31 30 }; 32 31 … … 54 53 void standaloneInit(std::string path); 55 54 // run functions 56 void playableServer(std::string path); 57 void standalone(); 55 void serverStart(); 56 void clientStart(); 57 void standaloneStart(); 58 58 void defineResources(); 59 59 void setupRenderSystem(); -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r871 r888 196 196 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 197 197 SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds"); 198 SetConfigValue(testvector_, Vector3()).description("asdfblah");198 //SetConfigValue(testvector_, Vector3()).description("asdfblah"); 199 199 } 200 200
Note: See TracChangeset
for help on using the changeset viewer.