Changeset 1088 for code/branches/network
- Timestamp:
- Apr 17, 2008, 1:15:58 PM (17 years ago)
- Location:
- code/branches/network/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/ClientConnection.cc
r1011 r1088 85 85 86 86 ENetPacket *ClientConnection::getPacket() { 87 ENetAddress address; 87 ENetAddress address; //sems that address is not needed 88 88 return getPacket(address); 89 89 } … … 160 160 case ENET_EVENT_TYPE_CONNECT: 161 161 case ENET_EVENT_TYPE_RECEIVE: 162 COUT(5) << "Cl.Con: receiver-Thread : got new packet" << std::endl;163 processData(&event);162 COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl; 163 if ( !processData(&event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl; 164 164 break; 165 165 case ENET_EVENT_TYPE_DISCONNECT: … … 201 201 bool ClientConnection::establishConnection() { 202 202 ENetEvent event; 203 // connect to peer 203 // connect to peer (server is type ENetPeer*) 204 204 server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS); 205 205 if(server==NULL) -
code/branches/network/src/network/GameStateClient.cc
r1087 r1088 182 182 183 183 GameState *GameStateClient::decompress(GameStateCompressed *a) { 184 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;184 //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl; 185 185 int normsize = a->normsize; 186 186 int compsize = a->compsize; -
code/branches/network/src/network/GameStateManager.cc
r1016 r1088 259 259 260 260 GameStateCompressed *GameStateManager::compress_(GameState *a) { 261 COUT(4) << "G.St.Man: compressing gamestate" << std::endl; 262 COUT(4) << "G.St.Man: a: id: " << a->id << " base_id: " << a->base_id << " size: " << a->size << " diffed: " << a->diffed << std::endl; 261 //COUT(4) << "G.St.Man: compressing gamestate" << std::endl; 262 263 //COUT(4) << "G.St.Man: a: id: " << a->id << " base_id: " << a->base_id << " size: " << a->size << " diffed: " << a->diffed << std::endl; 263 264 int size = a->size; 265 264 266 uLongf buffer = (uLongf)((a->size + 12)*1.01)+1; 265 COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl;267 //COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl; 266 268 unsigned char* dest = (unsigned char*)malloc( buffer ); 267 COUT(4) << "dest: " << dest << std::endl;269 //COUT(4) << "dest: " << dest << std::endl; 268 270 int retval; 269 271 //std::cout << "before ziped " << buffer << std::endl; 270 272 retval = compress( dest, &buffer, a->data, (uLong)size ); 271 COUT(4) << "bloablabla aft3er compress" << std::endl;273 //COUT(4) << "bloablabla aft3er compress" << std::endl; 272 274 //std::cout << "after ziped " << buffer << std::endl; 273 275 … … 291 293 compressedGamestate->diffed = a->diffed; 292 294 compressedGamestate->base_id = a->base_id; 293 COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl;295 //COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl; 294 296 return compressedGamestate; 295 297 } -
code/branches/network/src/network/PacketBuffer.cc
r1008 r1088 62 62 // change this!!!!!!! 63 63 last->packet = ev->packet; 64 last->address = ev->peer->address;64 //last->address = ev->peer->address; 65 65 } else { 66 66 //insert a new element at the bottom … … 71 71 // save the packet to the new element 72 72 last->packet = ev->packet; 73 last->address = ev->peer->address;73 //last->address = ev->peer->address; 74 74 } 75 return true; 75 // pseudo bugfix: added a return false statement for error handling 76 if ( last->packet == ev->packet ) return true; 77 return false; 76 78 } 77 79 80 //returns the first element in the list without deleting it but 81 //moving first pointer to next element 78 82 ENetPacket *PacketBuffer::pop() { 79 83 boost::mutex::scoped_lock lock(networkPacketBufferMutex); -
code/branches/network/src/network/PacketDecoder.cc
r1008 r1088 217 217 void PacketDecoder::processGamestate( GameStateCompressed *state ) 218 218 { 219 COUT(5) << "PacketDecoder: processing Gamestate" << std::endl; 220 //printGamestate( state ); 219 221 } 220 222 -
code/branches/network/src/network/Synchronisable.cc
r1087 r1088 46 46 temp->var = var; 47 47 temp->type = t; 48 COUT(5) << " registering var with size: " << temp->size << " and type: " << temp->type << std::endl;48 COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl; 49 49 // increase datasize 50 50 datasize+=sizeof(int)+size; 51 51 //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl; 52 COUT(5) << " objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;52 COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl; 53 53 syncList->push_back(temp); 54 54 } -
code/branches/network/src/network/diffTest.cc
r1008 r1088 38 38 if ( g1->id != g2->id ) { 39 39 std::cout << "\t--> GameStates are not comparable -> not same id" << std::endl; 40 return 1;40 return true; 41 41 } 42 42 else if ( g1->size != g2->size ) { … … 51 51 } 52 52 } 53 std::cout << "\t--> GameStates are identical (compareData)" << std::endl; 53 //std::cout << "\t--> GameData are identical (compareData)" << std::endl; 54 return true; 55 } 56 57 bool compareData2( GameState* g1, GameState* g2 ) { 58 int length = g1->size; 59 for ( int i=0; i<length; i++ ) { 60 if ( g1->data[i] != g2->data[i] ) { 61 return false; 62 } 63 } 64 //std::cout << "\t--> GameData are identical (compareData)" << std::endl; 54 65 return true; 55 66 } … … 67 78 return false; 68 79 } 69 else if ( !compareData ( g1, g2 ) ) {80 else if ( !compareData2( g1, g2 ) ) { 70 81 std::cout << "\t==> GameState data are not identical (GameStateCompare)" << std::endl; 71 82 return false; 72 83 } 73 std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;84 //std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl; 74 85 return true; 75 86 } … … 132 143 b->size = length; 133 144 for ( int i=0; i<length; i++ ) { 134 if ( i%(rand()%((length)/11) ) == 0 ) b->data[i] =rand()%255;145 if ( i%(rand()%((length)/11)+rand()) == 0 ) b->data[i] = (char)rand()%255; 135 146 else b->data[i] = a->data[i]; 136 147 } … … 141 152 b->size = s; 142 153 for ( int i=0; i<length; i++ ) { 143 if ( i%10 == 0 ) b->data[i] = rand()%255;154 if ( i%10 == 0 ) b->data[i] = (char)rand()%255; 144 155 else b->data[i] = a->data[i]; 145 156 } 146 157 for( int i=length; i<s; i++ ) { 147 b->data[i] = rand()%255;158 b->data[i] = (char)rand()%255; 148 159 } 149 160 } … … 153 164 b->size = s; 154 165 for ( int i=0; i<length; i++ ) { 155 if ( i%(rand()%(length) ) == 0 ) b->data[i] =rand()%255;166 if ( i%(rand()%(length)+rand()) == 0 ) b->data[i] = (char)rand()%255; 156 167 else b->data[i] = a->data[i]; 157 168 } … … 165 176 b->size = s; 166 177 for ( int i=0; i<s; i++ ) { 167 if ( i%10 == 0 ) b->data[i] = rand()%255;178 if ( i%10 == 0 ) b->data[i] = (char)rand()%255; 168 179 else b->data[i] = a->data[i]; 169 180 } … … 260 271 printGameState( g_undiff2 ); 261 272 262 if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " BUT THAT'S HOW IT HAS TO BE" << std::endl;273 if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " DATA not identical.. ok" << std::endl; 263 274 264 275 g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 ); … … 279 290 280 291 std::cout << "---Diffed Gamestates before compressed and after uncompress comparsion" << std::endl; 281 compareGameStates( g_resultDiffed, g_diffed );292 if ( compareGameStates( g_resultDiffed, g_diffed ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl; 282 293 283 294 g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed ); 284 295 std::cout << "---New Gamestate of pseudo Server compared with new gamestate that Client gets" << std::endl; 285 compareGameStates( g_resultUndiffed, g_undiff2 );296 if ( compareGameStates( g_resultUndiffed, g_undiff2 ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl; 286 297 287 298 return; 299 } 300 301 bool testNCompressWithDiff( int n, int size, int modeCreateData, int modeChangeData ) { 302 303 GameStateClient* g_client; 304 GameStateManager* g_manager;; 305 306 GameStateCompressed* gc = new GameStateCompressed; 307 GameState* g_undiff1 = new GameState; 308 GameState* g_undiff2 = new GameState; 309 GameState* g_diffed; 310 GameState* g_resultDiffed; 311 GameState* g_resultUndiffed; 312 313 g_undiff1->data = createData( size, modeCreateData ); 314 g_undiff1->size = size; 315 g_undiff1->id = 1; 316 g_undiff1->diffed = false; 317 //l = -1; 318 g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData ); 319 320 while( compareData2( g_undiff1, g_undiff2 ) ) { 321 delete g_undiff2->data; 322 g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData ); 323 } 324 //l = -2; 325 g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 ); 326 gc = g_manager->testCompress( g_diffed ); 327 g_resultDiffed = g_client->testDecompress( gc ); 328 329 if ( !compareGameStates( g_resultDiffed, g_diffed ) ) return false; 330 //l = -3; 331 g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed ); 332 if ( !compareGameStates( g_resultUndiffed, g_undiff2 ) ) return false; 333 //l = 1; 334 /*if ( gc != NULL && gc->data != NULL ) 335 delete gc->data; 336 //l = 2; 337 //if ( gc != NULL ) 338 //delete gc; 339 //l = 3; 340 if ( g_undiff1 != NULL && g_undiff1->data != NULL ) 341 delete g_undiff1->data; 342 //l = 4; 343 //if ( g_undiff1 != NULL ) 344 //delete g_undiff1; 345 //l = 5; 346 if ( g_undiff2 != NULL && g_undiff2->data ) 347 delete g_undiff2->data; 348 //l = 6; 349 //if ( g_undiff2 != NULL ) 350 //delete g_undiff2; 351 //l = 7; 352 if ( g_diffed != NULL && g_diffed->data ) 353 //delete g_diffed->data; 354 //l = 8; 355 //if ( g_diffed ) 356 //delete g_diffed; 357 //l = 9; 358 if ( g_resultDiffed != NULL && g_resultDiffed->data ) 359 delete g_resultDiffed->data; 360 //l = 10; 361 //if ( g_resultDiffed ) 362 //delete g_resultDiffed; 363 //l = 11;*/ 364 365 return true; 366 } 367 368 bool testNCompression( int n, int size, int mode ) { 369 GameStateClient* g_client; 370 GameStateManager* g_manager;; 371 372 GameState* g_new = new GameState; 373 GameState* g_old = new GameState; 374 GameStateCompressed* gc = new GameStateCompressed; 375 376 g_old->data = createData( size, mode ); 377 g_old->size = size; 378 g_old->id = 0; 379 g_old->diffed = false; 380 381 gc = g_manager->testCompress( g_old ); 382 383 g_new = g_client->testDecompress( gc ); 384 385 if ( !compareGameStates( g_new, g_old ) ) return false; 386 387 388 if ( g_new != NULL && g_new->data != NULL ) 389 delete g_new->data; 390 391 if ( g_old != NULL && g_old->data != NULL ) 392 delete g_old->data; 393 394 if ( gc != NULL && gc->data ) 395 delete gc->data; 396 397 return true; 288 398 } 289 399 … … 521 631 522 632 int main( int argc, char* argv[] ) { 523 int a,b,c ;633 int a,b,c,n; 524 634 std::string dec = "nothing"; 525 635 std::cout << "############### START TEST (quit q) ###############" << std::endl; … … 527 637 std::cout << "displayModes:\t\t modes" << std::endl; 528 638 std::cout << "testCompression:\t tc [datalength] [mode Data]" << std::endl; 639 std::cout << "testNCompression:\t tnc [#of loops] [datalength] [mode Data]" << std::endl; 529 640 std::cout << "testDifferentiation:\t td [datalength] [mode Data] [mode Change]" << std::endl; 530 641 std::cout << "testCompressWithDiff:\t tcd [datalength] [mode Data] [mode Change]" << std::endl; 642 std::cout << "testNCompressWithDiff:\t tncd [#of loops] [datalength] [mode Data] [mode Change]" << std::endl; 531 643 std::cout << "testClientObjectMapping: tcom [#clients]" << std::endl; 532 644 std::cout << "testClientInformation:\t tci [#clients] (call with >10)" << std::endl; … … 558 670 else if ( dec.compare("tbuf") == 0 ) { 559 671 testPacketBuffer(); 560 } 672 } 673 else if ( dec.compare("tncd") == 0 ) { 674 std::cin >> n; std::cin >> a; std::cin >> b; std::cin >> c; 675 for ( int i=1; i<=n; i++ ) { 676 std::cout << i << " s" << a << " "; 677 //std::cout << "start loop test " << i << std::endl; 678 if ( !testNCompressWithDiff( i, a, b, c ) ) { 679 std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl; 680 break; 681 } 682 } 683 std::cout << "end loop comparsion test" << std::endl; 684 } 685 else if ( dec.compare("tnc") == 0 ) { 686 std::cin >> n; std::cin >> a; std::cin >> b; 687 for ( int i=1; i<=n; i++ ) { 688 std::cout << i << " s" << a << " "; 689 //std::cout << "start loop test " << i << std::endl; 690 if ( !testNCompression( i, a, b ) ) { 691 std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl; 692 break; 693 } 694 } 695 std::cout << "end loop comparsion test" << std::endl; 696 } 697 else std::cout << "invalid input" << std::endl; 561 698 std::cout << "################## END ONE TURN ##################@" << std::endl; 562 699 } -
code/branches/network/src/orxonox/Orxonox.cc
r988 r1088 262 262 hudOverlay->show(); 263 263 264 client_g->establishConnection(); 264 if( !client_g->establishConnection() ) 265 COUT(1) <<"CLIENT COULD NOT ESTABLISH CONNECTION" << std::endl; 265 266 client_g->tick(0); 266 267 -
code/branches/network/src/orxonox/objects/Model.cc
r1082 r1088 89 89 this->mesh_.setMesh(meshSrc_); 90 90 this->attachObject(this->mesh_.getEntity()); 91 COUT(4) << "Loader : Created model" << std::endl;91 COUT(4) << "Loader (Model.cc): Created model" << std::endl; 92 92 } 93 93 return true; … … 96 96 void Model::registerAllVariables(){ 97 97 // WorldEntity::registerAllVariables(); 98 COUT(5) << " registering new meshsrc with size: " << meshSrc_.length()+1<< std::endl;98 COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl; 99 99 registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING); 100 100 }
Note: See TracChangeset
for help on using the changeset viewer.