Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7882 for code/branches


Ignore:
Timestamp:
Feb 14, 2011, 9:00:48 AM (14 years ago)
Author:
scheusso
Message:

improving gamestate processing and generation

Location:
code/branches/network6/src/libraries/network
Files:
3 edited

Legend:

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

    r7878 r7882  
    155155        COUT(4) << "popping partial gamestate: " << std::endl;
    156156//         packet::Gamestate *gs = GamestateClient::getGamestate();
    157         GamestateManager::update();
    158         std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
    159         std::vector<packet::Gamestate*>::iterator it;
    160         for( it = gamestates.begin(); it != gamestates.end(); ++it )
     157        if( GamestateManager::update() )
    161158        {
    162           (*it)->send( static_cast<Host*>(this) );
     159          std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
     160          std::vector<packet::Gamestate*>::iterator it;
     161          for( it = gamestates.begin(); it != gamestates.end(); ++it )
     162          {
     163            (*it)->send( static_cast<Host*>(this) );
     164          }
    163165        }
    164166        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
  • code/branches/network6/src/libraries/network/GamestateManager.cc

    r7878 r7882  
    5757
    5858namespace orxonox
    59 {
     59{ 
    6060  GamestateManager::GamestateManager() :
    6161  currentGamestate_(0), id_(0)
     
    110110      bool b = processGamestate(it->second);
    111111      assert(b);
    112 //       sendAck( it->second->getID(), it->second->getPeerID() );
     112      sendAck( it->second->getID(), it->second->getPeerID() );
    113113      delete it->second;
    114114    }
     
    140140    if ( currentGamestate_ != 0 )
    141141      delete currentGamestate_;
    142     currentGamestate_ = new packet::Gamestate();
    143142    uint8_t gsMode;
    144143    if( GameMode::isMaster() )
     
    153152      assert(peerMap_.size()!=0);
    154153      newID = peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
     154      if( newID == GAMESTATEID_INITIAL )
     155      {
     156        return false;
     157      }
    155158    }
    156159   
    157     if(!currentGamestate_->collectData(newID, gsMode)){ //we have no data to send
     160    currentGamestate_ = new packet::Gamestate();
     161   
     162    if(!currentGamestate_->collectData(newID, gsMode))
     163    { //we have no data to send
    158164      delete currentGamestate_;
    159165      currentGamestate_=0;
     166      return false;
    160167    }
    161168    return true;
  • code/branches/network6/src/libraries/network/Server.cc

    r7878 r7882  
    417417    b = w->send( static_cast<Host*>(this) );
    418418    assert(b);
    419     packet::Gamestate *g = new packet::Gamestate();
    420     g->setPeerID(clientID);
    421     b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
    422     assert(b);
    423     if(!b)
    424       return false; //no data for the client
    425 //     b = g->compressData();
     419//     packet::Gamestate *g = new packet::Gamestate();
     420//     g->setPeerID(clientID);
     421//     b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
    426422//     assert(b);
    427     b = g->send( static_cast<Host*>(this) );
    428     assert(b);
     423//     if(!b)
     424//       return false; //no data for the client
     425// //     b = g->compressData();
     426// //     assert(b);
     427//     b = g->send( static_cast<Host*>(this) );
     428//     assert(b);
    429429    return true;
    430430  }
Note: See TracChangeset for help on using the changeset viewer.