Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2009, 9:35:10 PM (15 years ago)
Author:
scheusso
Message:

merged netp2 → netp3

Location:
code/branches/netp3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3

  • code/branches/netp3/src/network/Client.cc

    r2896 r2990  
    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;
     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        if(gs){
     152          COUT(4) << "client tick: sending gs " << gs << std::endl;
     153          if( !gs->send() )
     154            COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
    150155        // gs gets automatically deleted by enet callback
     156        }
     157        FunctionCallManager::sendCalls();
    151158      }
     159      ENetEvent *event;
     160    // stop if the packet queue is empty
     161      while(!(client_connection.queueEmpty())){
     162        event = client_connection.getEvent();
     163        COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
     164        packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
     165      // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
     166        bool b = packet->process();
     167        assert(b);
     168      }
     169      if(gamestate.processGamestates())
     170      {
     171        if(!isSynched_)
     172          isSynched_=true;
     173      }
     174      gamestate.cleanup();
    152175    }
    153     ENetEvent *event;
    154     // stop if the packet queue is empty
    155     while(!(client_connection.queueEmpty())){
    156       event = client_connection.getEvent();
    157       COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
    158       packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
    159       // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
    160       bool b = packet->process();
    161       assert(b);
    162     }
    163     if(gamestate.processGamestates())
    164     {
    165       if(!isSynched_)
    166         isSynched_=true;
    167     }
    168     gamestate.cleanup();
     176
    169177    return;
    170178  }
Note: See TracChangeset for help on using the changeset viewer.