Changeset 888 for code/branches/network
- Timestamp:
- Mar 13, 2008, 3:25:10 PM (17 years ago)
- Location:
- code/branches/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/bin/levels/sample.oxw
r887 r888 1 1 <!-- 2 <audio> sdfasdfasd2 <audio> 3 3 <ambient> 4 4 <ogg src="allgorythm-lift_up" /> … … 15 15 16 16 <!--Fighter camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" forward="500" rotateupdown="200" rotaterightleft="200" looprightleft="200" /--> 17 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf 5.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />17 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> 18 18 19 19 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/> … … 23 23 <NPC position="100,0,400" scale="1" mesh="razor.mesh"/> 24 24 25 < Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" />26 < Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">25 <!--Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /--> 26 <!--Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> 27 27 <attached> 28 28 <Model name="drone2" position="200,-100,-500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> … … 32 32 </Model> 33 33 </attached> 34 </Model >34 </Model --> 35 35 36 36 <Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" /> -
code/branches/network/src/network/Client.h
r790 r888 16 16 #include <string> 17 17 18 #include "orxonox/objects/Tickable.h" 19 18 20 #include "NetworkPrereqs.h" 19 21 #include "ClientConnection.h" … … 21 23 #include "GameStateClient.h" 22 24 //#include "NetworkFrameListener.h" 25 23 26 24 27 … … 32 35 * 33 36 */ 34 class _NetworkExport Client : PacketDecoder {37 class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{ 35 38 public: 36 39 Client(); -
code/branches/network/src/network/ConnectionManager.cc
r790 r888 281 281 } 282 282 283 284 285 void ConnectionManager::addClientsObjectID( int clientID, int objectID ) { 286 COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl; 287 clientsShip.insert( std::make_pair( clientID, objectID ) ); 288 } 289 290 int ConnectionManager::getClientsShipID( int clientID ) { 291 return clientsShip[clientID]; 292 } 293 294 int ConnectionManager::getObjectsClientID( int objectID ) { 295 std::map<int, int>::iterator iter = clientsShip.begin(); 296 while( iter != clientsShip.end() ) { 297 if( iter->second == objectID ) return iter->first; 298 } 299 return -99; 300 } 301 302 void ConnectionManager::deleteClientIDReg( int clientID ) { 303 clientsShip.erase( clientID ); 304 } 305 306 void ConnectionManager::deleteObjectIDReg( int objectID ) { 307 std::map<int, int>::iterator iter = clientsShip.begin(); 308 while( iter != clientsShip.end() ) { 309 if( iter->second == objectID ) break; 310 } 311 clientsShip.erase( iter->first ); 312 } 313 283 314 } -
code/branches/network/src/network/ConnectionManager.h
r790 r888 14 14 15 15 #include <string> 16 #include <map> 16 17 // enet library for networking support 17 18 #include <enet/enet.h> … … 73 74 bool quit; // quit-variable (communication with threads) 74 75 ClientInformation *head_; 76 77 //functions to map what object every clients uses 78 std::map<int, int> clientsShip; 79 void addClientsObjectID( int clientID, int objectID ); 80 int getClientsShipID( int clientID ); 81 int getObjectsClientID( int objectID ); 82 void deleteClientIDReg( int clientID ); 83 void deleteObjectIDReg( int objectID ); 75 84 }; 76 85 -
code/branches/network/src/network/Server.h
r790 r888 16 16 #include <string> 17 17 18 #include "orxonox/objects/Tickable.h" 19 18 20 #include "PacketManager.h" 19 21 #include "NetworkPrereqs.h" 22 23 20 24 21 25 namespace network … … 25 29 * It implements all functions necessary for a Server 26 30 */ 27 class _NetworkExport Server : public PacketDecoder {31 class _NetworkExport Server : public PacketDecoder, public orxonox::Tickable{ 28 32 public: 29 33 Server(); -
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.