Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 13, 2008, 3:47:21 PM (16 years ago)
Author:
scheusso
Message:

added some debug output

File:
1 edited

Legend:

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

    r790 r889  
    5454    cout << "clientId: " << client << endl; //control cout, not important, just debugging info
    5555    int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
    56     std::cout << "packet id: " << id << std::endl;
    57     std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
     56    COUT(5) << "packet id: " << id << std::endl;
     57//     COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
    5858    switch( id ) {
    5959  case ACK:
     
    9393
    9494
    95     std::cout << "got ack id: " << a->id << std::endl;
     95    COUT(5) << "got ack id: " << a->id << std::endl;
    9696    processAck( a, clientId ); //debug info
    9797
     
    150150    //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
    151151    currentState->id = (int)*(data+sizeof(int));
    152     std::cout << "id: " << currentState->id << std::endl;
     152//     std::cout << "id: " << currentState->id << std::endl;
    153153    //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    154154    //position of the data stream, data+2*sizeof( int )
    155     memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
     155//     memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
    156156    //currentState->compsize = (int)*(data+2*sizeof(int));
    157     std::cout << "compsize: " << currentState->compsize << std::endl;
     157//     std::cout << "compsize: " << currentState->compsize << std::endl;
    158158    //size of uncompressed data
    159159    memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
    160160    //currentState->normsize = (int)*(data+3*sizeof(int));
    161     std::cout << "normsize. " << currentState->normsize << std::endl;
     161//     std::cout << "normsize. " << currentState->normsize << std::endl;
    162162    //since the packetgenerator was changed, due to a new parameter, change this function too
    163163    memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
    164164    //currentState->diffed = (bool)*(data+4*sizeof(int));
    165     std::cout << "diffed: " << currentState->diffed << std::endl;
     165//     std::cout << "diffed: " << currentState->diffed << std::endl;
    166166    //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    167167    currentState->data = (unsigned char*)(malloc( currentState->compsize ));
    168168    if(currentState->data==NULL)
    169       std::cout << "memory leak" << std::endl;
     169      COUT(2) << "Gamestatepacket-decoder: memory leak" << std::endl;
    170170    //copy the GameStateCompressed data
    171171    //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
     
    175175    //clean memory
    176176    enet_packet_destroy( packet );
    177     //run processGameStateCompressed
    178     //TODO: not yet implemented!
    179177    processGamestate(currentState);
    180178  }
     
    189187    void *data  = (void *)cid->message;
    190188    memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
    191     std::cout << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
     189    COUT(4) << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
    192190    enet_packet_destroy( packet );
    193191    processClassid(cid);
     
    223221  void PacketDecoder::printAck( ack* data )
    224222  {
    225     cout << "data id: " << data->id << endl;
    226     cout << "data:    " << data->a << endl;
     223    COUT(5) << "data id: " << data->id << endl;
     224    COUT(5) << "data:    " << data->a << endl;
    227225  }
    228226
    229227  void PacketDecoder::printMouse( mouse* data )
    230228  {
    231     cout << "data id: " << data->id << endl;
    232     cout << "data:    " << data->x << " " << data->y << endl;
     229    COUT(5) << "data id: " << data->id << endl;
     230    COUT(5) << "data:    " << data->x << " " << data->y << endl;
    233231  }
    234232
    235233  void PacketDecoder::printKey( keyboard* data )
    236234  {
    237     cout << "data id: " << data->id << endl;
    238     cout << "data:    " << (char)data->press << endl;
     235    COUT(5) << "data id: " << data->id << endl;
     236    COUT(5) << "data:    " << (char)data->press << endl;
    239237  }
    240238
     
    242240  {
    243241    if(clientId!=CLIENTID_CLIENT)
    244       cout << "client: " << clientId << endl;
    245     cout << "data id: " << data->id << endl;
    246     cout << "data:    " << data->message << endl;
     242      COUT(5) << "client: " << clientId << endl;
     243    COUT(5) << "data id: " << data->id << endl;
     244    COUT(5) << "data:    " << data->message << endl;
    247245  }
    248246
    249247  void PacketDecoder::printGamestate( GameStateCompressed* data )
    250248  {
    251     cout << "id of GameStateCompressed:   " << data->id << endl;
    252     cout << "size of GameStateCompressed: " << data->compsize << endl;
     249    COUT(5) << "id of GameStateCompressed:   " << data->id << endl;
     250    COUT(5) << "size of GameStateCompressed: " << data->compsize << endl;
    253251  }
    254252
    255253  void PacketDecoder::printClassid( classid *cid)
    256254  {
    257     cout << "id of classid:    " << cid->id << endl;
    258     cout << "size of classid:  " << cid->length << endl;
    259     cout << "ID of classid:    " << cid->clid <<endl;
    260     cout << "data of classid:  " << cid->message <<endl;
     255    COUT(5) << "id of classid:    " << cid->id << endl;
     256    COUT(5) << "size of classid:  " << cid->length << endl;
     257    COUT(5) << "ID of classid:    " << cid->clid <<endl;
     258    COUT(5) << "data of classid:  " << cid->message <<endl;
    261259  }
    262260
Note: See TracChangeset for help on using the changeset viewer.