Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7495 for code/trunk/src


Ignore:
Timestamp:
Sep 28, 2010, 9:48:32 PM (14 years ago)
Author:
scheusso
Message:

buffering incoming function calls for non-existing objects works now

Location:
code/trunk/src
Files:
8 edited

Legend:

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

    r7284 r7495  
    175175    if(gamestate->processGamestates())
    176176    {
     177      FunctionCallManager::processBufferedFunctionCalls();
    177178      if(!isSynched_)
    178179        isSynched_=true;
  • code/trunk/src/libraries/network/FunctionCall.cc

    r7490 r7495  
    8080    {
    8181      case 0:
    82         fct->call(this->objectID_);
     82        if( !fct->call(this->objectID_) )
     83          return false;
    8384        break;
    8485      case 1:
    85         fct->call(this->objectID_, this->arguments_[0]);
     86        if( !fct->call(this->objectID_, this->arguments_[0]) )
     87          return false;
    8688        break;
    8789      case 2:
    88         fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
     90        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )
     91          return false;
    8992        break;
    9093      case 3:
    91         fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
     94        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )
     95          return false;
    9296        break;
    9397      case 4:
    94         fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
     98        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )
     99          return false;
    95100        break;
    96101      case 5:
    97         fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
     102        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )
     103          return false;
    98104        break;
    99105      default:
  • code/trunk/src/libraries/network/FunctionCall.h

    r7490 r7495  
    3232#include "network/NetworkPrereqs.h"
    3333#include "util/UtilPrereqs.h"
     34#include "util/MultiType.h"
    3435
    3536#include <cassert>
  • code/trunk/src/libraries/network/FunctionCallManager.cc

    r6417 r7495  
    2929#include "FunctionCallManager.h"
    3030#include "packet/FunctionCalls.h"
     31#include "core/GameMode.h"
    3132
    3233namespace orxonox {
    3334
    34 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
     35std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sClientMap_;
     36std::vector<FunctionCall> FunctionCallManager::sIncomingFunctionCallBuffer_;
    3537
    3638// Static calls
     
    3840void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
    3941{
    40   if(clientMap_.find(clientID)==clientMap_.end())
     42  if(sClientMap_.find(clientID)==sClientMap_.end())
    4143  {
    42     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    43     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     44    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     45    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    4446  }
    45   FunctionCallManager::clientMap_[clientID]->addCallStatic(functionID);
     47  FunctionCallManager::sClientMap_[clientID]->addCallStatic(functionID);
    4648}
    4749void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
    4850{
    49   if(clientMap_.find(clientID)==clientMap_.end())
     51  if(sClientMap_.find(clientID)==sClientMap_.end())
    5052  {
    51     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    52     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     53    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     54    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    5355  }
    54   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
     56  FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1);
    5557}
    5658void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
    5759{
    58   if(clientMap_.find(clientID)==clientMap_.end())
     60  if(sClientMap_.find(clientID)==sClientMap_.end())
    5961  {
    60     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    61     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     62    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     63    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    6264  }
    63   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
     65  FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
    6466}
    6567void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    6668{
    67   if(clientMap_.find(clientID)==clientMap_.end())
     69  if(sClientMap_.find(clientID)==sClientMap_.end())
    6870  {
    69     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    70     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     71    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     72    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    7173  }
    72   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
     74  FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
    7375}
    7476void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    7577{
    76   if(clientMap_.find(clientID)==clientMap_.end())
     78  if(sClientMap_.find(clientID)==sClientMap_.end())
    7779  {
    78     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    79     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     80    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     81    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    8082  }
    81   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
     83  FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
    8284}
    8385void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    8486{
    85   if(clientMap_.find(clientID)==clientMap_.end())
     87  if(sClientMap_.find(clientID)==sClientMap_.end())
    8688  {
    87     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    88     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     89    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     90    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    8991  }
    90   FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
     92  FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
    9193}
    9294
     
    9698void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
    9799{
    98   if(clientMap_.find(clientID)==clientMap_.end())
     100  if(sClientMap_.find(clientID)==sClientMap_.end())
    99101  {
    100     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    101     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     102    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     103    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    102104  }
    103   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
     105  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID);
    104106}
    105107void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
    106108{
    107   if(clientMap_.find(clientID)==clientMap_.end())
     109  if(sClientMap_.find(clientID)==sClientMap_.end())
    108110  {
    109     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    110     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     111    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     112    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    111113  }
    112   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
     114  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
    113115}
    114116void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
    115117{
    116   if(clientMap_.find(clientID)==clientMap_.end())
     118  if(sClientMap_.find(clientID)==sClientMap_.end())
    117119  {
    118     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    119     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     120    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     121    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    120122  }
    121   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
     123  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
    122124}
    123125void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    124126{
    125   if(clientMap_.find(clientID)==clientMap_.end())
     127  if(sClientMap_.find(clientID)==sClientMap_.end())
    126128  {
    127     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    128     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     129    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     130    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    129131  }
    130   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
     132  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
    131133}
    132134void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    133135{
    134   if(clientMap_.find(clientID)==clientMap_.end())
     136  if(sClientMap_.find(clientID)==sClientMap_.end())
    135137  {
    136     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    137     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     138    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     139    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    138140  }
    139   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
     141  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
    140142}
    141143void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    142144{
    143   if(clientMap_.find(clientID)==clientMap_.end())
     145  if(sClientMap_.find(clientID)==sClientMap_.end())
    144146  {
    145     FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
    146     FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
     147    FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
     148    FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
    147149  }
    148   FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
     150  FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
    149151}
    150152
     
    154156{
    155157  std::map<uint32_t, packet::FunctionCalls*>::iterator it;
    156   for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++ )
     158  for (it = FunctionCallManager::sClientMap_.begin(); it != FunctionCallManager::sClientMap_.end(); ++it )
    157159  {
    158     assert(!FunctionCallManager::clientMap_.empty());
     160    assert(!FunctionCallManager::sClientMap_.empty());
    159161    it->second->send();
    160162  }
    161   FunctionCallManager::clientMap_.clear();
     163  FunctionCallManager::sClientMap_.clear();
     164}
     165
     166void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall)
     167{
     168  if( !GameMode::isMaster() )
     169    FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( fctCall );
     170}
     171
     172void FunctionCallManager::processBufferedFunctionCalls()
     173{
     174  std::vector<FunctionCall>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
     175  while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
     176  {
     177    if( it->execute() )
     178      FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it);
     179    else
     180      ++it;
     181  }
    162182}
    163183
  • code/trunk/src/libraries/network/FunctionCallManager.h

    r6417 r7495  
    3333
    3434#include <map>
     35#include <vector>
    3536#include "util/UtilPrereqs.h"
     37#include "FunctionCall.h"
    3638
    3739namespace orxonox {
     
    5860
    5961  static void sendCalls();
     62 
     63  static void bufferIncomingFunctionCall( const FunctionCall& fctCall );
     64  static void processBufferedFunctionCalls();
    6065
    61   static std::map<uint32_t, packet::FunctionCalls*> clientMap_;
     66  static std::map<uint32_t, packet::FunctionCalls*> sClientMap_;
     67  static std::vector<FunctionCall>                  sIncomingFunctionCallBuffer_;
    6268protected:
    6369  FunctionCallManager();
  • code/trunk/src/libraries/network/NetworkFunction.h

    r7284 r7495  
    139139
    140140    //
    141     virtual void call(uint32_t objectID)=0;
    142     virtual void call(uint32_t objectID, const MultiType& mt1)=0;
    143     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
    144     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
    145     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
    146     virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
     141    virtual bool call(uint32_t objectID)=0;
     142    virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
     143    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
     144    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
     145    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
     146    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
    147147
    148148  private:
     
    156156    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
    157157
    158     inline void call(uint32_t objectID)
    159     {
    160       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     158    inline bool call(uint32_t objectID)
     159    {
     160      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     161      {
    161162        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)));
    162     }
    163     inline void call(uint32_t objectID, const MultiType& mt1)
    164     {
    165       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     163        return true;
     164      }
     165      else
     166        return false;
     167    }
     168    inline bool call(uint32_t objectID, const MultiType& mt1)
     169    {
     170      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     171      {
    166172        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
    167     }
    168     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
    169     {
    170       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     173        return true;
     174      }
     175      else
     176        return false;
     177    }
     178    inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
     179    {
     180      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     181      {
    171182        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
    172     }
    173     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    174     {
    175       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     183        return true;
     184      }
     185      else
     186        return false;
     187    }
     188    inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
     189    {
     190      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     191      {
    176192        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
    177     }
    178     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    179     {
    180       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     193        return true;
     194      }
     195      else
     196        return false;
     197    }
     198    inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
     199    {
     200      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     201      {
    181202        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
    182     }
    183     inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    184     {
    185       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     203        return true;
     204      }
     205      else
     206        return false;
     207    }
     208    inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
     209    {
     210      if ( Synchronisable::getSynchronisable(objectID)!=0 )
     211      {
    186212        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
     213        return true;
     214      }
     215      else
     216        return false;
    187217    }
    188218
  • code/trunk/src/libraries/network/packet/FunctionCalls.cc

    r7490 r7495  
    3131#include <cassert>
    3232#include "network/FunctionCall.h"
     33#include "network/FunctionCallManager.h"
    3334
    3435namespace orxonox {
     
    6667    FunctionCall fctCall;
    6768    fctCall.loadData(temp);
    68     fctCall.execute();
     69    if( !fctCall.execute() )
     70      FunctionCallManager::bufferIncomingFunctionCall( fctCall );
    6971  }
    7072 
  • code/trunk/src/orxonox/worldentities/ControllableEntity.cc

    r6417 r7495  
    8787        this->setPriority( Priority::VeryHigh );
    8888        this->registerVariables();
     89        COUT(0) << "CE creator" << endl;
     90        if( GameMode::isMaster() )
     91          callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 1, 0);
    8992    }
    9093
     
    241244    void ControllableEntity::fire(unsigned int firemode)
    242245    {
     246        COUT(0) << "fire........." << endl;
    243247        if(GameMode::isMaster())
    244248        {
Note: See TracChangeset for help on using the changeset viewer.