Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2009, 9:20:57 PM (15 years ago)
Author:
landauf
Message:

merged netp3 branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/Client.cc

    r2896 r3084  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2007
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    4848#include "core/CoreIncludes.h"
    4949#include "packet/Packet.h"
     50#include "FunctionCallManager.h"
    5051
    5152// #include "packet/Acknowledgement.h"
     
    140141   */
    141142  void Client::update(const Clock& time){
    142 //     COUT(3) << ".";
    143     if(client_connection.isConnected() && isSynched_){
    144       COUT(4) << "popping partial gamestate: " << std::endl;
    145       packet::Gamestate *gs = gamestate.getGamestate();
    146       if(gs){
    147         COUT(4) << "client tick: sending gs " << gs << std::endl;
    148         if( !gs->send() )
    149           COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
     143    //this steers our network frequency
     144    timeSinceLastUpdate_+=time.getDeltaTime();
     145    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
     146      timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
     147      //     COUT(3) << ".";
     148      if(client_connection.isConnected() && isSynched_){
     149        COUT(4) << "popping partial gamestate: " << std::endl;
     150        packet::Gamestate *gs = gamestate.getGamestate();
     151        //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
     152        if(gs){
     153          COUT(4) << "client tick: sending gs " << gs << std::endl;
     154          if( !gs->send() )
     155            COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
    150156        // gs gets automatically deleted by enet callback
     157        }
     158        FunctionCallManager::sendCalls();
    151159      }
    152160    }
     161   
    153162    ENetEvent *event;
    154163    // stop if the packet queue is empty
     
    167176    }
    168177    gamestate.cleanup();
     178
    169179    return;
    170180  }
Note: See TracChangeset for help on using the changeset viewer.