Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1088


Ignore:
Timestamp:
Apr 17, 2008, 1:15:58 PM (17 years ago)
Author:
dumenim
Message:

catched some return values

Location:
code/branches/network/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/ClientConnection.cc

    r1011 r1088  
    8585
    8686  ENetPacket *ClientConnection::getPacket() {
    87     ENetAddress address;
     87    ENetAddress address; //sems that address is not needed
    8888    return getPacket(address);
    8989  }
     
    160160      case ENET_EVENT_TYPE_CONNECT:
    161161      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;
    164164        break;
    165165      case ENET_EVENT_TYPE_DISCONNECT:
     
    201201  bool ClientConnection::establishConnection() {
    202202    ENetEvent event;
    203     // connect to peer
     203    // connect to peer (server is type ENetPeer*)
    204204    server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS);
    205205    if(server==NULL)
  • code/branches/network/src/network/GameStateClient.cc

    r1087 r1088  
    182182
    183183  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;
    185185    int normsize = a->normsize;
    186186    int compsize = a->compsize;
  • code/branches/network/src/network/GameStateManager.cc

    r1016 r1088  
    259259
    260260  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;
    263264    int size = a->size;
     265
    264266    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;
    266268    unsigned char* dest = (unsigned char*)malloc( buffer );
    267     COUT(4) << "dest: " << dest << std::endl;
     269    //COUT(4) << "dest: " << dest << std::endl;
    268270    int retval;
    269271    //std::cout << "before ziped " << buffer << std::endl;
    270272    retval = compress( dest, &buffer, a->data, (uLong)size );
    271     COUT(4) << "bloablabla aft3er compress" << std::endl;
     273    //COUT(4) << "bloablabla aft3er compress" << std::endl;
    272274    //std::cout << "after ziped " << buffer << std::endl;
    273275
     
    291293    compressedGamestate->diffed = a->diffed;
    292294    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;
    294296    return compressedGamestate;
    295297  }
  • code/branches/network/src/network/PacketBuffer.cc

    r1008 r1088  
    6262      // change this!!!!!!!
    6363      last->packet = ev->packet;
    64       last->address = ev->peer->address;
     64      //last->address = ev->peer->address;
    6565    } else {
    6666      //insert a new element at the bottom
     
    7171      // save the packet to the new element
    7272      last->packet = ev->packet;
    73       last->address = ev->peer->address;
     73      //last->address = ev->peer->address;
    7474    }
    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;
    7678  }
    7779
     80  //returns the first element in the list without deleting it but
     81  //moving first pointer to next element
    7882  ENetPacket *PacketBuffer::pop() {
    7983    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
  • code/branches/network/src/network/PacketDecoder.cc

    r1008 r1088  
    217217  void PacketDecoder::processGamestate( GameStateCompressed *state )
    218218  {
     219    COUT(5) << "PacketDecoder: processing Gamestate" << std::endl;
     220    //printGamestate( state );
    219221  }
    220222
  • code/branches/network/src/network/Synchronisable.cc

    r1087 r1088  
    4646    temp->var = var;
    4747    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;
    4949    // increase datasize
    5050    datasize+=sizeof(int)+size;
    5151    //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;
    5353    syncList->push_back(temp);
    5454  }
  • code/branches/network/src/network/diffTest.cc

    r1008 r1088  
    3838  if ( g1->id != g2->id ) {
    3939    std::cout << "\t--> GameStates are not comparable -> not same id" << std::endl;
    40     return 1;
     40    return true;
    4141  }
    4242  else if ( g1->size != g2->size ) {
     
    5151    }
    5252  }
    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
     57bool 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;
    5465  return true;
    5566}
     
    6778    return false;
    6879  }
    69   else if ( !compareData( g1, g2 ) ) {
     80  else if ( !compareData2( g1, g2 ) ) {
    7081    std::cout << "\t==> GameState data are not identical (GameStateCompare)" << std::endl;
    7182    return false;
    7283  }
    73   std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;
     84  //std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;
    7485  return true;
    7586}
     
    132143    b->size = length;
    133144    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;
    135146      else b->data[i] = a->data[i];
    136147    }
     
    141152    b->size = s;
    142153    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;
    144155      else b->data[i] = a->data[i];
    145156    }
    146157    for( int i=length; i<s; i++ ) {
    147       b->data[i] = rand()%255;
     158      b->data[i] = (char)rand()%255;
    148159    }
    149160  }
     
    153164    b->size = s;
    154165    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;
    156167      else b->data[i] = a->data[i];
    157168    }
     
    165176    b->size = s;
    166177    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;
    168179      else b->data[i] = a->data[i];
    169180    }
     
    260271  printGameState( g_undiff2 ); 
    261272
    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;
    263274
    264275  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
     
    279290
    280291  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;
    282293 
    283294  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
    284295  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;
    286297
    287298  return; 
     299}
     300
     301bool 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
     368bool 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;
    288398}
    289399
     
    521631
    522632int main( int argc, char* argv[] ) {
    523   int a,b,c;
     633  int a,b,c,n;
    524634  std::string dec = "nothing";
    525635  std::cout << "############### START TEST (quit q) ###############" << std::endl;
     
    527637  std::cout << "displayModes:\t\t modes" << std::endl;
    528638  std::cout << "testCompression:\t tc [datalength] [mode Data]" << std::endl;
     639  std::cout << "testNCompression:\t tnc [#of loops] [datalength] [mode Data]" << std::endl;
    529640  std::cout << "testDifferentiation:\t td [datalength] [mode Data] [mode Change]" << std::endl;
    530641  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;
    531643  std::cout << "testClientObjectMapping: tcom [#clients]" << std::endl;
    532644  std::cout << "testClientInformation:\t tci [#clients] (call with >10)" << std::endl;
     
    558670    else if ( dec.compare("tbuf") == 0 ) {
    559671      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; 
    561698    std::cout << "################## END ONE TURN ##################@" << std::endl;
    562699  }
  • code/branches/network/src/orxonox/Orxonox.cc

    r988 r1088  
    262262    hudOverlay->show();
    263263   
    264     client_g->establishConnection();
     264    if( !client_g->establishConnection() )
     265      COUT(1) <<"CLIENT COULD NOT ESTABLISH CONNECTION" << std::endl;
    265266    client_g->tick(0);
    266267   
  • code/branches/network/src/orxonox/objects/Model.cc

    r1082 r1088  
    8989        this->mesh_.setMesh(meshSrc_);
    9090        this->attachObject(this->mesh_.getEntity());
    91         COUT(4) << "Loader: Created model" << std::endl;
     91        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
    9292      }
    9393      return true;
     
    9696    void Model::registerAllVariables(){
    9797//       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;
    9999      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
    100100    }
Note: See TracChangeset for help on using the changeset viewer.