Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1712


Ignore:
Timestamp:
Sep 6, 2008, 1:39:51 PM (16 years ago)
Author:
scheusso
Message:

enet callback disabled

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

Legend:

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

    r1707 r1712  
    7474    int id = GAMESTATEID_INITIAL;
    7575    bool b = saveShipCache();
    76     if(tempGamestate_->spreadData()){
     76    if(processGamestate(tempGamestate_)){
    7777      if(b)
    7878        loadShipCache();
     
    151151  }
    152152
     153  bool GamestateClient::processGamestate(packet::Gamestate *gs){
     154    assert(gs->decompressData());
     155    if(gs->isDiffed())
     156      assert(gs->undiff(gamestateMap_[gs->getBaseID()]));
     157    return gs->spreadData();
     158  }
    153159
    154160}
  • code/branches/network/src/network/GamestateClient.h

    r1707 r1712  
    6666    void cleanup();
    6767  private:
     68    bool processGamestate(packet::Gamestate *gs);
    6869    void removeObject(orxonox::Iterator<Synchronisable> &it);
    6970    void printGamestateMap();
  • code/branches/network/src/network/GamestateManager.cc

    r1705 r1712  
    8181    // now push only the most recent gamestates we received (ignore obsolete ones)
    8282    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
    83       it->second->spreadData();
     83      assert(processGamestate(it->second));
    8484      delete it->second;
    8585    }
     
    197197    ClientInformation::removeClient(client->getID());
    198198  }
     199 
     200  bool GamestateManager::processGamestate(packet::Gamestate *gs){
     201    assert(gs->decompressData());
     202    assert(!gs->isDiffed());
     203    return gs->spreadData();
     204  }
    199205
    200206}
  • code/branches/network/src/network/GamestateManager.h

    r1705 r1712  
    8282    private:
    8383    void cleanup(); // "garbage handler"
    84 
     84    bool processGamestate(packet::Gamestate *gs);
     85   
    8586    std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
    8687    std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
  • code/branches/network/src/network/Server.cc

    r1711 r1712  
    131131  bool Server::sendChat(packet::Chat *chat) {
    132132    //TODO: change this (no informations about who wrote a message)
     133    assert(0);
    133134    ClientInformation *temp = ClientInformation::getBegin();
    134135    while(temp){
     
    321322    w->setClientID(temp->getID());
    322323    assert(w->send());
    323     delete w;
    324324    return true;
    325325  }
  • code/branches/network/src/network/packet/Chat.cc

    r1711 r1712  
    4444  messageLength_ = message.length()+1;
    4545  data_=new unsigned char[ getSize() ];
    46   *(ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Chat;
     46  *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::Chat;
    4747  *(unsigned int *)&data_[ _MESSAGELENGTH ] = messageLength_;
    4848  memcpy( &data_[ _MESSAGE ], (void *)message.c_str(), messageLength_ );
  • code/branches/network/src/network/packet/ClassID.cc

    r1711 r1712  
    5151  data_=new unsigned char[ getSize() ];
    5252  assert(data_);
    53   *(packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::ClassID;
     53  *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::ClassID;
    5454  *(unsigned int *)&data_[ _CLASSID ] = classID;
    5555  *(unsigned int *)&data_[ _CLASSNAMELENGTH ] = classNameLength_;
  • code/branches/network/src/network/packet/Gamestate.cc

    r1711 r1712  
    1 
    2 
    3 
    4 
    5 
    6 
    7 
    8 
    9 
    10 
    11 
    12 
    13 
    14 
    15 
    16 
    17 
    18 
    191/*
    202 *   ORXONOX - the hottest 3D action shooter ever to exist
     
    124106  //start write gamestate header
    125107  HEADER->packetType = ENUM::Gamestate;
     108  assert( *(ENUM::Type *)&data_[ 0 ] == ENUM::Gamestate);
    126109  HEADER->normsize = currentsize;
    127110  HEADER->id = id;
     
    230213bool Gamestate::decompressData()
    231214{
     215  assert(compressed_);
    232216  //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
    233217  int normsize = HEADER->normsize;
     
    256240  *GAMESTATE_HEADER(ndata) = *HEADER;
    257241  //delete old (compressed data)
    258   delete []data_;
     242  delete[] data_;
    259243  //set new pointers and create bytestream
    260244  data_ = ndata;
     
    349333  }
    350334
    351 }
    352 
    353 }
     335  bool Gamestate::isDiffed(){
     336    return HEADER->diffed;
     337  }
     338 
     339  int Gamestate::getBaseID(){
     340    return HEADER->base_id;
     341  }
     342}
     343
     344}
  • code/branches/network/src/network/packet/Gamestate.h

    r1711 r1712  
    6262    bool spreadData(int mode=0x0);
    6363    int getID();
     64    bool isDiffed();
     65    int getBaseID();
    6466    Gamestate *diff(Gamestate *base);
    6567    Gamestate *undiff(Gamestate *base);
  • code/branches/network/src/network/packet/Packet.cc

    r1711 r1712  
    6060}
    6161
     62void blub(ENetPacket *packet){
     63  COUT(0) << "blubb" << std::endl;
     64}
     65
    6266Packet::Packet(unsigned char *data, int clientID){
    6367  flags_ = PACKET_FLAG_DEFAULT;
     
    7377  clientID_ = ClientInformation::findClient(&peer->address)->getID();
    7478  data_ = packet->data;
    75   enet_packet_destroy(packet);
    7679}
    7780
    7881Packet::Packet(const Packet &p){
     82  enetPacket_=p.enetPacket_;
    7983  flags_=p.flags_;
    8084  if(p.data_){
     
    9397
    9498bool Packet::send(){
    95   if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional )
     99  /*if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
     100    assert(0);
    96101    return false;
     102  }*/
    97103  if(!enetPacket_){
    98     if(!data_)
     104    if(!data_){
     105      assert(0);
    99106      return false;
     107    }
    100108    enetPacket_ = enet_packet_create(getData(), getSize(), getFlags());
    101     enetPacket_->freeCallback = &Packet::deletePacket;
     109    enetPacket_->freeCallback = &blub;
    102110    packetMap_[enetPacket_] = this;
    103111  }
Note: See TracChangeset for help on using the changeset viewer.