Changeset 1232 for code/branches/network3/src
- Timestamp:
- May 5, 2008, 1:19:22 AM (17 years ago)
- Location:
- code/branches/network3/src
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/Client.cc
r1199 r1232 40 40 41 41 #include "Client.h" 42 #include "Synchronisable.h" 42 43 #include "core/CoreIncludes.h" 43 44 … … 47 48 48 49 Client* Client::createSingleton(){ 49 if(!_sClient) 50 if(!_sClient){ 50 51 _sClient = new Client(); 52 } 51 53 return _sClient; 52 54 } … … 112 114 */ 113 115 bool Client::establishConnection(){ 116 Synchronisable::setClient(true); 114 117 isConnected=client_connection.createConnection(); 118 /*if(isConnected){ 119 COUT(2) << "sending connectrequest" << std::endl; 120 client_connection.addPacket(pck_gen.generateConnectRequest()); 121 client_connection.sendPackets(); 122 }else 123 COUT(2) << "could not create connection" << std::endl;*/ 115 124 return isConnected; 116 125 } … … 249 258 COUT(0) << "Server: " << data->message << std::endl; 250 259 } 260 261 bool Client::processWelcome( welcome *w ){ 262 COUT(4) << "processing welcome message" << std::endl; 263 clientID_ = w->clientID; 264 shipID_ = w->shipID; 265 266 } 251 267 252 268 } -
code/branches/network3/src/network/Client.h
r1184 r1232 83 83 84 84 bool sendPackets(); 85 86 int getShipID(){return shipID_;} 87 int getClientID(){return clientID_;} 85 88 86 89 void tick(float time); … … 103 106 void processClassid(classid *clid); 104 107 void processChat( chat *data); 108 bool processWelcome( welcome *w ); 109 int clientID_; // this is the id the server gave to us 110 int shipID_; 105 111 }; 106 112 -
code/branches/network3/src/network/ClientInformation.h
r1168 r1232 67 67 ClientInformation *insertBefore(ClientInformation *ins); 68 68 ClientInformation *insertBack(ClientInformation *ins); 69 70 // set functions 69 71 void setID(int clientID); 70 72 void setPeer(ENetPeer *peer); 71 73 void setGamestateID(int id); 74 inline void setShipID(int id){ShipID_=id;} 75 76 // get functions 77 inline int getShipID(){return ShipID_;} 72 78 int getID(); 79 int getGamestateID(); 73 80 ENetPeer *getPeer(); 74 int getGamestateID(); 81 82 75 83 bool removeClient(int clientID); 76 84 bool removeClient(ENetPeer *peer); … … 92 100 int clientID_; 93 101 int gamestateID_; 102 int ShipID_; // this is the unique objectID 94 103 bool synched_; 95 104 }; -
code/branches/network3/src/network/ConnectionManager.cc
r1168 r1232 44 44 45 45 #include "core/CoreIncludes.h" 46 #include "core/BaseObject.h" 47 #include "util/Math.h" 48 #include "objects/SpaceShip.h" 46 49 #include "ClientInformation.h" 47 50 #include "ConnectionManager.h" 51 #include "Synchronisable.h" 48 52 49 53 namespace std … … 179 183 case ENET_EVENT_TYPE_CONNECT: 180 184 addClient(&event); 185 //this is a workaround to ensure thread safety 186 if(!addFakeConnectRequest(&event)) 187 COUT(3) << "Problem pushing fakeconnectRequest to queue" << std::endl; 181 188 COUT(5) << "Con.Man: connection event has occured" << std::endl; 182 189 break; … … 237 244 } 238 245 239 //bool ConnectionManager::clientDisconnect(ENetPeer *peer) {240 // return clientDisconnect(*peer);241 //}242 243 246 bool ConnectionManager::clientDisconnect(ENetPeer *peer) { 244 247 COUT(4) << "removing client from list" << std::endl; … … 260 263 temp->setPeer(event->peer); 261 264 COUT(4) << "Con.Man: added client id: " << temp->getID() << std::endl; 262 syncClassid(temp->getID());263 temp->setSynched(true);264 265 return true; 265 266 } … … 298 299 } 299 300 300 301 302 void ConnectionManager::addClientsObjectID( int clientID, int objectID ) { 303 COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl; 304 clientsShip.insert( std::make_pair( clientID, objectID ) ); 305 } 301 bool ConnectionManager::createClient(int clientID){ 302 ClientInformation *temp = head_->findClient(clientID); 303 COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl; 304 syncClassid(temp->getID()); 305 COUT(4) << "creating spaceship for clientid: " << temp->getID() << std::endl; 306 // TODO: this is only a hack, untill we have a possibility to define default player-join actions 307 createShip(temp); 308 COUT(4) << "created spaceship" << std::endl; 309 temp->setSynched(true); 310 COUT(4) << "sending welcome" << std::endl; 311 sendWelcome(temp->getID(), temp->getShipID(), true); 312 return true; 313 } 314 315 bool ConnectionManager::createShip(ClientInformation *client){ 316 orxonox::Identifier* id = ID("SpaceShip"); 317 if(!id){ 318 COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl; 319 return false; 320 } 321 orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate()); 322 no->setPosition(orxonox::Vector3(0,80,0)); 323 no->setScale(10); 324 no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0)); 325 no->setMesh("assf3.mesh"); 326 no->setMaxSpeed(500); 327 no->setMaxSideAndBackSpeed(50); 328 no->setMaxRotation(1.0); 329 no->setTransAcc(200); 330 no->setRotAcc(3.0); 331 no->setTransDamp(75); 332 no->setRotDamp(1.0); 333 no->setCamera("cam_"+client->getID()); 334 no->create(); 335 336 client->setShipID(no->objectID); 337 return true; 338 } 339 340 bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){ 341 addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID); 342 sendPackets(); 343 } 344 345 bool ConnectionManager::addFakeConnectRequest(ENetEvent *ev){ 346 ENetEvent event; 347 event.peer=ev->peer; 348 event.packet = packet_gen.generateConnectRequest(); 349 return buffer.push(&event); 350 } 351 352 353 // int ConnectionManager::getNumberOfClients() { 354 // 355 // return clientsShip.size(); 356 // } 357 358 /*void ConnectionManager::addClientsObjectID( int clientID, int objectID ) { 359 COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl; 360 clientsShip.insert( std::make_pair( clientID, objectID ) ); 361 } 306 362 307 363 int ConnectionManager::getClientsShipID( int clientID ) { 308 309 364 return clientsShip[clientID]; 365 } 310 366 311 367 int ConnectionManager::getObjectsClientID( int objectID ) { 312 313 314 315 316 317 368 std::map<int, int>::iterator iter; 369 for( iter = clientsShip.begin(); iter != clientsShip.end(); iter++ ) { 370 if( iter->second == objectID ) return iter->first; 371 } 372 return -99; 373 } 318 374 319 375 void ConnectionManager::deleteClientIDReg( int clientID ) { 320 321 376 clientsShip.erase( clientID ); 377 } 322 378 323 379 void ConnectionManager::deleteObjectIDReg( int objectID ) { 324 std::map<int, int>::iterator iter = clientsShip.begin(); 325 for( iter = clientsShip.begin(); iter != clientsShip.end(); iter++ ) { 326 if( iter->second == objectID ) break; 327 } 328 clientsShip.erase( iter->first ); 329 } 330 int ConnectionManager::getNumberOfClients() { 331 return clientsShip.size(); 332 } 333 } 380 std::map<int, int>::iterator iter = clientsShip.begin(); 381 for( iter = clientsShip.begin(); iter != clientsShip.end(); iter++ ) { 382 if( iter->second == objectID ) break; 383 } 384 clientsShip.erase( iter->first ); 385 }*/ 386 } -
code/branches/network3/src/network/ConnectionManager.h
r1168 r1232 71 71 class ConnectionManager{ 72 72 public: 73 ConnectionManager(); 73 74 ConnectionManager(ClientInformation *head); 74 75 ConnectionManager(int port, const char *address, ClientInformation *head); … … 84 85 bool sendPackets(ENetEvent *event); 85 86 bool sendPackets(); 87 bool createClient(int clientID); 86 88 87 //##### for testing purpose only #####88 ConnectionManager();89 std::map<int, int> testGetClientsShip() {90 return clientsShip;91 }92 void testAddClientsShipID( int clientID, int objectID ) {93 addClientsObjectID( clientID, objectID );94 }95 int testGetClientsShipID( int clientID ) {96 return getClientsShipID( clientID );97 }98 int testGetObjectsClientID( int objectID ) {99 return getObjectsClientID( objectID );100 }101 void testDeleteClientsIDReg( int clientID ) {102 deleteClientIDReg( clientID );103 }104 void testDeleteObjectIDReg( int objectID ) {105 deleteObjectIDReg( objectID );106 }107 //##### for testing purpose only #####108 89 private: 109 90 bool clientDisconnect(ENetPeer *peer); 110 //bool clientDisconnect(ENetPeer peer);111 91 bool processData(ENetEvent *event); 112 92 bool addClient(ENetEvent *event); … … 117 97 void syncClassid(int clientID); 118 98 ENetPeer *getClientPeer(int clientID); 99 bool createShip(ClientInformation *client); 100 bool sendWelcome(int clientID, int shipID, bool allowed); 101 bool addFakeConnectRequest(ENetEvent *ev); 119 102 PacketBuffer buffer; 120 103 PacketGenerator packet_gen; … … 126 109 ClientInformation *head_; 127 110 111 112 // int getNumberOfClients(); 128 113 //functions to map what object every clients uses 129 std::map<int, int> clientsShip;114 /*std::map<int, int> clientsShip; 130 115 void addClientsObjectID( int clientID, int objectID ); 131 116 int getClientsShipID( int clientID ); 132 117 int getObjectsClientID( int objectID ); 133 118 void deleteClientIDReg( int clientID ); 134 void deleteObjectIDReg( int objectID ); 135 int getNumberOfClients(); 119 void deleteObjectIDReg( int objectID );*/ 136 120 }; 137 121 -
code/branches/network3/src/network/GameStateClient.cc
r1200 r1232 86 86 return false; 87 87 } 88 89 GameStateCompressed *GameStateClient::popPartialGameState(){ 90 GameState *gs = getPartialSnapshot(); 91 return compress_(gs); 92 } 93 88 94 89 95 /** … … 137 143 } 138 144 Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate()); 139 COUT(4) << "loadsnapsho rt: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;145 COUT(4) << "loadsnapshot: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl; 140 146 no->objectID=sync.objectID; 141 147 no->classID=sync.classID; 142 it=orxonox::ObjectList<Synchronisable>::end();143 148 // update data and create object/entity... 144 149 if( !no->updateData(sync) ) … … 146 151 if( !no->create() ) 147 152 COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl; 153 it=orxonox::ObjectList<Synchronisable>::end(); 148 154 } 149 155 } else { … … 159 165 } 160 166 167 GameState *GameStateClient::getPartialSnapshot(){ 168 //std::cout << "begin getSnapshot" << std::endl; 169 //the size of the gamestate 170 int totalsize=0; 171 int memsize=0; 172 //the size of one specific synchronisable 173 int tempsize=0; 174 // get the start of the Synchronisable list 175 orxonox::Iterator<Synchronisable> it; 176 // struct for return value of Synchronisable::getData() 177 syncData sync; 178 179 GameState *retval=new GameState; //return value 180 retval->id=reference->id; 181 retval->diffed=false; 182 retval->complete=false; 183 COUT(4) << "G.ST.Client: producing partial gamestate with id: " << retval->id << std::endl; 184 // offset of memory functions 185 int offset=0, size=0; 186 // get total size of gamestate 187 for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){ 188 if(!it->getBacksync()) 189 continue; 190 size+=it->getSize(); // size of the actual data of the synchronisable 191 size+=3*sizeof(int); // size of datasize, classID and objectID 192 } 193 //retval->data = (unsigned char*)malloc(size); 194 retval->data = new unsigned char[size]; 195 if(!retval->data){ 196 COUT(2) << "GameStateClient: could not allocate memory" << std::endl; 197 return NULL; 198 } 199 memsize=size; 200 // go through all Synchronisables 201 for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){ 202 if(!it->getBacksync()) 203 continue; 204 //get size of the synchronisable 205 tempsize=it->getSize(); 206 // add place for data and 3 ints (length,classid,objectid) 207 totalsize+=tempsize+3*sizeof(int); 208 // allocate+tempsize additional space 209 if(totalsize > size){ 210 COUT(3) << "G.St.Cl: need additional memory" << std::endl; 211 } 212 213 // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length) 214 sync=it->getData((retval->data)+offset+3*sizeof(int)); 215 memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int)); 216 memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int)); 217 memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int)); 218 // increase data pointer 219 offset+=tempsize+3*sizeof(int); 220 } 221 retval->size=totalsize; 222 COUT(5) << "G.ST.Cl: Gamestate size: " << totalsize << std::endl; 223 COUT(5) << "G.ST.Cl: 'estimated' Gamestate size: " << size << std::endl; 224 return retval; 225 } 226 227 161 228 GameState *GameStateClient::undiff(GameState *old, GameState *diff) { 229 if(!old || !diff) 230 return NULL; 162 231 unsigned char *ap = old->data, *bp = diff->data; 163 232 int of=0; // pointers offset … … 195 264 r->diffed = false; 196 265 r->data = dp; 266 r->complete = true; 197 267 return r; 198 268 } 199 269 200 //##### ADDED FOR TESTING PURPOSE ##### 201 GameState* GameStateClient::testDecompress( GameStateCompressed* gc ) { 202 return decompress( gc ); 203 } 204 205 GameState* GameStateClient::testUndiff( GameState* g_old, GameState* g_diffed ) { 206 return undiff( g_old, g_diffed ); 207 } 208 //##### ADDED FOR TESTING PURPOSE ##### 209 270 271 272 GameStateCompressed *GameStateClient::compress_(GameState *a) { 273 if(!a) 274 return NULL; 275 int size = a->size; 276 277 uLongf buffer = (uLongf)((a->size + 12)*1.01)+1; 278 unsigned char *dest = new unsigned char[buffer]; 279 int retval; 280 retval = compress( dest, &buffer, a->data, (uLong)size ); 281 282 switch ( retval ) { 283 case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break; 284 case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 285 return NULL; 286 case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; 287 return NULL; 288 case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; 289 return NULL; 290 } 291 292 GameStateCompressed *compressedGamestate = new GameStateCompressed; 293 compressedGamestate->compsize = buffer; 294 compressedGamestate->normsize = size; 295 compressedGamestate->id = a->id; 296 compressedGamestate->data = dest; 297 compressedGamestate->diffed = a->diffed; 298 compressedGamestate->complete = a->complete; 299 compressedGamestate->base_id = a->base_id; 300 delete[] a->data; 301 delete a; 302 return compressedGamestate; 303 } 304 305 210 306 GameState *GameStateClient::decompress(GameStateCompressed *a) { 211 307 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; … … 238 334 gamestate->base_id = a->base_id; 239 335 gamestate->diffed = a->diffed; 336 gamestate->complete = a->complete; 240 337 241 338 delete[] a->data; //delete compressed data … … 286 383 } 287 384 385 386 //##### ADDED FOR TESTING PURPOSE ##### 387 GameState* GameStateClient::testDecompress( GameStateCompressed* gc ) { 388 return decompress( gc ); 389 } 390 391 GameState* GameStateClient::testUndiff( GameState* g_old, GameState* g_diffed ) { 392 return undiff( g_old, g_diffed ); 393 } 394 //##### ADDED FOR TESTING PURPOSE ##### 395 396 288 397 } 398 -
code/branches/network3/src/network/GameStateClient.h
r1199 r1232 42 42 43 43 #include <map> 44 44 // 45 45 #include "NetworkPrereqs.h" 46 46 #include "core/CorePrereqs.h" 47 47 #include "PacketTypes.h" 48 48 49 49 50 namespace network … … 54 55 GameStateClient(); 55 56 ~GameStateClient(); 56 //#### ADDED FOR TESTING PURPOSE #### 57 GameState* testDecompress( GameStateCompressed* gc ); 58 GameState* testUndiff( GameState* g_old, GameState* g_diffed ); 59 //#### END TESTING PURPOSE #### 57 60 58 bool pushGameState(GameStateCompressed *compstate); 59 GameStateCompressed *popPartialGameState(); 61 60 private: 62 61 bool loadSnapshot(GameState *state); 62 GameState *getPartialSnapshot(); 63 63 void cleanup(); 64 64 GameState *undiff(GameState *old, GameState *diff); 65 GameStateCompressed *compress_(GameState *a); 65 66 GameState *decompress(GameStateCompressed *a); 66 67 GameState *decode(GameState *old, GameStateCompressed *diff); … … 72 73 int last_diff_; 73 74 std::map<int, GameState *> gameStateMap; 75 76 77 78 79 public: 80 //#### ADDED FOR TESTING PURPOSE #### 81 GameState* testDecompress( GameStateCompressed* gc ); 82 GameState* testUndiff( GameState* g_old, GameState* g_diffed ); 83 //#### END TESTING PURPOSE #### 74 84 }; 75 85 -
code/branches/network3/src/network/GameStateManager.cc
r1200 r1232 46 46 47 47 #include "core/CoreIncludes.h" 48 #include "core/BaseObject.h" 48 49 #include "ClientInformation.h" 49 50 #include "Synchronisable.h" … … 122 123 } 123 124 } 125 126 bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){ 127 GameState *ugs = decompress(gs); 128 return loadPartialSnapshot(ugs, clientID); 129 130 } 124 131 125 132 /** … … 188 195 //#### bugfix 189 196 retval->diffed = false; 197 retval->complete = true; 190 198 //std::cout << "end snapShot" << std::endl; 191 199 COUT(5) << "G.ST.Man: Gamestate size: " << totalsize << std::endl; … … 194 202 } 195 203 204 bool GameStateManager::loadPartialSnapshot(GameState *state, int clientID){ 205 unsigned char *data=state->data; 206 COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl; 207 // get the start of the Synchronisable list 208 orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start(); 209 syncData sync; 210 // loop as long as we have some data ;) 211 while(data < state->data+state->size){ 212 // prepare the syncData struct 213 sync.length = *(int *)data; 214 data+=sizeof(int); 215 sync.objectID = *(int*)data; 216 data+=sizeof(int); 217 sync.classID = *(int*)data; 218 data+=sizeof(int); 219 sync.data = data; 220 data+=sync.length; 221 222 while(it && it->objectID!=sync.objectID) 223 ++it; 224 225 226 if(!it){ 227 // the object does not exist yet 228 //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl; 229 orxonox::Identifier* id = ID((unsigned int)sync.classID); 230 if(!id){ 231 COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl; 232 continue; 233 } 234 Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate()); 235 COUT(4) << "loadpartialsnapshot (generating new object): classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl; 236 no->objectID=sync.objectID; 237 no->classID=sync.classID; 238 it=orxonox::ObjectList<Synchronisable>::end(); 239 // update data and create object/entity... 240 if( !no->updateData(sync) ) 241 COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl; 242 if( !no->create() ) 243 COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl; 244 }else{ 245 // we have our object 246 if(checkAccess(clientID, sync.objectID)){ 247 if(! it->updateData(sync)) 248 COUT(1) << "We couldn't update objectID: " \ 249 << sync.objectID << "; classID: " << sync.classID << std::endl; 250 }else 251 COUT(4) << "loadPartialSnapshot: no access to change objectID: " << sync.objectID << std::endl; 252 } 253 ++it; 254 } 255 256 return true; 257 } 258 259 196 260 //##### ADDED FOR TESTING PURPOSE ##### 197 261 GameStateCompressed* GameStateManager::testCompress( GameState* g ) { … … 269 333 r->base_id = a->id; 270 334 r->data = dp; 335 r->complete = true; 271 336 return r; 272 337 } … … 307 372 compressedGamestate->data = dest; 308 373 compressedGamestate->diffed = a->diffed; 374 compressedGamestate->complete = a->complete; 309 375 compressedGamestate->base_id = a->base_id; 310 376 //COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl; 311 377 return compressedGamestate; 312 378 } 379 380 GameState *GameStateManager::decompress(GameStateCompressed *a) { 381 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; 382 int normsize = a->normsize; 383 int compsize = a->compsize; 384 int bufsize; 385 if(normsize < compsize) 386 bufsize = compsize; 387 else 388 bufsize = normsize; 389 // unsigned char* dest = (unsigned char*)malloc( bufsize ); 390 unsigned char *dest = new unsigned char[bufsize]; 391 int retval; 392 uLongf length=normsize; 393 //std::cout << "gamestateclient" << std::endl; 394 //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl; 395 retval = uncompress( dest, &length, a->data, (uLong)compsize ); 396 //std::cout << "length " << length << std::endl; 397 switch ( retval ) { 398 case Z_OK: COUT(4) << "successfully decompressed" << std::endl; break; 399 case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return NULL; 400 case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL; 401 case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL; 402 } 403 404 GameState *gamestate = new GameState; 405 gamestate->id = a->id; 406 gamestate->size = normsize; 407 gamestate->data = dest; 408 gamestate->base_id = a->base_id; 409 gamestate->diffed = a->diffed; 410 gamestate->complete = a->complete; 411 412 delete[] a->data; //delete compressed data 413 delete a; //we do not need the old (struct) gamestate anymore 414 415 return gamestate; 416 } 417 313 418 314 419 void GameStateManager::ackGameState(int clientID, int gamestateID) { … … 336 441 COUT(4) << std::endl; 337 442 } 443 444 bool GameStateManager::checkAccess(int clientID, int objectID){ 445 // currently we only check, wheter the object is the clients spaceship 446 return head_->findClient(objectID)->getShipID()==objectID; 447 } 338 448 339 449 } -
code/branches/network3/src/network/GameStateManager.h
r1200 r1232 71 71 GameStateManager(ClientInformation *head); 72 72 ~GameStateManager(); 73 //#### ADDED FOR TESTING PURPOSE #### 74 GameStateCompressed* testCompress( GameState* g ); 75 GameState* testDiff( GameState* a, GameState* b ); 76 //#### END TESTING PURPOSE #### 73 77 74 void update(); 78 75 GameStateCompressed *popGameState(int clientID); 76 bool pushGameState(GameStateCompressed *gs, int clientID); 79 77 void ackGameState(int clientID, int gamestateID); 80 78 private: 81 79 void cleanup(); // "garbage handler" 82 80 GameState *getSnapshot(); 81 bool loadPartialSnapshot(GameState *state, int clientID); 83 82 GameStateCompressed *encode(GameState *a, GameState *b); 84 83 GameStateCompressed *encode(GameState *a); 85 84 GameState *diff(GameState *a, GameState *b); 86 85 GameStateCompressed *compress_(GameState *a); 86 GameState *decompress(GameStateCompressed *a); 87 87 bool printGameStates(); 88 bool checkAccess(int clientID, int objectID); 88 89 89 90 std::map<int, GameState*> gameStateMap; //map gsID to gamestate* … … 92 93 ClientInformation *head_; 93 94 int id_; 95 96 97 98 99 public: 100 //#### ADDED FOR TESTING PURPOSE #### 101 GameStateCompressed* testCompress( GameState* g ); 102 GameState* testDiff( GameState* a, GameState* b ); 103 //#### END TESTING PURPOSE #### 94 104 }; 95 105 -
code/branches/network3/src/network/NetworkPrereqs.h
r1168 r1232 78 78 struct chat; 79 79 struct classid; 80 struct welcome; 81 struct connectRequest; 80 82 struct ClientList; 81 83 struct GameState; -
code/branches/network3/src/network/PacketDecoder.cc
r1199 r1232 53 53 bool PacketDecoder::elaborate( ENetPacket* packet, int clientId ) 54 54 { 55 int client = clientId; 56 COUT(5) << "PacketDecoder: clientId: " << client << std::endl; //control cout, not important, just debugging info 55 COUT(5) << "PacketDecoder: clientId: " << clientId << std::endl; //control cout, not important, just debugging info 57 56 int id = (int)*packet->data; //the first 4 bytes are always the enet packet id 58 57 COUT(5) << "PacketDecoder: packet id: " << id << std::endl; … … 64 63 } 65 64 switch( id ) { 66 case ACK:67 acknowledgement( packet, clientId );68 return true;69 break;70 case MOUSE:71 mousem( packet, clientId );72 return true;73 break;74 case KEYBOARD:75 keystrike( packet, clientId );76 return true;77 break;78 case CHAT:79 chatMessage( packet, clientId );80 return true;81 break;82 case GAMESTATE:83 gstate( packet );84 return true;85 break;86 case CLASSID:87 clid(packet);88 return true;89 break;65 case ACK: 66 acknowledgement( packet, clientId ); 67 return true; 68 case COMMAND: 69 return command( packet, clientId ); 70 case MOUSE: 71 mousem( packet, clientId ); 72 return true; 73 case KEYBOARD: 74 keystrike( packet, clientId ); 75 return true; 76 case CHAT: 77 chatMessage( packet, clientId ); 78 return true; 79 case GAMESTATE: 80 gstate( packet ); 81 return true; 82 case CLASSID: 83 clid(packet); 84 return true; 85 case WELCOME: 86 return decodeWelcome( packet, clientId ); 87 case CONNECT: 88 return decodeConnectRequest( packet, clientId ); 90 89 } 91 90 return false; … … 105 104 //clean memory 106 105 enet_packet_destroy( packet ); 106 } 107 108 bool PacketDecoder::command( ENetPacket* packet, int clientId ){ 109 int length = *(int*)((unsigned char *)packet->data+sizeof(int)); 110 void *data = (void *)new unsigned char[length]; 111 memcpy(data, (void *)(packet->data+2*sizeof(int)), length); 112 return true; 107 113 } 108 114 … … 171 177 //since the packetgenerator was changed, due to a new parameter, change this function too 172 178 memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+5*sizeof(int)), sizeof(bool)); 179 memcpy( (void*)&(currentState->complete), (const void*)(packet->data+5*sizeof(int)+sizeof(bool)), sizeof(bool)); 173 180 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 174 181 if(currentState->compsize==0) … … 178 185 COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl; 179 186 //copy the GameStateCompressed data 180 memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + sizeof(bool)), currentState->compsize );187 memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + 2*sizeof(bool)), currentState->compsize ); 181 188 182 189 //clean memory … … 198 205 processClassid(cid); 199 206 } 207 208 209 bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){ 210 welcome *w = new welcome; 211 w->allowed = ((welcome *)(packet->data))->allowed; 212 w->shipID = ((welcome *)(packet->data))->shipID; 213 w->clientID = ((welcome *)(packet->data))->clientID; 214 w->id = ((welcome *)(packet->data))->id; 215 enet_packet_destroy( packet ); 216 return processWelcome(w); 217 } 218 219 bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){ 220 connectRequest *con = new connectRequest; 221 con->id = ((connectRequest *)(packet->data))->id; 222 enet_packet_destroy( packet ); 223 return processConnectRequest(con, clientID ); 224 } 200 225 201 226 … … 224 249 return; 225 250 } 226 251 252 bool PacketDecoder::processWelcome( welcome *w ){ 253 return true; 254 } 255 256 bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){ 257 COUT(3) << "packetdecoder: processing connectRequest" << std::endl; 258 return true; 259 } 227 260 228 261 //these are some print functions for test stuff -
code/branches/network3/src/network/PacketGenerator.cc
r1180 r1232 61 61 return packet; 62 62 } 63 64 ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE ) 65 { 66 void *stream = new char[dataLength + 2*sizeof(int)]; 67 if(!stream) 68 return NULL; 69 packet_id a = COMMAND; 70 memcpy(stream, (void*)&a, sizeof(int)); 71 memcpy((unsigned char *)stream+sizeof(int), (void*)&dataLength, sizeof(int)); 72 memcpy((unsigned char *)stream+2*sizeof(int), data, dataLength); 73 return enet_packet_create(stream, dataLength+2*sizeof(int), reliable); 74 } 63 75 64 76 /*### mouseupdates */ … … 108 120 //std::cout << "states->compsize " << states->compsize << std::endl; 109 121 int gid = GAMESTATE; //first assign the correct enet id 110 int totalLen = 5*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory122 int totalLen = 5*sizeof( int ) + 2*sizeof(bool) + states->compsize; //calculate the total size of the datastream memory 111 123 //std::cout << "totalLen " << totalLen << std::endl; 112 unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 124 //unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 125 unsigned char *data = new unsigned char[totalLen]; 113 126 memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id 114 127 memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id … … 118 131 memcpy( (void*)(data+5*sizeof(int)), (const void*)&(states->diffed), sizeof(bool)); 119 132 //place the GameStateCompressed data at the end of the enet datastream 120 memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize ); 133 memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)&(states->complete), sizeof(bool) ); 134 memcpy( (void*)(data+5*sizeof( int ) + 2*sizeof(bool)), (const void*)states->data, states->compsize ); 121 135 //create an enet packet with the generated bytestream 122 136 COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl; … … 128 142 ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable ) 129 143 { 130 unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1); 144 //unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1); 145 unsigned char *data = new unsigned char[3*sizeof(int)+classname.length()+1]; 131 146 std::cout << "PacketGenerator: classid: " << classid << ", name: " << classname << std::endl; 132 147 *(int *)data = CLASSID; … … 137 152 return packet; 138 153 } 154 155 ENetPacket* PacketGenerator::generateWelcome( int clientID,int shipID, bool allowed , int reliable ){ 156 welcome *wc = new welcome; 157 wc->id = WELCOME; 158 wc->clientID = clientID; 159 wc->shipID = shipID; 160 wc->allowed = true; 161 ENetPacket *packet = enet_packet_create( wc, sizeof(welcome), reliable); 162 return packet; 163 } 164 165 ENetPacket* PacketGenerator::generateConnectRequest( int reliable ){ 166 connectRequest *con = new connectRequest; 167 con->id=CONNECT; 168 return enet_packet_create( con, sizeof(connectRequest), reliable); 169 } 139 170 140 171 } -
code/branches/network3/src/network/PacketManager.h
r1168 r1232 54 54 //call one of this functions out of an instance of PacketGenerator to create a packet 55 55 ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE ); 56 ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE ); 56 57 ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE ); 57 58 ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE ); … … 59 60 ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE ); 60 61 ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE ); 62 ENetPacket* generateWelcome( int clientID,int shipID, bool allowed, int reliable = ENET_PACKET_FLAG_RELIABLE ); 63 ENetPacket* generateConnectRequest( int reliable = ENET_PACKET_FLAG_RELIABLE ); 61 64 private: 62 65 }; … … 85 88 86 89 void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); 90 bool command( ENetPacket* packet, int clientId ); 87 91 void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); 88 92 void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); … … 90 94 void gstate( ENetPacket* packet ); 91 95 void clid( ENetPacket *packet); 96 bool decodeWelcome( ENetPacket* packet, int clientID = CLIENTID_CLIENT ); 97 bool decodeConnectRequest( ENetPacket *packet, int clientID = CLIENTID_CLIENT ); 92 98 93 99 //process data … … 96 102 virtual void processAck( ack *data, int clientID); 97 103 virtual void processClassid( classid *cid); 104 virtual bool processWelcome( welcome *w ); 105 virtual bool processConnectRequest( connectRequest *con, int clientID ); 98 106 //virtual void processAck( ack *data); 99 107 -
code/branches/network3/src/network/PacketTypes.h
r1168 r1232 49 49 ACK, 50 50 MOUSE, 51 COMMAND, 51 52 KEYBOARD, 52 53 CHAT, 53 54 GAMESTATE , 54 CLASSID 55 CLASSID, 56 WELCOME, 57 CONNECT, 55 58 }; 56 59 … … 65 68 int size; //!< total size of data 66 69 // new ---- change functions 67 int base_id; // if gamestate is diffed this is the id of the old gamestate (base)70 int base_id; // if gamestate is diffed this is the id of the old gamestate (base) 68 71 bool diffed; 72 bool complete; // this determines, wheter all objects are in this gamestate (server) or only few objects (client) 69 73 unsigned char *data; //!< pointer to data 70 74 }; … … 83 87 int base_id; // if gamestate is diffed this is the id of the old gamestate (base) 84 88 bool diffed; 89 bool complete; // this determines, wheter all objects are in this gamestate (server) or only few objects (client) 85 90 unsigned char *data; //!< gamestate data 86 91 }; … … 116 121 }; 117 122 123 struct welcome { 124 int id; 125 int clientID; 126 int shipID; 127 bool allowed; 128 }; 129 130 struct connectRequest{ 131 int id; 132 }; 118 133 } 119 134 -
code/branches/network3/src/network/Server.cc
r1199 r1232 223 223 gamestates->ackGameState(clientID, data->a); 224 224 } 225 226 bool Server::processConnectRequest( connectRequest *con, int clientID ){ 227 COUT(4) << "processing connectRequest " << std::endl; 228 //connection->addPacket(packet_gen.gstate(gamestates->popGameState(clientID)) , clientID); 229 connection->createClient(clientID); 230 } 225 231 226 232 } -
code/branches/network3/src/network/Server.h
r1168 r1232 73 73 bool sendGameState(); 74 74 void processAck( ack *data, int clientID); 75 bool processConnectRequest( connectRequest *con, int clientID ); 75 76 ConnectionManager *connection; 76 77 GameStateManager *gamestates; -
code/branches/network3/src/network/Synchronisable.cc
r1199 r1232 48 48 namespace network 49 49 { 50 51 52 int Synchronisable::state_=1; // detemines wheter we are server (default) or client 53 50 54 /** 51 55 * Constructor: … … 63 67 Synchronisable::~Synchronisable(){ 64 68 } 69 70 void Synchronisable::setClient(bool b){ 71 if(b) // client 72 state_=0x2; 73 else // server 74 state_=0x1; 75 } 65 76 66 77 /** … … 70 81 * @param size size of the datatype the variable consists of 71 82 */ 72 void Synchronisable::registerVar(void *var, int size, variableType t ){83 void Synchronisable::registerVar(void *var, int size, variableType t, int mode){ 73 84 // create temporary synch.Var struct 74 85 synchronisableVariable *temp = new synchronisableVariable; 75 86 temp->size = size; 76 87 temp->var = var; 88 temp->mode = mode; 77 89 temp->type = t; 78 90 COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl; … … 153 165 for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){ 154 166 //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int)); 167 if( ((*i)->mode & state_) == 0 ) 168 continue; // this variable should only be received 155 169 switch((*i)->type){ 156 170 case DATA: … … 185 199 COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl; 186 200 for(i=syncList->begin(); i!=syncList->end(); i++){ 201 if( ((*i)->mode ^ state_) == 0 ) 202 continue; // this variable should only be sent 187 203 COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl; 188 204 switch((*i)->type){ … … 212 228 std::list<synchronisableVariable *>::iterator i; 213 229 for(i=syncList->begin(); i!=syncList->end(); i++){ 230 if( ((*i)->mode & state_) == 0 ) 231 continue; // this variable should only be received, so dont add its size to the send-size 214 232 switch((*i)->type){ 215 233 case DATA: … … 226 244 return tsize; 227 245 } 228 246 247 void Synchronisable::setBacksync(bool sync){ 248 backsync_=sync; 249 } 250 251 bool Synchronisable::getBacksync(){ 252 return backsync_; 253 } 254 229 255 } -
code/branches/network3/src/network/Synchronisable.h
r1180 r1232 62 62 typedef struct synchronisableVariable{ 63 63 int size; 64 int mode; // this determines in which direction the variable gets synchronised 64 65 void *var; 65 66 variableType type; … … 69 70 /** 70 71 * This class is the base class of all the Objects in the universe that need to be synchronised over the network 71 * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list. 72 * Every class, t 73 int mode;hat inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list. 72 74 * @author Oliver Scheuss 73 75 */ … … 79 81 int classID; 80 82 81 void registerVar(void *var, int size, variableType t );83 void registerVar(void *var, int size, variableType t, int mode=1); 82 84 // syncData getData(); 83 85 syncData getData(unsigned char *mem); 84 86 int getSize(); 85 87 bool updateData(syncData vars); 88 void setBacksync(bool sync); 89 bool getBacksync(); 86 90 virtual void registerAllVariables()=0; 87 91 virtual bool create()=0; 92 static void setClient(bool b); 88 93 protected: 89 94 Synchronisable(); … … 93 98 std::list<synchronisableVariable *> *syncList; 94 99 int datasize; 100 static int state_; // detemines wheter we are server (default) or client 101 bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) 95 102 }; 96 103 } -
code/branches/network3/src/orxonox/Orxonox.cc
r1184 r1232 326 326 orxonoxHUD_->setEnergyDistr(20,20,60); 327 327 hudOverlay->show(); 328 setupInputSystem(); 328 329 329 330 client_g->establishConnection(); … … 362 363 } 363 364 364 void Orxonox::createScene( void)365 void Orxonox::createScene() 365 366 { 366 367 // Init audio -
code/branches/network3/src/orxonox/objects/Camera.cc
r1212 r1232 127 127 COUT(0) << "t " << this->targetNode_->getPosition() << std::endl; 128 128 if(this->positionNode_ != NULL) 129 //this->cam_->setPosition(this->positionNode_->getPosition());129 this->cam_->setPosition(this->positionNode_->getPosition()); 130 130 if(this->targetNode_ != NULL) 131 131 this->cam_->lookAt(this->targetNode_->getPosition()); … … 139 139 { 140 140 this->bHasFocus_ = false; 141 this->positionNode_->detachObject(cam_); 141 142 } 142 143 -
code/branches/network3/src/orxonox/objects/Model.cc
r1174 r1232 73 73 XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode); 74 74 75 create();75 Model::create(); 76 76 } 77 77 -
code/branches/network3/src/orxonox/objects/SpaceShip.cc
r1212 r1232 80 80 81 81 this->camNode_ = 0; 82 this->camName_ = "camNode"; 82 83 83 84 this->tt_ = 0; … … 160 161 161 162 void SpaceShip::registerAllVariables(){ 162 163 164 163 registerVar( &camName_, camName_.length()+1, network::STRING); 165 164 } 166 165 167 166 void SpaceShip::init() 168 167 { 169 createCamera();168 COUT(4) << "================ \t\t\t\tspaceship::init" << std::endl; 170 169 // START CREATING THRUSTER 171 170 this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 198 197 this->greenNode_->setInheritScale(false); 199 198 199 COUT(4) << "attaching red billboard" << std::endl; 200 200 this->redNode_->attachObject(this->redBillboard_.getBillboardSet()); 201 201 this->redNode_->setScale(0.3, 0.3, 0.3); 202 202 203 COUT(4) << "attaching green billboard" << std::endl; 203 204 this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet()); 204 205 this->greenNode_->setScale(0.3, 0.3, 0.3); … … 214 215 this->chFarNode_->setInheritScale(false); 215 216 217 COUT(4) << "attaching crosshair near billboard" << std::endl; 216 218 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 217 219 this->chNearNode_->setScale(0.2, 0.2, 0.2); 218 220 221 COUT(4) << "attaching crosshair far billboard" << std::endl; 219 222 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 220 223 this->chFarNode_->setScale(0.4, 0.4, 0.4); 221 224 COUT(4) << "attaching camera" << std::endl; 225 226 createCamera(); 222 227 // END of testing crosshair 223 228 } … … 232 237 void SpaceShip::loadParams(TiXmlElement* xmlElem) 233 238 { 239 COUT(4) << "using loadparams" << std::endl; 234 240 Model::loadParams(xmlElem); 235 241 this->create(); 242 this->getFocus(); 236 243 /* 237 244 if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) … … 284 291 void SpaceShip::setCamera(const std::string& camera) 285 292 { 293 camName_=camera; 286 294 // change camera attributes here, if you want to ;) 295 } 296 297 void SpaceShip::getFocus(){ 298 COUT(4) << "requesting focus" << std::endl; 299 if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID) 300 CameraHandler::getInstance()->requestFocus(cam_); 301 287 302 } 288 303 289 304 void SpaceShip::createCamera(){ 290 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 291 camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 305 COUT(4) << "begin camera creation" << std::endl; 306 this->camNode_ = this->getNode()->createChildSceneNode(camName_); 307 COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl; 308 this->camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10)); 309 COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl; 292 310 /* 293 311 // node->setInheritOrientation(false); … … 295 313 cam->lookAt(Vector3(0,20,0)); 296 314 cam->roll(Degree(0)); 297 */ 315 */COUT(4) << "creating new camera" << std::endl; 298 316 cam_ = new Camera(this->camNode_); 317 COUT(4) << "setting target node" << std::endl; 299 318 cam_->setTargetNode(this->getNode()); 300 CameraHandler::getInstance()->requestFocus(cam_); 319 // this only applies to clients 320 if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID) 321 CameraHandler::getInstance()->requestFocus(cam_); 301 322 // cam->setPosition(Vector3(0,-350,0)); 302 323 //cam->roll(Degree(-90)); 303 324 304 325 //this->camNode_->attachObject(cam); 305 326 COUT(4) << "created camera" << std::endl; 306 327 } 307 328 … … 329 350 void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) 330 351 { 352 COUT(4) << "using xmlport" << std::endl; 331 353 Model::XMLPort(xmlelement, mode); 332 354 … … 339 361 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode); 340 362 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode); 363 364 SpaceShip::create(); 365 getFocus(); 341 366 } 342 367 … … 534 559 } 535 560 536 if(!network::Client::getSingleton() ){561 if(!network::Client::getSingleton() || network::Client::getSingleton()->getShipID() == objectID){ 537 562 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 538 563 this->acceleration_.x = this->translationAcceleration_; -
code/branches/network3/src/orxonox/objects/SpaceShip.h
r1212 r1232 63 63 void setTransDamp(float value); 64 64 void setRotDamp(float value); 65 66 void getFocus(); 65 67 66 68 static void setMaxSpeedTest(float value) … … 83 85 84 86 Ogre::SceneNode* camNode_; 85 Camera* cam_; 87 Camera* cam_; 88 std::string camName_; 89 86 90 87 91 ParticleInterface* tt_; -
code/branches/network3/src/orxonox/objects/WorldEntity.cc
r1191 r1232 190 190 XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true); 191 191 192 //create();192 WorldEntity::create(); 193 193 } 194 194 … … 197 197 { 198 198 // register coordinates 199 registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA );200 registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA );201 registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA );199 registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3); 200 registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3); 201 registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3); 202 202 // register orientation 203 registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA );204 registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA );205 registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA );206 registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA );203 registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3); 204 registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3); 205 registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3); 206 registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3); 207 207 // register velocity_ 208 registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA );209 registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA );210 registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA );208 registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3); 209 registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3); 210 registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3); 211 211 // register rotationAxis/rate 212 registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA );213 registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA );214 registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA );215 registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA );212 registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3); 213 registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3); 214 registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3); 215 registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3); 216 216 // register scale of node 217 registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA );218 registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA );219 registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA );217 registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3); 218 registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3); 219 registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3); 220 220 //register staticity 221 registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA); 221 registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3); 222 //register acceleration 223 // register velocity_ 224 registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3); 225 registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3); 226 registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3); 222 227 } 223 228
Note: See TracChangeset
for help on using the changeset viewer.