Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2944 for code/branches


Ignore:
Timestamp:
May 1, 2009, 9:47:34 AM (16 years ago)
Author:
scheusso
Message:

this is another commit for testing purpose
still trying to get network function calls to work (first success)

Location:
code/branches/netp2/src
Files:
9 edited

Legend:

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

    r2937 r2944  
    5757{
    5858  std::map<uint32_t, packet::FunctionCalls*>::iterator it;
    59   for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++)
     59  for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); )
     60  {
    6061    it->second->send();
     62    clientMap_.erase(it++);
     63  }
    6164}
    6265
  • code/branches/netp2/src/network/NetworkFunction.cc

    r2937 r2944  
    5858 
    5959 
    60   NetworkFunctionStatic::NetworkFunctionStatic(Functor* functor, std::string name, const NetworkFunctionPointer& p):
     60  NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p):
    6161    NetworkFunctionBase(name)
    6262  {
    6363    RegisterObject(NetworkFunctionStatic);
    6464   
     65    this->functor_ = functor;
    6566    functorMap_[p] = this;
    6667    idMap_[ this->getNetworkID() ] = this;
  • code/branches/netp2/src/network/NetworkFunction.h

    r2943 r2944  
    7777    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
    7878   
    79    
    8079    static inline void setNetworkID(std::string name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
    8180   
     81  protected:
     82    static std::map<uint32_t, bool> isStaticMap_;
     83   
    8284  private:
    8385    static std::map<std::string, NetworkFunctionBase*> nameMap_;
    84     static std::map<uint32_t, bool> isStaticMap_;
    8586    uint32_t networkID_;
    8687    std::string name_;
     
    9192class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    9293  public:
    93     NetworkFunctionStatic(Functor* functor, std::string name, const NetworkFunctionPointer& p);
     94    NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p);
    9495    ~NetworkFunctionStatic();
    9596   
     
    152153    FunctorMember<T>* functor_;
    153154};
     155
     156template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p):
     157    NetworkMemberFunctionBase(name, p), functor_(functor)
     158{
     159}
    154160
    155161
  • code/branches/netp2/src/network/Server.cc

    r2773 r2944  
    6060#include "util/Convert.h"
    6161#include "ChatListener.h"
     62#include "FunctionCallManager.h"
     63#include "packet/FunctionIDs.h"
     64
    6265
    6366namespace orxonox
     
    157160      gamestates_->processGamestates();
    158161      updateGamestate();
     162      FunctionCallManager::sendCalls();
    159163    }
    160164  }
     
    340344      return false;
    341345    }
    342     COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
     346    COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
     347   
     348    // synchronise class ids
    343349    connection->syncClassid(temp->getID());
     350   
     351    // now synchronise functionIDs
     352    packet::FunctionIDs *fIDs = new packet::FunctionIDs();
     353    bool b = fIDs->send();
     354    assert(b);
     355   
    344356    temp->setSynched(true);
    345     COUT(3) << "sending welcome" << std::endl;
     357    COUT(4) << "sending welcome" << std::endl;
    346358    packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
    347359    w->setClientID(temp->getID());
    348     bool b = w->send();
     360    b = w->send();
    349361    assert(b);
    350362    packet::Gamestate *g = new packet::Gamestate();
  • code/branches/netp2/src/network/packet/FunctionCalls.cc

    r2938 r2944  
    7272  {
    7373    uint32_t functionID = *(uint32_t*)temp;
    74     bool isStatic = NetworkFunctionBase::isStatic( functionID );
     74    bool isStatic = *(uint8_t*)(temp+sizeof(uint32_t));
    7575    if( isStatic )
    7676    {
    7777      MultiType mt1, mt2, mt3, mt4, mt5;
    7878      NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( functionID );
    79       uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t));
    80       temp+=2*sizeof(uint32_t);
     79      uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t));
     80      temp+=2*sizeof(uint32_t)+sizeof(uint8_t);
    8181      switch(nrOfArguments)
    8282      {
     
    122122      MultiType mt1, mt2, mt3, mt4, mt5;
    123123      NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( functionID );
    124       uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t));
    125       uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t));
    126       temp+=3*sizeof(uint32_t);
     124      uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t));
     125      uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t));
     126      temp+=3*sizeof(uint32_t)+sizeof(uint8_t);
    127127      switch(nrOfArguments)
    128128      {
     
    166166    }
    167167  }
     168  delete this;
    168169  return true;
    169170}
     
    173174 
    174175  // first determine the size that has to be reserved for this call
    175   uint32_t callsize = 2*sizeof(uint32_t); //size for network-function-id and nrOfArguments
     176  uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
    176177  uint32_t nrOfArguments = 0;
    177178  if(mt1)
     
    211212  }
    212213 
    213   // now serialise the mt values and copy the function id
     214  // now serialise the mt values and copy the function id and isStatic
    214215  uint8_t* temp = data_+currentSize_;
    215216  *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
    216217  *(uint32_t*)temp = networkID;
    217   *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments;
    218   temp += 2*sizeof(uint32_t);
     218  *(uint8_t*)(temp+sizeof(uint32_t)) = true;
     219  *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments;
     220  temp += 2*sizeof(uint32_t)+sizeof(uint8_t);
    219221  if(mt1)
    220222  {
     
    237239    }
    238240  }
    239   currentSize_ += callsize;
     241  //currentSize_ += callsize;
     242  currentSize_ = temp-data_;
    240243 
    241244}
     
    245248 
    246249  // first determine the size that has to be reserved for this call
    247   uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
     250  uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID
    248251  uint32_t nrOfArguments = 0;
    249252  if(mt1)
     
    287290  *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
    288291  *(uint32_t*)temp = networkID;
    289   *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments;
    290   *(uint32_t*)(temp+2*sizeof(uint32_t)) = objectID;
    291   temp += 3*sizeof(uint32_t);
     292  *(uint8_t*)(temp+sizeof(uint32_t)) = false;
     293  *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments;
     294  *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)) = objectID;
     295  temp += 3*sizeof(uint32_t)+sizeof(uint8_t);
    292296  if(mt1)
    293297  {
  • code/branches/netp2/src/network/packet/Packet.cc

    r2937 r2944  
    3939
    4040#include "Acknowledgement.h"
     41#include "DeleteObjects.h"
    4142#include "Chat.h"
    4243#include "ClassID.h"
     44#include "FunctionCalls.h"
     45#include "FunctionIDs.h"
    4346#include "Gamestate.h"
    4447#include "Welcome.h"
    45 #include "DeleteObjects.h"
    4648#include "network/Host.h"
    4749#include "core/CoreIncludes.h"
     
    172174  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    173175  Packet *p = 0;
    174   COUT(5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
     176  COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    175177  switch( *(ENUM::Type *)(data + _PACKETID) )
    176178  {
    177179    case ENUM::Acknowledgement:
    178       COUT(4) << "ack" << std::endl;
     180      COUT(5) << "ack" << std::endl;
    179181      p = new Acknowledgement( data, clientID );
    180182      break;
    181183    case ENUM::Chat:
    182       COUT(4) << "chat" << std::endl;
     184      COUT(5) << "chat" << std::endl;
    183185      p = new Chat( data, clientID );
    184186      break;
    185187    case ENUM::ClassID:
    186       COUT(4) << "classid" << std::endl;
     188      COUT(5) << "classid" << std::endl;
    187189      p = new ClassID( data, clientID );
    188190      break;
    189191    case ENUM::Gamestate:
    190       COUT(4) << "gamestate" << std::endl;
     192      COUT(5) << "gamestate" << std::endl;
    191193      // TODO: remove brackets
    192194      p = new Gamestate( data, clientID );
    193195      break;
    194196    case ENUM::Welcome:
    195       COUT(4) << "welcome" << std::endl;
     197      COUT(5) << "welcome" << std::endl;
    196198      p = new Welcome( data, clientID );
    197199      break;
    198200    case ENUM::DeleteObjects:
    199       COUT(4) << "deleteobjects" << std::endl;
     201      COUT(5) << "deleteobjects" << std::endl;
    200202      p = new DeleteObjects( data, clientID );
     203      break;
     204    case ENUM::FunctionCalls:
     205      COUT(5) << "functionCalls" << std::endl;
     206      p = new FunctionCalls( data, clientID );
     207      break;
     208    case ENUM::FunctionIDs:
     209      COUT(5) << "functionIDs" << std::endl;
     210      p = new FunctionIDs( data, clientID );
    201211      break;
    202212    default:
  • code/branches/netp2/src/network/synchronisable/SynchronisableVariable.h

    r2861 r2944  
    268268        else{
    269269          // apply data
    270           mem += sizeof(varReference_);
    271           if ( checkEquality( this->variable_, mem )==true )
     270          if ( checkEquality( this->variable_, mem+sizeof(varReference_) )==true )
    272271          {
    273272            mem += getSize( mode );
     
    276275          else
    277276          {
     277            mem += sizeof(varReference_);
    278278            memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
    279279            if ( this->callback_ != 0 )
  • code/branches/netp2/src/orxonox/objects/Test.cc

    r2937 r2944  
    8282
    8383
    84         void Test::registerVariables()
    85         {
    86                 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     84  void Test::registerVariables()
     85  {
     86    registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
    8787    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
    88                 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     88    registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
    8989    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
    9090   
     
    9393    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
    9494    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    95         }
     95  }
    9696 
    9797  void Test::call(unsigned int clientID)
    9898  {
     99    callStaticNetworkFunction( &Test::printV1, clientID );
    99100    callStaticNetworkFunction( &Test::printV1, clientID );
    100101  }
  • code/branches/netp2/src/orxonox/objects/Test.h

    r2937 r2944  
    5050      void registerVariables();
    5151     
    52       void call(unsigned int clientID);
     52      static void call(unsigned int clientID);
    5353
    5454
Note: See TracChangeset for help on using the changeset viewer.