Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2010, 8:54:00 PM (14 years ago)
Author:
scheusso
Message:

a lot of changes:

  • some fixes (mostly gamestate:diff)
  • FunctionCall buffering (if Gamestate is not recent enough)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network5/src/libraries/network/FunctionCallManager.cc

    r7495 r7759  
    3030#include "packet/FunctionCalls.h"
    3131#include "core/GameMode.h"
     32#include "GamestateHandler.h"
    3233
    3334namespace orxonox {
    3435
    3536std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sClientMap_;
    36 std::vector<FunctionCall> FunctionCallManager::sIncomingFunctionCallBuffer_;
     37std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
    3738
    3839// Static calls
     
    164165}
    165166
    166 void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall)
     167void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t clientID)
    167168{
    168   if( !GameMode::isMaster() )
    169     FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( fctCall );
     169  FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, clientID)));
    170170}
    171171
    172172void FunctionCallManager::processBufferedFunctionCalls()
    173173{
    174   std::vector<FunctionCall>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
     174  std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > >::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
    175175  while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
    176176  {
    177     if( it->execute() )
     177    uint32_t minGamestateID = it->second.first;
     178    uint32_t clientID       = it->second.second;
     179    if( minGamestateID <= GamestateHandler::getInstance()->getLastProcessedGamestateID(clientID) && it->first.execute() )
    178180      FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it);
    179181    else
     182    {
    180183      ++it;
     184    }
    181185  }
    182186}
Note: See TracChangeset for help on using the changeset viewer.