Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2990


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

merged netp2 → netp3

Location:
code/branches/netp3
Files:
111 edited
10 copied

Legend:

Unmodified
Added
Removed
  • code/branches/netp3

  • code/branches/netp3/bin/client1.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/bin/client2.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/bin/dedicated.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/bin/run.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/bin/server.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/bin/standalone.bat.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/cmake/FindDirectX.cmake

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/cmake/LibraryConfigTardis.cmake

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/LuaBind.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/LuaBind.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/Template.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/Template.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/XMLFile.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/core/XMLIncludes.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/cpptcl/cpptcl.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/cpptcl/cpptcl.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/network/CMakeLists.txt

    r2748 r2990  
    2525  ClientConnectionListener.cc
    2626  ConnectionManager.cc
     27  FunctionCallManager.cc
    2728  GamestateManager.cc
    2829  GamestateClient.cc
    2930  GamestateHandler.cc
     31  NetworkFunction.cc
     32  Host.cc
    3033  PacketBuffer.cc
    3134  Server.cc
    3235  TrafficControl.cc
    33   Host.cc
    3436)
    3537ADD_SUBDIRECTORY(packet)
  • 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  }
  • code/branches/netp3/src/network/Client.h

    r2896 r2990  
    8888
    8989    bool gameStateFailure_;
     90    float timeSinceLastUpdate_;
    9091  };
    9192
  • code/branches/netp3/src/network/ClientConnection.cc

    r2773 r2990  
    4242#include <enet/enet.h>
    4343#include <iostream>
     44#include <cassert>
    4445// boost.thread library for multithreading support
    4546#include <boost/thread/thread.hpp>
     
    5758
    5859  ClientConnection::ClientConnection(int port, const std::string& address) {
    59     quit=false;
     60    quit_=false;
    6061    server=NULL;
    6162    serverAddress = new ENetAddress();
     
    6667
    6768  ClientConnection::ClientConnection(int port, const char *address) {
    68     quit=false;
     69    quit_=false;
    6970    server=NULL;
    7071    serverAddress = new ENetAddress();
     
    106107
    107108  bool ClientConnection::closeConnection() {
    108     quit=true;
     109    quit_=true;
    109110    //network_threads.join_all();
    110111    receiverThread_->join();
     
    150151      COUT(2) << "ClientConnection: could not create client host" << std::endl;
    151152      // add some error handling here ==========================
    152       quit=true;
     153      quit_=true;
    153154    }
    154155    //connect to the server
    155156    if(!establishConnection()){
    156157      COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
    157       quit=true;
     158      quit_=true;
    158159      return;
    159160    }
    160161    event = new ENetEvent;
    161162    //main loop
    162     while(!quit){
     163    while(!quit_){
    163164      //std::cout << "connection loop" << std::endl;
    164165      {
     
    166167        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
    167168          // we should never reach this point
    168           quit=true;
    169           continue;
     169//              assert(0);
     170          printf("ClientConnection: ENet returned with an error!\n");
     171          quit_=true;
     172          break;
    170173          // add some error handling here ========================
    171174        }
     
    183186        break;
    184187      case ENET_EVENT_TYPE_DISCONNECT:
    185         quit=true;
     188        quit_=true;
     189        printf("Received disconnect Packet from Server!\n");
    186190        // server closed the connection
    187191        return;
     
    206210    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    207211    enet_peer_disconnect(server, 0);
    208     while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
     212    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) >= 0){
    209213      switch (event.type)
    210214      {
     
    233237    }
    234238    // handshake
    235     while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit){
     239    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit_){
    236240      if( event.type == ENET_EVENT_TYPE_CONNECT ){
    237241        established=true;
  • code/branches/netp3/src/network/ClientConnection.h

    r2773 r2990  
    5353    const int NETWORK_PORT = 55556;
    5454    const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
    55     const int NETWORK_CLIENT_WAIT_TIME = 1;
     55    const int NETWORK_CLIENT_WAIT_TIME = 10;
    5656    const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
    5757    const int NETWORK_CLIENT_CHANNELS = 2;
     
    7676    //bool sendPackets(ENetEvent *event);
    7777    bool waitEstablished(int milisec);
    78     bool isConnected(){return established;}
     78    inline bool isConnected(){return established;}
     79    inline bool checkConnection(){ return !quit_ && isConnected(); }
    7980  private:
    8081    ClientConnection(const ClientConnection& copy); // not used
     
    9091    ENetAddress *serverAddress;
    9192    // quit-variable (communication with threads)
    92     bool quit;
     93    bool quit_;
    9394    bool established;
    9495    // clientlist
  • code/branches/netp3/src/network/ConnectionManager.cc

    r2896 r2990  
    5858{
    5959  bool operator< (ENetAddress a, ENetAddress b) {
    60     if(a.host <= b.host)
    61       return true;
    62     else
    63       return false;
     60    return a.host <= b.host;
    6461  }
    6562}
     
    7572    assert(instance_==0);
    7673    instance_=this;
    77     quit=false;
     74    quit_=false;
    7875    bindAddress = new ENetAddress();
    7976    bindAddress->host = ENET_HOST_ANY;
     
    8481    assert(instance_==0);
    8582    instance_=this;
    86     quit=false;
     83    quit_=false;
    8784    bindAddress = new ENetAddress();
    8885    bindAddress->host = ENET_HOST_ANY;
     
    9390    assert(instance_==0);
    9491    instance_=this;
    95     quit=false;
     92    quit_=false;
    9693    bindAddress = new ENetAddress();
    9794    enet_address_set_host (bindAddress, address.c_str());
     
    10299    assert(instance_==0);
    103100    instance_=this;
    104     quit=false;
     101    quit_=false;
    105102    bindAddress = new ENetAddress();
    106103    enet_address_set_host (bindAddress, address);
     
    109106
    110107  ConnectionManager::~ConnectionManager(){
    111     if(!quit)
     108    if(!quit_)
    112109      quitListener();
    113110    instance_=0;
     
    133130
    134131  bool ConnectionManager::quitListener() {
    135     quit=true;
     132    quit_=true;
    136133    receiverThread_->join();
    137134    return true;
     
    189186    if(server==NULL){
    190187      // add some error handling here ==========================
    191       quit=true;
     188      quit_=true;
    192189      return;
    193190    }
    194191
    195192    event = new ENetEvent;
    196     while(!quit){
     193    while(!quit_)
     194    {
    197195      { //mutex scope
    198196        boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    199197        if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
    200198          // we should never reach this point
    201           quit=true;
     199          printf("ConnectionManager: ENet returned with an error\n");
     200          quit_=true;
    202201          continue;
     202          printf("waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh");
    203203          // add some error handling here ========================
    204204        }
     
    208208        // log handling ================
    209209        case ENET_EVENT_TYPE_CONNECT:
     210          printf("====================================================================");
    210211        case ENET_EVENT_TYPE_DISCONNECT:
    211212        case ENET_EVENT_TYPE_RECEIVE:
     
    215216        case ENET_EVENT_TYPE_NONE:
    216217          //receiverThread_->yield();
    217           msleep(1);
     218          msleep(10);
    218219          break;
    219220      }
     
    267268  }
    268269
    269   bool ConnectionManager::processData(ENetEvent *event) {
    270     // just add packet to the buffer
    271     // this can be extended with some preprocessing
    272     return buffer.push(event);
    273   }
    274 
    275 
    276270
    277271  int ConnectionManager::getClientID(ENetPeer* peer) {
  • code/branches/netp3/src/network/ConnectionManager.h

    r2773 r2990  
    5555    const int NETWORK_PORT = 55556;
    5656    const int NETWORK_MAX_CONNECTIONS = 50;
    57     const int NETWORK_WAIT_TIMEOUT = 1;
     57    const int NETWORK_WAIT_TIMEOUT = 10;
    5858    const int NETWORK_DEFAULT_CHANNEL = 0;
    5959
     
    8181    void disconnectClient(ClientInformation *client);
    8282    void syncClassid(unsigned int clientID);
     83    bool checkReceiverThread(){ return !quit_; }
    8384
    8485  private:
    8586    ConnectionManager(const ConnectionManager& copy); // not used
    86     bool processData(ENetEvent *event);
     87    inline bool processData(ENetEvent *event){ return buffer.push(event); }
    8788    void receiverThread();
    8889    void disconnectClients();
     
    9596    ENetAddress *bindAddress;
    9697
    97     bool quit; // quit-variable (communication with threads)
     98    bool quit_; // quit-variable (communication with threads)
    9899
    99100    boost::thread *receiverThread_;
  • code/branches/netp3/src/network/Host.h

    r2171 r2990  
    3535
    3636namespace orxonox {
     37
     38  const int CLIENTID_SERVER = 0;
     39  const unsigned int NETWORK_FREQUENCY = 25;
     40  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
    3741
    3842/**
  • code/branches/netp3/src/network/NetworkPrereqs.h

    r2773 r2990  
    9090  class ClientInformation;
    9191  class ConnectionManager;
     92  class FunctionCallManager;
    9293  class GamestateClient;
    9394  class GamestateManager;
     
    9697  template <class T> class NetworkCallback;
    9798  class NetworkCallbackManager;
     99  class NetworkFunctionBase;
     100  class NetworkFunctionStatic;
     101  class NetworkMemberFunctionBase;
     102  template <class T> class NetworkMemeberFunction;
     103  struct NetworkFunctionPointer;
    98104  class PacketBuffer;
    99105  class Server;
     
    112118  namespace packet
    113119  {
     120    class Acknowledgement;
     121    class Chat;
     122    class ClassID;
     123    class FunctionCalls;
     124    class FunctionIDs;
    114125    class Gamestate;
     126    class NetworkIDs;
    115127    class Packet;
    116     class Acknowledgement;
    117     class ClassID;
    118128    class Welcome;
    119     class Chat;
    120129  }
    121130}
  • code/branches/netp3/src/network/Server.cc

    r2896 r2990  
    6161#include "util/Convert.h"
    6262#include "ChatListener.h"
     63#include "FunctionCallManager.h"
     64#include "packet/FunctionIDs.h"
     65
    6366
    6467namespace orxonox
     
    158161      gamestates_->processGamestates();
    159162      updateGamestate();
     163      FunctionCallManager::sendCalls();
    160164    }
    161165  }
     
    341345      return false;
    342346    }
    343     COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
     347    COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
     348   
     349    // synchronise class ids
    344350    connection->syncClassid(temp->getID());
     351   
     352    // now synchronise functionIDs
     353    packet::FunctionIDs *fIDs = new packet::FunctionIDs();
     354    fIDs->setClientID(clientID);
     355    bool b = fIDs->send();
     356    assert(b);
     357   
    345358    temp->setSynched(true);
    346     COUT(3) << "sending welcome" << std::endl;
     359    COUT(4) << "sending welcome" << std::endl;
    347360    packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
    348361    w->setClientID(temp->getID());
    349     bool b = w->send();
     362    b = w->send();
    350363    assert(b);
    351364    packet::Gamestate *g = new packet::Gamestate();
  • code/branches/netp3/src/network/Server.h

    r2896 r2990  
    5151namespace orxonox
    5252{
    53   const int CLIENTID_SERVER = 0;
    54   const unsigned int NETWORK_FREQUENCY = 25;
    55   const float NETWORK_PERIOD = 1.f/NETWORK_FREQUENCY;
    5653
    5754  /**
  • code/branches/netp3/src/network/TrafficControl.cc

    r2896 r2990  
    9191  void TrafficControl::setConfigValues()
    9292  {
    93     SetConfigValue ( bActive_, true );
    94     SetConfigValue ( targetSize, 5000 );
     93    SetConfigValue ( bActive_, false );
     94    SetConfigValue ( targetSize, 10000 );
    9595  }
    9696
  • code/branches/netp3/src/network/packet/CMakeLists.txt

    r2710 r2990  
    11ADD_SOURCE_FILES(NETWORK_SRC_FILES
    22  Packet.cc
     3  Acknowledgement.cc
    34  Chat.cc
    45  ClassID.cc
    5   Acknowledgement.cc
     6  DeleteObjects.cc
     7  FunctionIDs.cc
     8  FunctionCalls.cc
    69  Gamestate.cc
    710  Welcome.cc
    8   DeleteObjects.cc
    911)
  • code/branches/netp3/src/network/packet/ClassID.cc

    r2773 r2990  
    9393  }
    9494 
    95   COUT(0) << "classid packetSize is " << packetSize << endl;
     95  COUT(5) << "classid packetSize is " << packetSize << endl;
    9696 
    9797}
  • code/branches/netp3/src/network/packet/Gamestate.cc

    r2896 r2990  
    107107  for(it = ObjectList<Synchronisable>::begin(); it; ++it){
    108108   
    109     tempsize=it->getSize(id, mode);
     109//     tempsize=it->getSize(id, mode);
     110
     111    tempsize = it->getData(mem, id, mode);
     112    if ( it->doSync( id, mode ) )
     113      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
     114   
    110115#ifndef NDEBUG
    111116    if(currentsize+tempsize > size){
     
    123128    }// stop allocate additional memory
    124129#endif
    125 
    126     if ( it->doSync( id, mode ) )
    127       dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
    128     if(!it->getData(mem, id, mode))
    129       return false; // mem pointer gets automatically increased because of call by reference
     130//     if(!it->getData(mem, id, mode))
     131//       return false; // mem pointer gets automatically increased because of call by reference
    130132    // increase size counter by size of current synchronisable
    131133    currentsize+=tempsize;
  • code/branches/netp3/src/network/packet/Packet.cc

    r2773 r2990  
    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"
     
    153155    case ENUM::Welcome:
    154156    case ENUM::DeleteObjects:
     157    case ENUM::FunctionIDs:
     158    case ENUM::FunctionCalls:
    155159      break;
    156160    default:
     
    170174  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    171175  Packet *p = 0;
    172   COUT(5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
     176  COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    173177  switch( *(ENUM::Type *)(data + _PACKETID) )
    174178  {
    175179    case ENUM::Acknowledgement:
    176       COUT(4) << "ack" << std::endl;
     180      COUT(5) << "ack" << std::endl;
    177181      p = new Acknowledgement( data, clientID );
    178182      break;
    179183    case ENUM::Chat:
    180       COUT(4) << "chat" << std::endl;
     184      COUT(5) << "chat" << std::endl;
    181185      p = new Chat( data, clientID );
    182186      break;
    183187    case ENUM::ClassID:
    184       COUT(4) << "classid" << std::endl;
     188      COUT(5) << "classid" << std::endl;
    185189      p = new ClassID( data, clientID );
    186190      break;
    187191    case ENUM::Gamestate:
    188       COUT(4) << "gamestate" << std::endl;
     192      COUT(5) << "gamestate" << std::endl;
    189193      // TODO: remove brackets
    190194      p = new Gamestate( data, clientID );
    191195      break;
    192196    case ENUM::Welcome:
    193       COUT(4) << "welcome" << std::endl;
     197      COUT(5) << "welcome" << std::endl;
    194198      p = new Welcome( data, clientID );
    195199      break;
    196200    case ENUM::DeleteObjects:
    197       COUT(4) << "deleteobjects" << std::endl;
     201      COUT(5) << "deleteobjects" << std::endl;
    198202      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 );
    199211      break;
    200212    default:
  • code/branches/netp3/src/network/packet/Packet.h

    r2773 r2990  
    4545  enum Type{
    4646    Acknowledgement,
     47    Chat,
     48    ClassID,
     49    DeleteObjects,
     50    FunctionIDs,
     51    FunctionCalls,
    4752    Gamestate,
    48     ClassID,
    49     Chat,
    50     Welcome,
    51     DeleteObjects
     53    Welcome
    5254  };
    5355}
     
    6668    virtual unsigned int getSize() const =0;
    6769    virtual bool process()=0;
    68     uint32_t getFlags()
     70    inline uint32_t getFlags()
    6971      { return flags_; }
    70     int getClientID()
     72    inline int getClientID()
    7173      { return clientID_; }
    72     void setClientID( int id )
     74    inline void setClientID( int id )
    7375      { clientID_ = id; }
    7476
     
    7880    Packet(uint8_t *data, unsigned int clientID);
    7981//    Packet(ENetPacket *packet, ENetPeer *peer);
     82    inline bool isDataENetAllocated() const
     83      { return bDataENetAllocated_; }
     84
    8085    uint32_t flags_;
    8186    unsigned int clientID_;
  • code/branches/netp3/src/network/synchronisable/NetworkCallback.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/network/synchronisable/NetworkCallbackManager.cc

    r2662 r2990  
    3232
    3333namespace orxonox{
    34 
     34 
    3535  std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
    3636  std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
     
    6060    while( triggeredCallbacks_.empty()==false )
    6161    {
    62       triggeredCallbacks_.front()->call();
     62      //make sure callback hasn't been deleted before
     63      if ( callbackSet_.find(triggeredCallbacks_.front()) != callbackSet_.end() )
     64        triggeredCallbacks_.front()->call();
    6365      triggeredCallbacks_.pop();
    6466    }
  • code/branches/netp3/src/network/synchronisable/Synchronisable.cc

    r2911 r2990  
    6666      objectID=OBJECTID_UNKNOWN;
    6767    classID = static_cast<uint32_t>(-1);
    68 
     68   
     69    // set dataSize to 0
     70    this->dataSize_ = 0;
    6971    // set standard priority
    7072    this->setPriority( priority::normal );
     
    9698    // delete callback function objects
    9799    if(!Identifier::isCreatingHierarchy()){
    98       for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
     100      for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
    99101        delete (*it);
    100102      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
     
    236238   * @return true: if !doSync or if everything was successfully saved
    237239   */
    238   bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
     240  uint32_t Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
    239241    if(mode==0x0)
    240242      mode=state_;
    241243    //if this tick is we dont synchronise, then abort now
    242244    if(!doSync(id, mode))
    243       return true;
     245      return 0;
    244246    uint32_t tempsize = 0;
    245247    if (this->classID==0)
     
    250252
    251253    assert(this->classID==this->getIdentifier()->getNetworkID());
    252     std::list<SynchronisableVariableBase*>::iterator i;
    253     uint32_t size;
    254     size=getSize(id, mode);
     254    std::vector<SynchronisableVariableBase*>::iterator i;
    255255
    256256    // start copy header
    257257    SynchronisableHeader header(mem);
    258     header.setDataSize( size );
     258    mem += SynchronisableHeader::getSize();
     259    // end copy header
     260
     261
     262    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
     263    // copy to location
     264    for(i=syncList.begin(); i!=syncList.end(); ++i){
     265      tempsize += (*i)->getData( mem, mode );
     266      //tempsize += (*i)->getSize( mode );
     267    }
     268   
     269    tempsize += SynchronisableHeader::getSize();
    259270    header.setObjectID( this->objectID );
    260271    header.setCreatorID( this->creatorID );
    261272    header.setClassID( this->classID );
    262273    header.setDataAvailable( true );
    263     tempsize += SynchronisableHeader::getSize();
    264     mem += SynchronisableHeader::getSize();
    265     // end copy header
    266 
    267 
    268     COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
    269     // copy to location
    270     for(i=syncList.begin(); i!=syncList.end(); ++i){
    271       (*i)->getData( mem, mode );
    272       tempsize += (*i)->getSize( mode );
    273     }
     274    header.setDataSize( tempsize );
     275   
     276#ifndef NDEBUG
     277    uint32_t size;
     278    size=getSize(id, mode);
    274279    assert(tempsize==size);
    275     return true;
     280#endif
     281    return tempsize;
    276282  }
    277283
     
    286292    if(mode==0x0)
    287293      mode=state_;
    288     std::list<SynchronisableVariableBase *>::iterator i;
     294    std::vector<SynchronisableVariableBase *>::iterator i;
    289295    if(syncList.empty()){
    290296      assert(0);
     
    325331  uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
    326332    int tsize=SynchronisableHeader::getSize();
    327     if(mode==0x0)
     333    if (mode==0x0)
    328334      mode=state_;
    329     if(!doSync(id, mode))
     335    if (!doSync(id, mode))
    330336      return 0;
    331     std::list<SynchronisableVariableBase*>::iterator i;
    332     for(i=syncList.begin(); i!=syncList.end(); i++){
     337    assert( mode==state_ );
     338    tsize += this->dataSize_;
     339    std::vector<SynchronisableVariableBase*>::iterator i;
     340    for(i=stringList.begin(); i!=stringList.end(); ++i){
    333341      tsize += (*i)->getSize( mode );
    334342    }
  • code/branches/netp3/src/network/synchronisable/Synchronisable.h

    r2911 r2990  
    3333
    3434#include <list>
     35#include <vector>
    3536#include <map>
    3637#include <queue>
    3738#include <cassert>
     39#include <string>
    3840#include "util/Math.h"
    3941#include "util/mbool.h"
     
    120122  public:
    121123    friend class packet::Gamestate;
    122 //     friend class Server;
    123124    virtual ~Synchronisable();
    124125
     
    139140    Synchronisable(BaseObject* creator);
    140141    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    141     template <class T> void unregisterVariable(T& var);
     142    //template <class T> void unregisterVariable(T& var);
    142143    void setObjectMode(uint8_t mode);
    143144    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
     
    145146
    146147  private:
    147     bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
     148    uint32_t getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
    148149    uint32_t getSize(int32_t id, uint8_t mode=0x0);
    149150    bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
     
    155156    uint32_t classID;
    156157
    157     std::list<SynchronisableVariableBase*> syncList;
     158    std::vector<SynchronisableVariableBase*> syncList;
     159    std::vector<SynchronisableVariableBase*> stringList;
     160    uint32_t dataSize_; //size of all variables except strings
    158161    static uint8_t state_; // detemines wheter we are server (default) or client
    159162    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
     
    164167  };
    165168
    166   template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
    167   {
    168     if (bidirectional)
    169       syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
    170     else
    171       syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
    172   }
    173 
    174   template <class T> void Synchronisable::unregisterVariable(T& var){
    175     std::list<SynchronisableVariableBase*>::iterator it = syncList.begin();
    176     while(it!=syncList.end()){
    177       if( ((*it)->getReference()) == &var ){
    178         delete (*it);
    179         syncList.erase(it);
    180         return;
    181       }
    182       else
    183         it++;
    184     }
    185     bool unregistered_nonexistent_variable = false;
    186     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
    187     // the variable has not been registered before
    188   }
    189 
    190169  // ================= Specialisation declarations
     170 
     171//   template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
     172  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    191173  template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    192174  template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     
    200182  template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
    201183  template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
     184 
     185  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
     186  {
     187    if (bidirectional)
     188    {
     189      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
     190      this->dataSize_ += syncList.back()->getSize(state_);
     191    }
     192    else
     193    {
     194      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
     195      if ( this->state_ == mode )
     196        this->dataSize_ += syncList.back()->getSize(state_);
     197    }
     198  }
     199 
     200
     201
     202//   template <class T> void Synchronisable::unregisterVariable(T& var){
     203//     std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
     204//     while(it!=syncList.end()){
     205//       if( ((*it)->getReference()) == &var ){
     206//         delete (*it);
     207//         syncList.erase(it);
     208//         return;
     209//       }
     210//       else
     211//         it++;
     212//     }
     213//     bool unregistered_nonexistent_variable = false;
     214//     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
     215//     // the variable has not been registered before
     216//   }
     217
     218 
    202219}
    203220
  • code/branches/netp3/src/network/synchronisable/SynchronisableSpecialisations.cc

    r2662 r2990  
    2929
    3030#include "network/synchronisable/Synchronisable.h"
     31#include <string>
    3132
    3233// ================ template spezialisation
     
    3435 
    3536namespace orxonox{
     37 
     38//   template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
     39//   {
     40//     if (bidirectional)
     41//       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
     42//     else
     43//       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
     44//     stringList.push_back(syncList.back());
     45//   }
     46 
     47  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
     48  {
     49    if (bidirectional)
     50      syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
     51    else
     52      syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
     53    stringList.push_back(syncList.back());
     54  }
    3655 
    3756  template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
     
    5271    registerVariable(variable.y, mode, cb, bidirectional);
    5372  }
    54   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    55   {
    56     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
    57   }
     73//   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
     74//   {
     75//     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
     76//   }
    5877 
    5978  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
  • code/branches/netp3/src/network/synchronisable/SynchronisableVariable.h

    r2896 r2990  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2008
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    3535#include <string>
    3636#include <cassert>
    37 #include "util/Math.h"
     37#include "util/Serialise.h"
     38#include "core/Core.h"
     39#include "core/CoreIncludes.h"
    3840#include "network/synchronisable/NetworkCallback.h"
    3941#include "network/synchronisable/NetworkCallbackManager.h"
     
    5557  {
    5658    public:
    57       virtual void getData(uint8_t*& mem, uint8_t mode)=0;
     59      virtual uint32_t getData(uint8_t*& mem, uint8_t mode)=0;
    5860      virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false)=0;
    5961      virtual uint32_t getSize(uint8_t mode)=0;
     
    7476
    7577      virtual inline uint8_t getMode(){ return mode_; }
    76       virtual inline void getData(uint8_t*& mem, uint8_t mode);
     78      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
    7779      virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
    7880      virtual inline uint32_t getSize(uint8_t mode);
    7981      virtual inline void* getReference(){ return (void *)&this->variable_; }
    8082    protected:
    81       bool checkEquality(uint8_t* mem);
    82       void setAndIncrease(uint8_t*& mem);
    83       void getAndIncrease(uint8_t*& mem);
    84       uint32_t returnSize();
     83//       inline bool checkEquality(uint8_t* mem);
     84//       inline void loadAndIncrease(uint8_t*& mem);
     85//       inline void saveAndIncrease(uint8_t*& mem);
     86//       inline uint32_t returnSize();
    8587     
    8688      T& variable_;
     
    9799     
    98100      virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
    99       virtual void getData(uint8_t*& mem, uint8_t mode);
     101      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
    100102      virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
    101       virtual uint32_t getSize(uint8_t mode);
     103      virtual inline uint32_t getSize(uint8_t mode);
    102104    private:
    103105      T varBuffer_;
     
    119121  }
    120122
    121   template <class T> void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
     123  template <class T> inline uint32_t SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
    122124  {
    123125    if ( state_ == this->mode_ )
    124       getAndIncrease( mem );
     126    {
     127      saveAndIncrease( this->variable_, mem );
     128      return returnSize( this->variable_ );
     129    }
     130    else
     131      return 0;
    125132//   mem += SynchronisableVariable<T>::getSize();
    126133  }
     
    135142    if ( this->callback_ != 0 )
    136143    {
    137       if( forceCallback || !checkEquality( mem ) )
     144      if( forceCallback || !checkEquality( this->variable_, mem ) )
    138145        callback = true;
    139146    }
    140147  // write the data
    141     setAndIncrease( mem );
    142 //   mem += SynchronisableVariable<T>::getSize();
     148    loadAndIncrease( this->variable_, mem );
    143149  // now do a callback if neccessary
    144150    if ( callback )
    145151      NetworkCallbackManager::triggerCallback( this->callback_ );
    146       //this->callback_->call();
    147   }
    148 
    149   template <class T> uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
     152  }
     153
     154  template <class T> inline uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
    150155  {
    151156    if ( mode == this->mode_ )
    152       return returnSize();
     157      return returnSize( this->variable_ );
    153158    else
    154159      return 0;
    155160  }
    156161
    157   template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
    158   template <> _NetworkExport void     SynchronisableVariable<const bool>::setAndIncrease(uint8_t*& mem);
    159   template <> _NetworkExport void     SynchronisableVariable<const bool>::getAndIncrease(uint8_t*& mem);
     162  /*template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
     163  template <> _NetworkExport void     SynchronisableVariable<const bool>::loadAndIncrease(uint8_t*& mem);
     164  template <> _NetworkExport void     SynchronisableVariable<const bool>::saveAndIncrease(uint8_t*& mem);
    160165  template <> _NetworkExport bool     SynchronisableVariable<const bool>::checkEquality(uint8_t* mem);
    161166  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned char>::returnSize();
    162   template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::setAndIncrease(uint8_t*& mem);
    163   template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::getAndIncrease(uint8_t*& mem);
     167  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::loadAndIncrease(uint8_t*& mem);
     168  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::saveAndIncrease(uint8_t*& mem);
    164169  template <> _NetworkExport bool     SynchronisableVariable<const unsigned char>::checkEquality(uint8_t* mem);
    165170  template <> _NetworkExport uint32_t SynchronisableVariable<const short>::returnSize();
    166   template <> _NetworkExport void     SynchronisableVariable<const short>::setAndIncrease(uint8_t*& mem);
    167   template <> _NetworkExport void     SynchronisableVariable<const short>::getAndIncrease(uint8_t*& mem);
     171  template <> _NetworkExport void     SynchronisableVariable<const short>::loadAndIncrease(uint8_t*& mem);
     172  template <> _NetworkExport void     SynchronisableVariable<const short>::saveAndIncrease(uint8_t*& mem);
    168173  template <> _NetworkExport bool     SynchronisableVariable<const short>::checkEquality(uint8_t* mem);
    169174  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned short>::returnSize();
    170   template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::setAndIncrease(uint8_t*& mem);
    171   template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::getAndIncrease(uint8_t*& mem);
     175  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::loadAndIncrease(uint8_t*& mem);
     176  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::saveAndIncrease(uint8_t*& mem);
    172177  template <> _NetworkExport bool     SynchronisableVariable<const unsigned short>::checkEquality(uint8_t* mem);
    173178  template <> _NetworkExport uint32_t SynchronisableVariable<const int>::returnSize();
    174   template <> _NetworkExport void     SynchronisableVariable<const int>::setAndIncrease(uint8_t*& mem);
    175   template <> _NetworkExport void     SynchronisableVariable<const int>::getAndIncrease(uint8_t*& mem);
     179  template <> _NetworkExport void     SynchronisableVariable<const int>::loadAndIncrease(uint8_t*& mem);
     180  template <> _NetworkExport void     SynchronisableVariable<const int>::saveAndIncrease(uint8_t*& mem);
    176181  template <> _NetworkExport bool     SynchronisableVariable<const int>::checkEquality(uint8_t* mem);
    177182  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned int>::returnSize();
    178   template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::setAndIncrease(uint8_t*& mem);
    179   template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::getAndIncrease(uint8_t*& mem);
     183  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::loadAndIncrease(uint8_t*& mem);
     184  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::saveAndIncrease(uint8_t*& mem);
    180185  template <> _NetworkExport bool     SynchronisableVariable<const unsigned int>::checkEquality(uint8_t* mem);
    181186  template <> _NetworkExport uint32_t SynchronisableVariable<const long>::returnSize();
    182   template <> _NetworkExport void     SynchronisableVariable<const long>::setAndIncrease(uint8_t*& mem);
    183   template <> _NetworkExport void     SynchronisableVariable<const long>::getAndIncrease(uint8_t*& mem);
     187  template <> _NetworkExport void     SynchronisableVariable<const long>::loadAndIncrease(uint8_t*& mem);
     188  template <> _NetworkExport void     SynchronisableVariable<const long>::saveAndIncrease(uint8_t*& mem);
    184189  template <> _NetworkExport bool     SynchronisableVariable<const long>::checkEquality(uint8_t* mem);
    185190  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long>::returnSize();
    186   template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::setAndIncrease(uint8_t*& mem);
    187   template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::getAndIncrease(uint8_t*& mem);
     191  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::loadAndIncrease(uint8_t*& mem);
     192  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::saveAndIncrease(uint8_t*& mem);
    188193  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long>::checkEquality(uint8_t* mem);
    189194  template <> _NetworkExport uint32_t SynchronisableVariable<const long long>::returnSize();
    190   template <> _NetworkExport void     SynchronisableVariable<const long long>::setAndIncrease(uint8_t*& mem);
    191   template <> _NetworkExport void     SynchronisableVariable<const long long>::getAndIncrease(uint8_t*& mem);
     195  template <> _NetworkExport void     SynchronisableVariable<const long long>::loadAndIncrease(uint8_t*& mem);
     196  template <> _NetworkExport void     SynchronisableVariable<const long long>::saveAndIncrease(uint8_t*& mem);
    192197  template <> _NetworkExport bool     SynchronisableVariable<const long long>::checkEquality(uint8_t* mem);
    193198  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long long>::returnSize();
    194   template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::setAndIncrease(uint8_t*& mem);
    195   template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::getAndIncrease(uint8_t*& mem);
     199  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::loadAndIncrease(uint8_t*& mem);
     200  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::saveAndIncrease(uint8_t*& mem);
    196201  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long long>::checkEquality(uint8_t* mem);
    197202  template <> _NetworkExport uint32_t SynchronisableVariable<const float>::returnSize();
    198   template <> _NetworkExport void     SynchronisableVariable<const float>::setAndIncrease(uint8_t*& mem);
    199   template <> _NetworkExport void     SynchronisableVariable<const float>::getAndIncrease(uint8_t*& mem);
     203  template <> _NetworkExport void     SynchronisableVariable<const float>::loadAndIncrease(uint8_t*& mem);
     204  template <> _NetworkExport void     SynchronisableVariable<const float>::saveAndIncrease(uint8_t*& mem);
    200205  template <> _NetworkExport bool     SynchronisableVariable<const float>::checkEquality(uint8_t* mem);
    201206  template <> _NetworkExport uint32_t SynchronisableVariable<const double>::returnSize();
    202   template <> _NetworkExport void     SynchronisableVariable<const double>::setAndIncrease(uint8_t*& mem);
    203   template <> _NetworkExport void     SynchronisableVariable<const double>::getAndIncrease(uint8_t*& mem);
     207  template <> _NetworkExport void     SynchronisableVariable<const double>::loadAndIncrease(uint8_t*& mem);
     208  template <> _NetworkExport void     SynchronisableVariable<const double>::saveAndIncrease(uint8_t*& mem);
    204209  template <> _NetworkExport bool     SynchronisableVariable<const double>::checkEquality(uint8_t* mem);
    205210  template <> _NetworkExport uint32_t SynchronisableVariable<const long double>::returnSize();
    206   template <> _NetworkExport void     SynchronisableVariable<const long double>::setAndIncrease(uint8_t*& mem);
    207   template <> _NetworkExport void     SynchronisableVariable<const long double>::getAndIncrease(uint8_t*& mem);
     211  template <> _NetworkExport void     SynchronisableVariable<const long double>::loadAndIncrease(uint8_t*& mem);
     212  template <> _NetworkExport void     SynchronisableVariable<const long double>::saveAndIncrease(uint8_t*& mem);
    208213  template <> _NetworkExport bool     SynchronisableVariable<const long double>::checkEquality(uint8_t* mem);
    209214  template <> _NetworkExport uint32_t SynchronisableVariable<const std::string>::returnSize();
    210   template <> _NetworkExport void     SynchronisableVariable<const std::string>::setAndIncrease(uint8_t*& mem);
    211   template <> _NetworkExport void     SynchronisableVariable<const std::string>::getAndIncrease(uint8_t*& mem);
     215  template <> _NetworkExport void     SynchronisableVariable<const std::string>::loadAndIncrease(uint8_t*& mem);
     216  template <> _NetworkExport void     SynchronisableVariable<const std::string>::saveAndIncrease(uint8_t*& mem);
    212217  template <> _NetworkExport bool     SynchronisableVariable<const std::string>::checkEquality(uint8_t* mem);
    213218  template <> _NetworkExport uint32_t SynchronisableVariable<const Degree>::returnSize();
    214   template <> _NetworkExport void     SynchronisableVariable<const Degree>::setAndIncrease(uint8_t*& mem);
    215   template <> _NetworkExport void     SynchronisableVariable<const Degree>::getAndIncrease(uint8_t*& mem);
    216   template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);
     219  template <> _NetworkExport void     SynchronisableVariable<const Degree>::loadAndIncrease(uint8_t*& mem);
     220  template <> _NetworkExport void     SynchronisableVariable<const Degree>::saveAndIncrease(uint8_t*& mem);
     221  template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);*/
    217222
    218223
     
    229234    }
    230235
    231     template <class T> void SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
     236    template <class T> uint32_t SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
    232237    {
    233238      if ( this->mode_ == mode )
     
    243248      mem += sizeof(this->varReference_);
    244249  // now write the content
    245       SynchronisableVariable<T>::getAndIncrease( mem );
     250      saveAndIncrease( this->variable_, mem );
    246251//   mem += SynchronisableVariable<T>::getSize();
     252      return SynchronisableVariableBidirectional::getSize(mode);
    247253    }
    248254
     
    260266        else{
    261267          // apply data
    262           mem += sizeof(varReference_);
    263           if ( SynchronisableVariableBidirectional<T>::checkEquality( mem )==true )
     268          if ( checkEquality( this->variable_, mem+sizeof(varReference_) )==true )
    264269          {
    265             mem += SynchronisableVariable<T>::getSize( mode );
     270            mem += getSize( mode );
    266271            return;
    267272          }
    268273          else
    269274          {
     275            mem += sizeof(varReference_);
    270276            memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
    271277            if ( this->callback_ != 0 )
     
    285291          this->varReference_ = *static_cast<uint8_t*>(mem);
    286292          mem += sizeof(varReference_);
    287           if ( SynchronisableVariable<T>::checkEquality( mem ) == false )
     293          if ( checkEquality( this->variable_, mem ) == false )
    288294          {
    289295            // value changed so remark for callback
     
    294300      }
    295301  // now write the data
    296       SynchronisableVariable<T>::setAndIncrease(mem);
     302      loadAndIncrease(this->variable_, mem);
    297303  // now do a callback if neccessary
    298304      if ( callback )
     
    301307    }
    302308
    303     template <class T> uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
    304     {
    305       return SynchronisableVariable<T>::returnSize() + sizeof(varReference_);
     309    template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
     310    {
     311      return returnSize( this->variable_ ) + sizeof(varReference_);
    306312    }
    307313 
     
    309315}
    310316
     317//#include "network/synchronisable/SynchronisableVariableSpecialisations.h"
    311318
    312319#endif
  • code/branches/netp3/src/orxonox/CameraManager.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/CameraManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/OrxonoxPrereqs.h

    r2911 r2990  
    158158    class SpawnPoint;
    159159    class TeamSpawnPoint;
     160    class Test;
    160161
    161162    class Spectator;
  • code/branches/netp3/src/orxonox/objects/Level.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/Level.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/Test.cc

    r2662 r2990  
    3131#include "core/ConfigValueIncludes.h"
    3232#include "core/ConsoleCommand.h"
     33#include "network/NetworkFunction.h"
    3334#include "Test.h"
     35#include "util/MultiType.h"
    3436
    3537namespace orxonox
     
    4143  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
    4244  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
     45  SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
     46  SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
     47 
     48 
     49  //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
     50  //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
     51//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
     52 
     53  registerStaticNetworkFunction( &Test::printV1 );
     54  registerMemberNetworkFunction( Test, checkU1 );
     55  registerMemberNetworkFunction( Test, printBlaBla );
    4356 
    4457  Test* Test::instance_ = 0;
     
    7386
    7487
    75         void Test::registerVariables()
    76         {
    77                 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     88  void Test::registerVariables()
     89  {
     90    registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
    7891    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
    79                 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     92    registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
    8093    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
    8194   
     
    8497    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
    8598    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    86         }
    87 
     99  }
     100 
     101  void Test::call(unsigned int clientID)
     102  {
     103    callStaticNetworkFunction( &Test::printV1, clientID );
     104    callStaticNetworkFunction( &Test::printV1, clientID );
     105  }
     106 
     107  void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     108  {
     109    callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     110  }
     111 
     112  void Test::tick(float dt)
     113  {
     114//     std::string str1 = "blub";
     115//     //MultiType mt1(std::string("blub"));
     116//     MultiType mt1(str1);
     117//     uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
     118//     uint8_t* temp = mem;
     119//     mt1.exportData( temp );
     120//     assert( temp-mem == mt1.getNetworkSize() );
     121//     MultiType mt2;
     122//     temp = mem;
     123//     mt2.importData( temp );
     124//     assert( temp-mem == mt1.getNetworkSize() );
     125//     COUT(0) << mt2 << endl;
     126    if(!Core::isMaster())
     127      call2(0, "bal", "a", "n", "ce");
     128//       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
     129  }
     130 
     131  void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
     132  {
     133    COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
     134  }
     135 
    88136  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
    89137  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
  • code/branches/netp3/src/orxonox/objects/Test.h

    r2662 r2990  
    3333#include "core/BaseObject.h"
    3434#include "network/synchronisable/Synchronisable.h"
     35#include "Tickable.h"
    3536
    3637
     
    4142namespace orxonox
    4243{
    43   class _OrxonoxExport Test: public BaseObject, public Synchronisable
     44  class _OrxonoxExport Test: public BaseObject, public Synchronisable, public Tickable
    4445  {
    4546    public:
     
    4950      void setConfigValues();
    5051      void registerVariables();
     52     
     53      static void call(unsigned int clientID);
     54      void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
     55      virtual void tick(float dt);
    5156
    5257
     
    7580      static void printV3(){ instance_->checkU3(); }
    7681      static void printV4(){ instance_->checkU4(); }
     82     
     83      void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
    7784
    7885    private:
  • code/branches/netp3/src/orxonox/objects/collisionshapes

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/controllers/AIController.cc

    r2896 r2990  
    101101    void AIController::tick(float dt)
    102102    {
    103         if (!this->isActive())
    104             return;
    105 
    106         if (this->target_)
    107             this->aimAtTarget();
    108 
    109         if (this->bHasTargetPosition_)
    110             this->moveToTargetPosition(dt);
    111 
    112         if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0))
    113             this->getControllableEntity()->fire(WeaponMode::fire);
     103        if(Core::isMaster())
     104        {
     105            if (!this->isActive())
     106                return;
     107   
     108            if (this->target_)
     109                this->aimAtTarget();
     110   
     111            if (this->bHasTargetPosition_)
     112                this->moveToTargetPosition(dt);
     113   
     114            if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0))
     115                this->getControllableEntity()->fire(WeaponMode::fire);
     116        }
    114117
    115118        SUPER(AIController, tick, dt);
  • code/branches/netp3/src/orxonox/objects/gametypes/TeamDeathmatch.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/gametypes/TeamDeathmatch.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/pickup/Usable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddQuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddQuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddReward.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/AddReward.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/ChangeQuestStatus.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/ChangeQuestStatus.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/CompleteQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/CompleteQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/FailQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/FailQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/GlobalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/GlobalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/LocalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/LocalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/Quest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/Quest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestDescription.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestDescription.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestEffect.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestEffect.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestItem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestItem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestManager.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/QuestManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/Rewardable.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/quest/Rewardable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/weaponSystem/WeaponSystem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/Backlight.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/Backlight.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/Camera.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/Camera.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2973 r2990  
    6666        this->mouseLookSpeed_ = 200;
    6767
    68         this->server_position_         = Vector3::ZERO;
    69         this->client_position_         = Vector3::ZERO;
    70         this->server_linear_velocity_  = Vector3::ZERO;
    71         this->client_linear_velocity_  = Vector3::ZERO;
    72         this->server_orientation_      = Quaternion::IDENTITY;
    73         this->client_orientation_      = Quaternion::IDENTITY;
    74         this->server_angular_velocity_ = Vector3::ZERO;
    75         this->client_angular_velocity_ = Vector3::ZERO;
     68        this->common_position_         = Vector3::ZERO;
     69//         this->client_position_         = Vector3::ZERO;
     70        this->common_linear_velocity_  = Vector3::ZERO;
     71//         this->client_linear_velocity_  = Vector3::ZERO;
     72        this->common_orientation_      = Quaternion::IDENTITY;
     73//         this->client_orientation_      = Quaternion::IDENTITY;
     74        this->common_angular_velocity_ = Vector3::ZERO;
     75//         this->client_angular_velocity_ = Vector3::ZERO;
    7676
    7777
     
    326326            if (!this->isDynamic())
    327327            {
    328                 if (GameMode::isMaster())
    329                 {
    330                     this->server_position_ = this->getPosition();
    331                     this->server_orientation_ = this->getOrientation();
    332                     this->server_linear_velocity_ = this->getVelocity();
    333                     this->server_angular_velocity_ = this->getAngularVelocity();
    334                 }
    335                 else if (this->bHasLocalController_)
    336                 {
    337                     this->client_position_ = this->getPosition();
    338                     this->client_orientation_ = this->getOrientation();
    339                     this->client_linear_velocity_ = this->getVelocity();
    340                     this->client_angular_velocity_ = this->getAngularVelocity();
    341                 }
     328//                 if (GameMode::isMaster())
     329//                 {
     330                    this->common_position_ = this->getPosition();
     331                    this->common_orientation_ = this->getOrientation();
     332                    this->common_linear_velocity_ = this->getVelocity();
     333                    this->common_angular_velocity_ = this->getAngularVelocity();
     334//                 }
     335//                 else if (this->bHasLocalController_)
     336//                 {
     337//                     this->client_position_ = this->getPosition();
     338//                     this->client_orientation_ = this->getOrientation();
     339//                     this->client_linear_velocity_ = this->getVelocity();
     340//                     this->client_angular_velocity_ = this->getAngularVelocity();
     341//                 }
    342342            }
    343343        }
     
    349349        registerVariable(this->hudtemplate_,             variableDirection::toclient);
    350350
    351         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    352         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
    353         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    354         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
    355 
    356         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    357         registerVariable(this->client_overwrite_,        variableDirection::toserver);
    358 
    359         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    360         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
    361         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    362         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     351//         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     352//         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     353//         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     354//         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     355//
     356//         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     357//         registerVariable(this->client_overwrite_,        variableDirection::toserver);
     358//
     359//         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     360//         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     361//         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     362//         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     363       
     364        registerVariable(this->common_position_,         variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true);
     365        registerVariable(this->common_linear_velocity_,  variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true);
     366        registerVariable(this->common_orientation_,      variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true);
     367        registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true);
    363368
    364369        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     
    368373    {
    369374        if (!this->bHasLocalController_)
    370             MobileEntity::setPosition(this->server_position_);
     375            MobileEntity::setPosition(this->common_position_);
    371376    }
    372377
     
    374379    {
    375380        if (!this->bHasLocalController_)
    376             MobileEntity::setVelocity(this->server_linear_velocity_);
     381            MobileEntity::setVelocity(this->common_linear_velocity_);
    377382    }
    378383
     
    380385    {
    381386        if (!this->bHasLocalController_)
    382             MobileEntity::setOrientation(this->server_orientation_);
     387            MobileEntity::setOrientation(this->common_orientation_);
    383388    }
    384389
     
    386391    {
    387392        if (!this->bHasLocalController_)
    388             MobileEntity::setAngularVelocity(this->server_angular_velocity_);
     393            MobileEntity::setAngularVelocity(this->common_angular_velocity_);
    389394    }
    390395
     
    393398        if (this->bHasLocalController_)
    394399        {
    395             this->setPosition(this->server_position_);
    396             this->setOrientation(this->server_orientation_);
    397             this->setVelocity(this->server_linear_velocity_);
    398             this->setAngularVelocity(this->server_angular_velocity_);
    399 
    400             this->client_overwrite_ = this->server_overwrite_;
     400//             this->setPosition(this->server_position_);
     401//             this->setOrientation(this->server_orientation_);
     402//             this->setVelocity(this->server_linear_velocity_);
     403//             this->setAngularVelocity(this->server_angular_velocity_);
     404
     405//             this->client_overwrite_ = this->server_overwrite_;
    401406        }
    402407    }
     
    406411        if (this->server_overwrite_ == this->client_overwrite_)
    407412        {
    408             MobileEntity::setPosition(this->client_position_);
    409             this->server_position_ = this->getPosition();
     413//             MobileEntity::setPosition(this->client_position_);
     414//             this->server_position_ = this->getPosition();
    410415        }
    411416    }
     
    415420        if (this->server_overwrite_ == this->client_overwrite_)
    416421        {
    417             MobileEntity::setVelocity(this->client_linear_velocity_);
    418             this->server_linear_velocity_ = this->getVelocity();
     422//             MobileEntity::setVelocity(this->client_linear_velocity_);
     423//             this->server_linear_velocity_ = this->getVelocity();
    419424        }
    420425    }
     
    424429        if (this->server_overwrite_ == this->client_overwrite_)
    425430        {
    426             MobileEntity::setOrientation(this->client_orientation_);
    427             this->server_orientation_ = this->getOrientation();
     431//             MobileEntity::setOrientation(this->client_orientation_);
     432//             this->server_orientation_ = this->getOrientation();
    428433        }
    429434    }
     
    433438        if (this->server_overwrite_ == this->client_overwrite_)
    434439        {
    435             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
    436             this->server_angular_velocity_ = this->getAngularVelocity();
     440//             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
     441//             this->server_angular_velocity_ = this->getAngularVelocity();
    437442        }
    438443    }
     
    440445    void ControllableEntity::setPosition(const Vector3& position)
    441446    {
    442         if (GameMode::isMaster())
    443         {
     447//         if (GameMode::isMaster())
     448//         {
    444449            MobileEntity::setPosition(position);
    445             this->server_position_ = this->getPosition();
    446             ++this->server_overwrite_;
    447         }
    448         else if (this->bHasLocalController_)
    449         {
    450             MobileEntity::setPosition(position);
    451             this->client_position_ = this->getPosition();
    452         }
     450            this->common_position_ = this->getPosition();
     451//             ++this->server_overwrite_;
     452//         }
     453//         else if (this->bHasLocalController_)
     454//         {
     455//             MobileEntity::setPosition(position);
     456//             this->client_position_ = this->getPosition();
     457//         }
    453458    }
    454459
    455460    void ControllableEntity::setOrientation(const Quaternion& orientation)
    456461    {
    457         if (GameMode::isMaster())
    458         {
     462//         if (GameMode::isMaster())
     463//         {
    459464            MobileEntity::setOrientation(orientation);
    460             this->server_orientation_ = this->getOrientation();
    461             ++this->server_overwrite_;
    462         }
    463         else if (this->bHasLocalController_)
    464         {
    465             MobileEntity::setOrientation(orientation);
    466             this->client_orientation_ = this->getOrientation();
    467         }
     465            this->common_orientation_ = this->getOrientation();
     466//             ++this->server_overwrite_;
     467//         }
     468//         else if (this->bHasLocalController_)
     469//         {
     470//             MobileEntity::setOrientation(orientation);
     471//             this->client_orientation_ = this->getOrientation();
     472//         }
    468473    }
    469474
    470475    void ControllableEntity::setVelocity(const Vector3& velocity)
    471476    {
    472         if (GameMode::isMaster())
    473         {
     477//         if (GameMode::isMaster())
     478//         {
    474479            MobileEntity::setVelocity(velocity);
    475             this->server_linear_velocity_ = this->getVelocity();
    476             ++this->server_overwrite_;
    477         }
    478         else if (this->bHasLocalController_)
    479         {
    480             MobileEntity::setVelocity(velocity);
    481             this->client_linear_velocity_ = this->getVelocity();
    482         }
     480            this->common_linear_velocity_ = this->getVelocity();
     481//             ++this->server_overwrite_;
     482//         }
     483//         else if (this->bHasLocalController_)
     484//         {
     485//             MobileEntity::setVelocity(velocity);
     486//             this->client_linear_velocity_ = this->getVelocity();
     487//         }
    483488    }
    484489
    485490    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    486491    {
    487         if (GameMode::isMaster())
    488         {
     492//         if (GameMode::isMaster())
     493//         {
    489494            MobileEntity::setAngularVelocity(velocity);
    490             this->server_angular_velocity_ = this->getAngularVelocity();
    491             ++this->server_overwrite_;
    492         }
    493         else if (this->bHasLocalController_)
    494         {
    495             MobileEntity::setAngularVelocity(velocity);
    496             this->client_angular_velocity_ = this->getAngularVelocity();
    497         }
     495            this->common_angular_velocity_ = this->getAngularVelocity();
     496//             ++this->server_overwrite_;
     497//         }
     498//         else if (this->bHasLocalController_)
     499//         {
     500//             MobileEntity::setAngularVelocity(velocity);
     501//             this->client_angular_velocity_ = this->getAngularVelocity();
     502//         }
    498503    }
    499504
     
    501506    {
    502507        MobileEntity::setWorldTransform(worldTrans);
    503         if (GameMode::isMaster())
    504         {
    505             this->server_position_ = this->getPosition();
    506             this->server_orientation_ = this->getOrientation();
    507             this->server_linear_velocity_ = this->getVelocity();
    508             this->server_angular_velocity_ = this->getAngularVelocity();
    509         }
    510         else if (this->bHasLocalController_)
    511         {
    512             this->client_position_ = this->getPosition();
    513             this->client_orientation_ = this->getOrientation();
    514             this->client_linear_velocity_ = this->getVelocity();
    515             this->client_angular_velocity_ = this->getAngularVelocity();
    516         }
     508//         if (GameMode::isMaster())
     509//         {
     510            this->common_position_ = this->getPosition();
     511            this->common_orientation_ = this->getOrientation();
     512            this->common_linear_velocity_ = this->getVelocity();
     513            this->common_angular_velocity_ = this->getAngularVelocity();
     514//         }
     515//         else if (this->bHasLocalController_)
     516//         {
     517//             this->client_position_ = this->getPosition();
     518//             this->client_orientation_ = this->getOrientation();
     519//             this->client_linear_velocity_ = this->getVelocity();
     520//             this->client_angular_velocity_ = this->getAngularVelocity();
     521//         }
    517522    }
    518523}
  • code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h

    r2973 r2990  
    164164            bool bDestroyWhenPlayerLeft_;
    165165
    166             Vector3 server_position_;
    167             Vector3 client_position_;
    168             Vector3 server_linear_velocity_;
    169             Vector3 client_linear_velocity_;
    170             Quaternion server_orientation_;
    171             Quaternion client_orientation_;
    172             Vector3 server_angular_velocity_;
    173             Vector3 client_angular_velocity_;
     166//             Vector3 server_position_;
     167            Vector3 common_position_;
     168//             Vector3 client_position_;
     169//             Vector3 server_linear_velocity_;
     170//             Vector3 client_linear_velocity_;
     171            Vector3 common_linear_velocity_;
     172//             Quaternion server_orientation_;
     173//             Quaternion client_orientation_;
     174            Quaternion common_orientation_;
     175//             Vector3 server_angular_velocity_;
     176//             Vector3 client_angular_velocity_;
     177            Vector3 common_angular_velocity_;
    174178
    175179            PlayerInfo* player_;
  • code/branches/netp3/src/orxonox/objects/worldentities/MobileEntity.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/MobileEntity.h

    r2911 r2990  
    6161                { this->setAngularVelocity(Vector3(x, y, z)); }
    6262            inline const Vector3& getAngularVelocity() const
    63                 { return this->linearAcceleration_; }
     63                { return this->angularVelocity_; }
    6464
    6565            void setAcceleration(const Vector3& acceleration);
  • code/branches/netp3/src/orxonox/objects/worldentities/ParticleSpawner.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/ParticleSpawner.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/StaticEntity.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/StaticEntity.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2904 r2990  
    3939#include "objects/worldentities/ParticleSpawner.h"
    4040#include "objects/worldentities/ExplosionChunk.h"
     41#include "network/NetworkFunction.h"
    4142
    4243namespace orxonox
    4344{
    4445    CreateFactory(Pawn);
     46   
     47    registerMemberNetworkFunction( Pawn, doFire );
    4548
    4649    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
     
    117120        SUPER(Pawn, tick, dt);
    118121
    119         if (this->weaponSystem_)
    120         {
    121             if (this->fire_ & WeaponMode::fire)
    122                 this->weaponSystem_->fire(WeaponMode::fire);
    123             if (this->fire_ & WeaponMode::altFire)
    124                 this->weaponSystem_->fire(WeaponMode::altFire);
    125             if (this->fire_ & WeaponMode::altFire2)
    126                 this->weaponSystem_->fire(WeaponMode::altFire2);
    127         }
    128         this->fire_ = this->firehack_;
    129         this->firehack_ = 0x0;
    130 
    131         if (this->health_ <= 0)
     122//         if (this->weaponSystem_)
     123//         {
     124//             if (this->fire_ & WeaponMode::fire)
     125//                 this->weaponSystem_->fire(WeaponMode::fire);
     126//             if (this->fire_ & WeaponMode::altFire)
     127//                 this->weaponSystem_->fire(WeaponMode::altFire);
     128//             if (this->fire_ & WeaponMode::altFire2)
     129//                 this->weaponSystem_->fire(WeaponMode::altFire2);
     130//         }
     131//         this->fire_ = this->firehack_;
     132//         this->firehack_ = 0x0;
     133
     134        if (Core::isMaster())
     135          if (this->health_ <= 0)
    132136            this->death();
    133137    }
     
    254258    void Pawn::fire(WeaponMode::Enum fireMode)
    255259    {
    256         this->firehack_ |= fireMode;
     260        doFire(fireMode);
     261    }
     262   
     263    void Pawn::doFire(uint8_t fireMode)
     264    {
     265        if(Core::isMaster())
     266        {
     267            if (this->weaponSystem_)
     268                this->weaponSystem_->fire((WeaponMode::Enum)fireMode);
     269        }
     270        else
     271        {
     272            callMemberNetworkFunction( Pawn, doFire, this->getObjectID(), 0, ((uint8_t)fireMode));
     273            if (this->weaponSystem_)
     274                this->weaponSystem_->fire((WeaponMode::Enum)fireMode);
     275        }
    257276    }
    258277
  • code/branches/netp3/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2826 r2990  
    8080
    8181            virtual void fire(WeaponMode::Enum fireMode);
     82            virtual void doFire(uint8_t fireMode);
    8283            virtual void postSpawn();
    8384
  • code/branches/netp3/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/triggers/Trigger.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/orxonox/objects/worldentities/triggers/Trigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/tolua/all-5.0.lua

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/tolua/all-5.1.lua

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/util

  • code/branches/netp3/src/util/Exception.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/util/Exception.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/util/MultiType.h

    r2662 r2990  
    8080    enum MT_Type
    8181    {
    82         MT_null,
    83         MT_char,
    84         MT_uchar,
    85         MT_short,
    86         MT_ushort,
    87         MT_int,
    88         MT_uint,
    89         MT_long,
    90         MT_ulong,
    91         MT_longlong,
    92         MT_ulonglong,
    93         MT_float,
    94         MT_double,
    95         MT_longdouble,
    96         MT_bool,
    97         MT_void,
    98         MT_string,
    99         MT_vector2,
    100         MT_vector3,
    101         MT_vector4,
    102         MT_colourvalue,
    103         MT_quaternion,
    104         MT_radian,
    105         MT_degree
     82        MT_null=0,
     83        MT_char=1,
     84        MT_uchar=2,
     85        MT_short=3,
     86        MT_ushort=4,
     87        MT_int=5,
     88        MT_uint=6,
     89        MT_long=7,
     90        MT_ulong=8,
     91        MT_longlong=9,
     92        MT_ulonglong=10,
     93        MT_float=11,
     94        MT_double=12,
     95        MT_longdouble=13,
     96        MT_bool=14,
     97        MT_void=15,
     98        MT_string=16,
     99        MT_vector2=17,
     100        MT_vector3=18,
     101        MT_vector4=19,
     102        MT_colourvalue=20,
     103        MT_quaternion=21,
     104        MT_radian=22,
     105        MT_degree=23
    106106    };
    107107
     
    223223
    224224            virtual void toString(std::ostream& outstream) const = 0;
     225           
     226            virtual void importData( uint8_t*& mem )=0;
     227            virtual void exportData( uint8_t*& mem ) const=0;
     228            virtual uint8_t getSize() const=0;
    225229
    226230            MT_Type type_;          //!< The type of the current value
     
    320324            template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
    321325            std::string                       getTypename()             const;
     326           
     327            /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
     328            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
     329            /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
     330            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
     331            /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
     332            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
     333            /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
     334            inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
     335            inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
    322336
    323337            /** @brief Checks whether the value is a default one. */
  • code/branches/netp3/src/util/MultiTypeValue.h

    r2171 r2990  
    4040#include "MathConvert.h"
    4141#include "MultiType.h"
     42#include "Serialise.h"
     43#include <cassert>
    4244
    4345namespace orxonox
     
    147149        /** @brief Puts the current value on the stream */
    148150        inline void toString(std::ostream& outstream) const { outstream << this->value_; }
     151       
     152        /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
     153        inline void importData( uint8_t*& mem )         { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
     154        /** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */
     155        inline void exportData( uint8_t*& mem ) const   { saveAndIncrease( /*(const T&)*/this->value_, mem ); }
     156        /** @brief returns the size of the data that would be saved by exportData */
     157        inline uint8_t getSize() const { return returnSize( this->value_ ); }
    149158
    150159        T value_; //!< The stored value
    151160    };
     161   
     162    // Import / Export specialisation
     163    // ColourValue
     164    template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem )
     165    {
     166        loadAndIncrease( this->value_.r, mem );
     167        loadAndIncrease( this->value_.g, mem );
     168        loadAndIncrease( this->value_.b, mem );
     169        loadAndIncrease( this->value_.a, mem );
     170    }
     171    template <> inline void MT_Value<ColourValue>::exportData( uint8_t*& mem ) const
     172    {
     173        saveAndIncrease( this->value_.r, mem );
     174        saveAndIncrease( this->value_.g, mem );
     175        saveAndIncrease( this->value_.b, mem );
     176        saveAndIncrease( this->value_.a, mem );
     177    }
     178    template <> inline uint8_t MT_Value<ColourValue>::getSize() const
     179    {
     180        return 4*returnSize(this->value_.r);
     181    }
     182    // Ogre::Quaternion
     183    template <> inline void MT_Value<Ogre::Quaternion>::importData( uint8_t*& mem )
     184    {
     185        loadAndIncrease( this->value_.x, mem );
     186        loadAndIncrease( this->value_.y, mem );
     187        loadAndIncrease( this->value_.z, mem );
     188        loadAndIncrease( this->value_.w, mem );
     189    }
     190    template <> inline void MT_Value<Ogre::Quaternion>::exportData( uint8_t*& mem ) const
     191    {
     192        saveAndIncrease( this->value_.x, mem );
     193        saveAndIncrease( this->value_.y, mem );
     194        saveAndIncrease( this->value_.z, mem );
     195        saveAndIncrease( this->value_.w, mem );
     196    }template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const
     197    {
     198        return 4*returnSize(this->value_.x);
     199    }
     200    // Ogre::Vector2
     201    template <> inline void MT_Value<Ogre::Vector2>::importData( uint8_t*& mem )
     202    {
     203        loadAndIncrease( this->value_.x, mem );
     204        loadAndIncrease( this->value_.y, mem );
     205    }
     206    template <> inline void MT_Value<Ogre::Vector2>::exportData( uint8_t*& mem ) const
     207    {
     208        saveAndIncrease( this->value_.x, mem );
     209        saveAndIncrease( this->value_.y, mem );
     210    }
     211    template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const
     212    {
     213        return 2*returnSize(this->value_.x);
     214    }
     215    // Ogre::Vector3
     216    template <> inline void MT_Value<Ogre::Vector3>::importData( uint8_t*& mem )
     217    {
     218        loadAndIncrease( this->value_.x, mem );
     219        loadAndIncrease( this->value_.y, mem );
     220        loadAndIncrease( this->value_.z, mem );
     221    }
     222    template <> inline void MT_Value<Ogre::Vector3>::exportData( uint8_t*& mem ) const
     223    {
     224        saveAndIncrease( this->value_.x, mem );
     225        saveAndIncrease( this->value_.y, mem );
     226        saveAndIncrease( this->value_.z, mem );
     227    }
     228    template <> inline uint8_t MT_Value<Ogre::Vector3>::getSize() const
     229    {
     230        return 3*returnSize(this->value_.x);
     231    }
     232    // Ogre::Vector4
     233    template <> inline void MT_Value<Ogre::Vector4>::importData( uint8_t*& mem )
     234    {
     235        loadAndIncrease( this->value_.x, mem );
     236        loadAndIncrease( this->value_.y, mem );
     237        loadAndIncrease( this->value_.z, mem );
     238        loadAndIncrease( this->value_.w, mem );
     239    }
     240    template <> inline void MT_Value<Ogre::Vector4>::exportData( uint8_t*& mem ) const
     241    {
     242        saveAndIncrease( this->value_.x, mem );
     243        saveAndIncrease( this->value_.y, mem );
     244        saveAndIncrease( this->value_.z, mem );
     245        saveAndIncrease( this->value_.w, mem );
     246    }
     247    template <> inline uint8_t MT_Value<Ogre::Vector4>::getSize() const
     248    {
     249        return 4*returnSize(this->value_.x);
     250    }
     251    template <> inline void MT_Value<void*>::importData( uint8_t*& mem )
     252    {
     253        assert(0);
     254    }
     255    template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const
     256    {
     257        assert(0);
     258    }
     259    template <> inline uint8_t MT_Value<void*>::getSize() const
     260    {
     261        assert(0); return 0;
     262    }
    152263}
    153264
  • code/branches/netp3/src/util/SignalHandler.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/netp3/src/util/SignalHandler.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.