Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 6, 2008, 2:50:12 PM (16 years ago)
Author:
scheusso
Message:

some bugs fixed (packet handling)

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

Legend:

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

    r1711 r1713  
    334334  }
    335335
    336   void ConnectionManager::syncClassid(int clientID) {
     336  /**
     337   *
     338   * @param clientID
     339   */
     340  void ConnectionManager::syncClassid(unsigned int clientID) {
    337341    unsigned int network_id=0, failures=0;
    338342    std::string classname;
     
    349353      COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
    350354
    351       packet::ClassID classid( network_id, classname );
    352       classid.setClientID(clientID);
    353       while(!classid.send() && failures < 10){
     355      packet::ClassID *classid = new packet::ClassID( network_id, classname );
     356      classid->setClientID(clientID);
     357      while(!classid->send() && failures < 10){
    354358        failures++;
    355359      }
  • code/branches/network/src/network/ConnectionManager.h

    r1705 r1713  
    9494    //bool createClient(int clientID);
    9595    void disconnectClient(ClientInformation *client);
    96     void syncClassid(int clientID);
     96    void syncClassid(unsigned int clientID);
    9797
    9898  private:
  • code/branches/network/src/network/packet/Acknowledgement.cc

    r1711 r1713  
    4444  flags_ = flags_ | PACKET_FLAGS_ACK;
    4545  data_=new unsigned char[ getSize() ];
    46   *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::Acknowledgement;
     46  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
    4747  *(unsigned int *)&data_[ _ACKID ] = id;
    4848  clientID_=clientID;
  • code/branches/network/src/network/packet/ClassID.cc

    r1712 r1713  
    5151  data_=new unsigned char[ getSize() ];
    5252  assert(data_);
    53   *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::ClassID;
    54   *(unsigned int *)&data_[ _CLASSID ] = classID;
    55   *(unsigned int *)&data_[ _CLASSNAMELENGTH ] = classNameLength_;
    56   memcpy( &data_[ _CLASSNAME ], (void *)className.c_str(), classNameLength_ );
     53  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID;
     54  *(unsigned int *)(data_ + _CLASSID ) = classID;
     55  *(unsigned int *)(data_ + _CLASSNAMELENGTH ) = classNameLength_;
     56  memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ );
    5757}
    5858
     
    7272
    7373bool ClassID::process(){
     74  COUT(3) << "processing classid: " << getClassID() << " name: " << &data_[ sizeof(network::packet::ENUM::Type) ] << std::endl;
    7475  orxonox::Identifier *id=ID( std::string((const char*)&data_[ sizeof(network::packet::ENUM::Type) ]) );
    7576  if(id==NULL)
  • code/branches/network/src/network/packet/Gamestate.cc

    r1712 r1713  
    106106  //start write gamestate header
    107107  HEADER->packetType = ENUM::Gamestate;
    108   assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate);
     108  assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate); 
    109109  HEADER->normsize = currentsize;
    110110  HEADER->id = id;
  • code/branches/network/src/network/packet/Packet.cc

    r1712 r1713  
    6161
    6262void blub(ENetPacket *packet){
    63   COUT(0) << "blubb" << std::endl;
     63  COUT(4) << "blubb" << std::endl;
    6464}
    6565
    6666Packet::Packet(unsigned char *data, int clientID){
    6767  flags_ = PACKET_FLAG_DEFAULT;
    68   packetDirection_ = ENUM::Outgoing;
     68  packetDirection_ = ENUM::Incoming;
    6969  clientID_=clientID;
    7070  data_=data;
     
    7272}
    7373
    74 Packet::Packet(ENetPacket *packet, ENetPeer *peer){
     74/*Packet::Packet(ENetPacket *packet, ENetPeer *peer){
    7575  packetDirection_ = ENUM::Incoming;
    7676  enetPacket_ = packet;
    7777  clientID_ = ClientInformation::findClient(&peer->address)->getID();
    7878  data_ = packet->data;
    79 }
     79}*/
    8080
    8181Packet::Packet(const Packet &p){
     
    107107    }
    108108    enetPacket_ = enet_packet_create(getData(), getSize(), getFlags());
     109    //enetPacket_->freeCallback = &Packet::deletePacket;
    109110    enetPacket_->freeCallback = &blub;
    110111    packetMap_[enetPacket_] = this;
     
    119120  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    120121  Packet *p;
     122  COUT(3) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    121123  switch( *(ENUM::Type *)&data[_PACKETID] )
    122124  {
    123125    case ENUM::Acknowledgement:
     126      COUT(3) << "ack" << std::endl;
    124127      p = new Acknowledgement( data, clientID );
    125128      break;
    126129    case ENUM::Chat:
     130      COUT(3) << "chat" << std::endl;
    127131      p = new Chat( data, clientID );
    128132      break;
    129133    case ENUM::ClassID:
     134      COUT(3) << "classid" << std::endl;
    130135      p = new ClassID( data, clientID );
    131136      break;
    132137    case ENUM::Gamestate:
     138      COUT(3) << "gamestate" << std::endl;
    133139      // TODO: remove brackets
    134140      p = new Gamestate( data, true, clientID );
    135141      break;
    136142    case ENUM::Welcome:
     143      COUT(3) << "welcome" << std::endl;
    137144      p = new Welcome( data, clientID );
    138145    default:
  • code/branches/network/src/network/packet/Packet.h

    r1711 r1713  
    7575    Packet();
    7676    Packet(unsigned char *data, int clientID);
    77     Packet(ENetPacket *packet, ENetPeer *peer);
     77//    Packet(ENetPacket *packet, ENetPeer *peer);
    7878    enet_uint32 flags_;
    7979    int clientID_;
  • code/branches/network/src/network/packet/Welcome.cc

    r1711 r1713  
    4949  data_=new unsigned char[ getSize() ];
    5050  assert(data_);
    51   *(packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Welcome;
     51  *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
    5252  *(unsigned int *)&data_[ _CLIENTID ] = clientID;
    5353  *(unsigned int *)&data_[ _SHIPID ] = shipID;
Note: See TracChangeset for help on using the changeset viewer.