Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1710


Ignore:
Timestamp:
Sep 5, 2008, 12:27:37 PM (16 years ago)
Author:
scheusso
Message:

further errors corrected (mostly double frees, etc)

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

Legend:

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

    r1705 r1710  
    155155      if(gs){
    156156        COUT(4) << "client tick: sending gs " << gs << std::endl;
    157         packet::Packet p(gs);
    158         if( !p.send() )
     157        packet::Packet packet(gs);
     158        if( !packet.send() )
    159159          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
    160160        // now delete it to save memory
     
    173173    if(gameStateID==GAMESTATEID_INITIAL)
    174174      if(gameStateFailure_){
    175         packet::Packet packet(new packet::Acknowledgement(GAMESTATEID_INITIAL, 0));
     175        packet::Acknowledgement ack(GAMESTATEID_INITIAL, 0);
     176        packet::Packet packet(&ack);
    176177        if(!packet.send())
    177178          COUT(3) << "could not (negatively) ack gamestate" << std::endl;
     
    186187        isSynched_=true;
    187188      gameStateFailure_=false;
    188       packet::Packet packet(new packet::Acknowledgement(gameStateID, 0));
     189      packet::Acknowledgement ack(gameStateID, 0);
     190      packet::Packet packet(&ack);
    189191      if(!packet.send())
    190192        COUT(3) << "could not ack gamestate" << std::endl;
  • code/branches/network/src/network/ConnectionManager.cc

    r1705 r1710  
    360360      ++it;
    361361    }
    362     packet.setPacketContent(0);
    363362    //sendPackets();
    364363    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
  • code/branches/network/src/network/GamestateHandler.h

    r1706 r1710  
    5252   
    5353  public:
    54     static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->addGamestate(gs, clientID); }
     54    static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }
    5555    static bool ackGamestate(int gamestateID, int clientID){ return instance_->ack(gamestateID, clientID); }
    5656};
  • code/branches/network/src/network/Server.cc

    r1709 r1710  
    121121      if(!pkt->send())
    122122        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
     123      delete pkt;
    123124    }
    124125    return message->process();
     
    140141        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
    141142    }
    142     return chat->process();
     143    return chat->process();;
    143144  }
    144145
     
    269270      added=true;
    270271      temp=temp->next();
    271       // now delete gamestate
    272272      delete gs;
    273273    }
     
    323323    temp->setSynched(true);
    324324    COUT(3) << "sending welcome" << std::endl;
    325     packet::Packet packet(new packet::Welcome(temp->getID(), temp->getShipID()));
     325    packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
     326    packet::Packet packet(w);
    326327    assert(packet.send());
     328    delete w;
    327329    return true;
    328330  }
  • code/branches/network/src/network/packet/Gamestate.cc

    r1705 r1710  
    8080 
    8181  //start write gamestate header
     82  HEADER->packetType = ENUM::Gamestate;
    8283  HEADER->normsize = currentsize;
    8384  HEADER->id = id;
  • code/branches/network/src/network/packet/Gamestate.h

    r1705 r1710  
    2828
    2929#include "PacketContent.h"
     30#include "Packet.h"
    3031#include "network/Synchronisable.h"
    3132//#include "util/Bytestream.h"
     
    4041 
    4142struct GamestateHeader{
     43  ENUM::Type packetType;
    4244  int id; // id of the gamestate
    4345  unsigned int compsize;
  • code/branches/network/src/network/packet/Packet.cc

    r1709 r1710  
    4141  packetContent_ = createPacketContent(packet);
    4242  enet_packet_destroy(packet);
    43   delete peer;
    4443}
    4544
    4645Packet::~Packet(){
    47   if(packetContent_)
    48     delete packetContent_;
    4946  if(enetPacket_){
    5047    enet_packet_destroy(enetPacket_);
     
    6663    if(!packetContent_)
    6764      return false;
    68     COUT(3) << "creating packet with data: " << packetContent_->getData() << " size: " << packetContent_->getSize() << " and flags: " << packetContent_->getFlags() << std::endl;
    6965    enetPacket_ = enet_packet_create(packetContent_->getData(), packetContent_->getSize(), packetContent_->getFlags());
    7066  }
     
    9288      break;
    9389    default:
    94       assert(0);
     90      assert(0); //TODO: repair this
     91      break;
    9592  }
    9693  return packetContent_;
Note: See TracChangeset for help on using the changeset viewer.