Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2011, 8:22:36 PM (14 years ago)
Author:
scheusso
Message:

merging network6 into trunk

Location:
code/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/packet/Gamestate.cc

    r7844 r8327  
    107107  uint32_t size = calcGamestateSize(id, mode);
    108108
    109   COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
     109  COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
    110110  if(size==0)
    111111    return false;
     
    158158  //start write gamestate header
    159159  header_.setDataSize( currentsize );
     160  header_.setCompSize( 0 );
    160161  header_.setID( id );
    161162  header_.setBaseID( GAMESTATEID_INITIAL );
  • code/trunk/src/libraries/network/packet/Packet.cc

    r7801 r8327  
    4747#include "Welcome.h"
    4848#include "network/Host.h"
    49 #include "network/ClientInformation.h"
     49// #include "network/ClientInformation.h"
    5050
    5151namespace orxonox{
     
    8585
    8686
    87 Packet::Packet(const Packet &p){
     87Packet::Packet(const Packet &p)
     88{
    8889  enetPacket_=p.enetPacket_;
    8990  flags_=p.flags_;
     
    104105    That also means destroying the ENetPacket if one exists. There
    105106*/
    106 Packet::~Packet(){
     107Packet::~Packet()
     108{
    107109  // Deallocate data_ memory if necessary.
    108   if (this->bDataENetAllocated_){
     110  if (this->bDataENetAllocated_)
     111  {
    109112    // In this case ENet allocated data_ and will destroy it.
    110113  }
    111   else if (this->data_) {
     114  else if (this->data_)
     115  {
    112116    // This destructor was probably called as a consequence of ENet executing our callback.
    113117    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
     
    119123  // Note: For the case ENet used the callback to destroy the packet, we have already set
    120124  // enetPacket_ to NULL to avoid destroying it again.
    121   if (this->enetPacket_){
     125  if (this->enetPacket_)
     126  {
    122127    // enetPacket_->data gets destroyed too by ENet if it was allocated by it.
    123128    enet_packet_destroy(enetPacket_);
     
    125130}
    126131
    127 bool Packet::send(orxonox::Host* host){
    128   if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){
     132bool Packet::send(orxonox::Host* host)
     133{
     134  if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional )
     135  {
    129136    assert(0);
    130137    return false;
    131138  }
    132   if(!enetPacket_){
     139  if(!enetPacket_)
     140  {
    133141    if(!data_){
    134142      assert(0);
     
    175183}
    176184
    177 Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
     185Packet *Packet::createPacket(ENetPacket* packet, uint32_t peerID)
     186{
    178187  uint8_t *data = packet->data;
    179   assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
    180   unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
     188//   assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
     189//   unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
    181190  // HACK
    182   if( peerID==static_cast<unsigned int>(-2))
    183     peerID = NETWORK_PEER_ID_SERVER;
     191//   if( peerID==static_cast<unsigned int>(-2))
     192//     peerID = NETWORK_PEER_ID_SERVER;
    184193  Packet *p = 0;
    185194//   COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
     
    235244    data we allocated ourselves.
    236245*/
    237 void Packet::deletePacket(ENetPacket *enetPacket){
     246void Packet::deletePacket(ENetPacket *enetPacket)
     247{
    238248  // Get our Packet from a global map with all Packets created in the send() method of Packet.
    239249  Packet::packetMapMutex_.lock();
  • code/trunk/src/libraries/network/packet/Packet.h

    r7801 r8327  
    3232#include <map>
    3333
    34 namespace orxonox {
     34namespace orxonox
     35{
    3536
    36 namespace packet{
     37namespace packet
     38{
    3739
    38 namespace Direction{
    39   enum Value{
     40namespace Direction
     41{
     42  enum Value
     43  {
    4044    Incoming,
    4145    Outgoing,
     
    4347  };
    4448}
    45 namespace Type{
    46   enum Value{
     49namespace Type
     50{
     51  enum Value
     52  {
    4753    Acknowledgement,
    4854    Chat,
     
    5965    @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
    6066*/
    61 class _NetworkExport Packet{
     67class _NetworkExport Packet
     68{
    6269  public:
    6370    Packet(const Packet &p);
    6471    virtual ~Packet();
    65     static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
    66     static void deletePacket(ENetPacket *packet);
     72    static Packet* createPacket(ENetPacket* packet, uint32_t peerID);
     73    static void deletePacket(ENetPacket* packet);
    6774
    68     virtual unsigned char *getData(){ return data_; };
     75    virtual unsigned char* getData(){ return data_; };
    6976    virtual unsigned int getSize() const =0;
    7077    virtual bool process(orxonox::Host* host)=0;
Note: See TracChangeset for help on using the changeset viewer.