Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 5, 2008, 11:32:42 PM (16 years ago)
Author:
scheusso
Message:

we use enetcallback for destroying packets now (unfortunately there are still some problems)

File:
1 edited

Legend:

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

    r1710 r1711  
    123123  }
    124124 
    125   bool Client::sendChat(packet::Chat *chat){
     125  /*bool Client::sendChat(packet::Chat *chat){
    126126    chat->process();
    127127    packet::Packet *p = new packet::Packet(chat);
    128128    return p->send();
    129   }
     129  }*/
    130130 
    131131
     
    139139    if(!isConnected)
    140140      return false;
    141     packet::Packet p(new packet::Chat(message, clientID_));
    142     return p.send();
    143       //return client_connection.sendPackets();
     141    packet::Chat chat(message, 0);
     142    return chat.send();
    144143    // send packets
    145144  }
     
    155154      if(gs){
    156155        COUT(4) << "client tick: sending gs " << gs << std::endl;
    157         packet::Packet packet(gs);
    158         if( !packet.send() )
     156        if( !gs->send() )
    159157          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
    160         // now delete it to save memory
    161         delete gs;
     158        // gs gets automatically deleted by enet callback
    162159      }
    163160    }
     
    167164      event = client_connection.getEvent();
    168165      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
    169       packet::Packet packet(event->packet, event->peer);
    170       assert(packet.getPacketContent()->process());
     166      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
     167      assert(packet->process());
    171168    }
    172169    int gameStateID = gamestate.processGamestates();
     
    174171      if(gameStateFailure_){
    175172        packet::Acknowledgement ack(GAMESTATEID_INITIAL, 0);
    176         packet::Packet packet(&ack);
    177         if(!packet.send())
     173        if(!ack.send())
    178174          COUT(3) << "could not (negatively) ack gamestate" << std::endl;
    179175        else
     
    188184      gameStateFailure_=false;
    189185      packet::Acknowledgement ack(gameStateID, 0);
    190       packet::Packet packet(&ack);
    191       if(!packet.send())
     186      if(!ack.send())
    192187        COUT(3) << "could not ack gamestate" << std::endl;
    193188    }// otherwise we had no gamestate to load
Note: See TracChangeset for help on using the changeset viewer.