Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 632


Ignore:
Timestamp:
Dec 19, 2007, 12:28:42 AM (16 years ago)
Author:
dumenim
Message:

networkstuff bluber fubber

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

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/Client.cc

    r624 r632  
    183183    while(!(client_connection.queueEmpty())){
    184184      packet = client_connection.getPacket();
     185      //std::cout << "tick packet size " << packet->dataLength << std::endl;
    185186      elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
    186187    }
  • code/branches/FICN/src/network/ClientConnection.cc

    r620 r632  
    7575
    7676  ENetPacket *ClientConnection::getPacket(ENetAddress &address){
    77     if(!buffer.isEmpty())
     77    if(!buffer.isEmpty()) {
     78      //std::cout << "###BUFFER IS NOT EMPTY###" << std::endl;
    7879      return buffer.pop(address);
    79     else
     80    }
     81    else{
    8082        return NULL;
     83    }
    8184  }
    8285
  • code/branches/FICN/src/network/GameStateClient.cc

    r624 r632  
    153153  int retval;
    154154  uLongf length=normsize;
     155  //std::cout << "gamestateclient" << std::endl;
     156  //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
    155157  retval = uncompress( dest, &length, a.data, (uLong)compsize );
    156 
     158  //std::cout << "length " << length << std::endl;
    157159  switch ( retval ) {
    158160    case Z_OK: std::cout << "successfully decompressed" << std::endl; break;
     
    167169  gamestate.data = dest;
    168170  gamestate.diffed = a.diffed;
    169 
     171 
    170172  return gamestate;
    171173}
  • code/branches/FICN/src/network/GameStateManager.cc

    r630 r632  
    109109    //get size of the synchronisable
    110110    tempsize=it->getSize();
     111    //std::cout << "size of temp gamestate: " << tempsize << std::endl;
    111112    //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
    112113    // add place for data and 3 ints (length,classid,objectid)
    113114    totalsize+=tempsize+3*sizeof(int);
     115    //std::cout << "totalsize: " << totalsize << std::endl;
    114116    // allocate additional space
    115117    if(totalsize+tempsize>memsize){
     
    188190  unsigned char* dest = (unsigned char*)malloc( buffer );
    189191  int retval;
     192  //std::cout << "before ziped " << buffer << std::endl;
    190193  retval = compress( dest, &buffer, a->data, (uLong)size );
     194  //std::cout << "after ziped " << buffer << std::endl;
    191195
    192196  switch ( retval ) {
     
    199203  GameStateCompressed compressedGamestate;
    200204  compressedGamestate.compsize = buffer;
     205  //std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
    201206  compressedGamestate.normsize = size;
     207  //std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
    202208  compressedGamestate.id = a->id;
    203209  compressedGamestate.data = dest;
  • code/branches/FICN/src/network/PacketBuffer.cc

    r514 r632  
    5050bool PacketBuffer::push(ENetEvent *ev){
    5151  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
     52  //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
    5253//   if(closed)
    5354//     return false;
     
    7576ENetPacket *PacketBuffer::pop(){
    7677  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
     78  //std::cout << "packetbuffer pop" << std::endl;
    7779  if(first!=NULL /*&& !closed*/){
    7880    QueueItem *temp = first;
     
    8284    first = first->next;
    8385    delete temp;
     86    //std::cout << "pop size of packet " << pck->dataLength << std::endl;
    8487    return pck;
    8588  } else{
     89    //std::cout << "nothing to return" << std::endl;
    8690    return NULL;
    8791  }
     
    9094ENetPacket *PacketBuffer::pop(ENetAddress &address){
    9195  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
     96  //std::cout << "packetbuffer pop(address)" << std::endl;
    9297  if(first!=NULL /*&& !closed*/){
    9398    QueueItem *temp = first;
     
    98103    first = first->next;
    99104    delete temp;
     105    //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
    100106    return pck;
    101107  } else{
  • code/branches/FICN/src/network/PacketDecoder.cc

    r624 r632  
    5252        cout << "clientId: " << client << endl; //control cout, not important, just debugging info
    5353        int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
     54        std::cout << "packet id: " << id << std::endl;
     55        std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
    5456        switch( id ) {
    5557        case ACK:
     
    145147        unsigned char* data = (unsigned char*)packet->data;
    146148        //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
    147   //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
    148   currentState->id = (int)*(data+sizeof(int));
    149   std::cout << "id: " << currentState->id << std::endl;
     149        //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
     150        currentState->id = (int)*(data+sizeof(int));
     151         std::cout << "id: " << currentState->id << std::endl;
    150152        //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    151153        //position of the data stream, data+2*sizeof( int )
    152 //      memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
    153   currentState->compsize = (int)*(data+2*sizeof(int));
    154   std::cout << "compsize: " << currentState->compsize << std::endl;
     154        memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
     155        //currentState->compsize = (int)*(data+2*sizeof(int));
     156        std::cout << "compsize: " << currentState->compsize << std::endl;
    155157        //size of uncompressed data
    156 //      memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
    157   currentState->normsize = (int)*(data+3*sizeof(int));
    158   std::cout << "normsize. " << currentState->normsize << std::endl;
     158        memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
     159        //currentState->normsize = (int)*(data+3*sizeof(int));
     160        std::cout << "normsize. " << currentState->normsize << std::endl;
    159161        //since the packetgenerator was changed, due to a new parameter, change this function too
    160 //      memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
    161   currentState->diffed = (bool)*(data+4*sizeof(int));
    162   std::cout << "diffed: " << currentState->diffed << std::endl;
     162        memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
     163        //currentState->diffed = (bool)*(data+4*sizeof(int));
     164        std::cout << "diffed: " << currentState->diffed << std::endl;
    163165        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    164166        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
    165   if(currentState->data==NULL)
    166     std::cout << "memory leak" << std::endl;
     167        if(currentState->data==NULL)
     168                std::cout << "memory leak" << std::endl;
    167169        //copy the GameStateCompressed data
    168   //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
    169   //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
     170        //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
     171        //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
    170172        memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
    171173
    172174        //clean memory
    173175        enet_packet_destroy( packet );
    174   //run processGameStateCompressed
    175   //TODO: not yet implemented!
    176   processGamestate(currentState);
     176        //run processGameStateCompressed
     177        //TODO: not yet implemented!
     178        processGamestate(currentState);
    177179}
    178180
  • code/branches/FICN/src/network/PacketGenerator.cc

    r624 r632  
    9898ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
    9999{
    100         int gid = GAMESTATE; //first assign the correct enet id
    101         int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
    102         unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
     100  //std::cout << "packetgenerator" << std::endl;
     101  //std::cout << "states->normsize " << states->normsize << std::endl;
     102  //std::cout << "states->compsize " << states->compsize << std::endl;
     103  int gid = GAMESTATE; //first assign the correct enet id
     104  int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
     105  //std::cout << "totalLen " << totalLen << std::endl;
     106  unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
    103107  memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
    104108  memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
     
    107111  memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
    108112  /*(int)*(data) = gid;
    109         (int)*(data+sizeof(int)) = states->id;
     113  (int)*(data+sizeof(int)) = states->id;
    110114  //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
    111115  (int)*(data+2*sizeof(int)) = states->compsize;
    112         //this is the uncompressed size of GameStateCompressed data
     116  //this is the uncompressed size of GameStateCompressed data
    113117  (int)*(data+3*sizeof(int)) = states->normsize;
    114         //since there is a new parameter inside GameStateCompressed, change this function to create packet
     118  //since there is a new parameter inside GameStateCompressed, change this function to create packet
    115119  (bool)*(data+4*sizeof(int)) = states->diffed;*/
    116         //place the GameStateCompressed data at the end of the enet datastream
    117         memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
    118         //create an enet packet with the generated bytestream
    119         ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
     120  //place the GameStateCompressed data at the end of the enet datastream
     121  memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
     122  //create an enet packet with the generated bytestream
     123  ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
    120124  //delete data;
    121         return packet;
     125  return packet;
    122126}
    123127
  • code/branches/FICN/src/network/Server.cc

    r624 r632  
    8686  bool Server::sendMSG(const char *msg){
    8787    ENetPacket *packet = packet_gen.chatMessage(msg);
    88     std::cout <<"adding PPPPPackets" << std::endl;
     88    std::cout <<"adding Packets" << std::endl;
    8989    connection->addPacketAll(packet);
    9090    //std::cout <<"added packets" << std::endl;
    9191    if (connection->sendPackets()){
    92         std::cout << "SSSSSucessfully" << std::endl;
     92        std::cout << "Sucessfully" << std::endl;
    9393        return true;
    9494    }
  • code/branches/FICN/src/network/dummyclient3.cc

    r601 r632  
    2828          std::cout << "connection established" << std::endl;
    2929  else std::cout << "problems establishing connection" << std::endl;
    30 
     30  char message[10000];
     31  char signs[] = "abcdefghijklmnopqrstuvwxy";
    3132  while (true) {
    3233          client.tick(0);
    33           std::cout << "your message: ";
    34           std::getline( std::cin, str );
    35           client.sendChat( str );
    36           std::cout << "sent message" << std::endl;
     34         
     35          std::cout << "your message2: ";
     36          for ( int i=0; i<9999; i++ ) {
     37            message[i] = signs[0];
     38          }
     39          message[9999] = 'z';
     40          std::string str( message );
     41          client.sendChat( str );
     42          std::cout << str << std::endl;
     43          std::cin.get(); std::cin.get();
    3744  }
    3845
Note: See TracChangeset for help on using the changeset viewer.