Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2794 for code


Ignore:
Timestamp:
Mar 17, 2009, 12:49:29 PM (16 years ago)
Author:
scheusso
Message:

some optimisations (mostly inlined SynchronisableVariable functions)
trying to track down a bug with enet connections

Location:
code/branches/netp/src
Files:
1 deleted
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/netp/src/network/ClientConnection.cc

    r2773 r2794  
    4242#include <enet/enet.h>
    4343#include <iostream>
     44#include <cassert>
    4445// boost.thread library for multithreading support
    4546#include <boost/thread/thread.hpp>
     
    166167        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
    167168          // we should never reach this point
     169                assert(0);
    168170          quit=true;
    169171          continue;
     
    206208    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    207209    enet_peer_disconnect(server, 0);
    208     while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
     210    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) >= 0){
    209211      switch (event.type)
    210212      {
  • code/branches/netp/src/network/ClientConnection.h

    r2773 r2794  
    5353    const int NETWORK_PORT = 55556;
    5454    const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
    55     const int NETWORK_CLIENT_WAIT_TIME = 1;
    56     const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
     55    const int NETWORK_CLIENT_WAIT_TIME = 10;
     56    const int NETWORK_CLIENT_CONNECT_TIMEOUT = 10000; // miliseconds
    5757    const int NETWORK_CLIENT_CHANNELS = 2;
    5858
  • code/branches/netp/src/network/ConnectionManager.cc

    r2773 r2794  
    5757{
    5858  bool operator< (ENetAddress a, ENetAddress b) {
    59     if(a.host <= b.host)
    60       return true;
    61     else
    62       return false;
     59    return a.host <= b.host;
    6360  }
    6461}
     
    198195        if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
    199196          // we should never reach this point
     197          assert(0);
    200198          quit=true;
    201199          continue;
     
    214212        case ENET_EVENT_TYPE_NONE:
    215213          //receiverThread_->yield();
    216           msleep(1);
     214          msleep(10);
    217215          break;
    218216      }
     
    266264  }
    267265
    268   bool ConnectionManager::processData(ENetEvent *event) {
    269     // just add packet to the buffer
    270     // this can be extended with some preprocessing
    271     return buffer.push(event);
    272   }
    273 
    274 
    275266
    276267  int ConnectionManager::getClientID(ENetPeer* peer) {
  • code/branches/netp/src/network/ConnectionManager.h

    r2773 r2794  
    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
     
    8484  private:
    8585    ConnectionManager(const ConnectionManager& copy); // not used
    86     bool processData(ENetEvent *event);
     86    inline bool processData(ENetEvent *event){ return buffer.push(event); }
    8787    void receiverThread();
    8888    void disconnectClients();
  • code/branches/netp/src/network/TrafficControl.cc

    r2662 r2794  
    9090  void TrafficControl::setConfigValues()
    9191  {
    92     SetConfigValue ( bActive_, true );
    93     SetConfigValue ( targetSize, 5000 );
     92    SetConfigValue ( bActive_, false );
     93    SetConfigValue ( targetSize, 10000 );
    9494  }
    9595
  • code/branches/netp/src/network/packet/Packet.h

    r2773 r2794  
    6666    virtual unsigned int getSize() const =0;
    6767    virtual bool process()=0;
    68     uint32_t getFlags()
     68    inline uint32_t getFlags()
    6969      { return flags_; }
    70     int getClientID()
     70    inline int getClientID()
    7171      { return clientID_; }
    72     void setClientID( int id )
     72    inline void setClientID( int id )
    7373      { clientID_ = id; }
    7474
  • code/branches/netp/src/network/synchronisable/SynchronisableVariable.h

    r2710 r2794  
    7979      virtual inline void* getReference(){ return (void *)&this->variable_; }
    8080    protected:
    81       bool checkEquality(uint8_t* mem);
    82       void setAndIncrease(uint8_t*& mem);
    83       void getAndIncrease(uint8_t*& mem);
    84       uint32_t returnSize();
     81      inline bool checkEquality(uint8_t* mem);
     82      inline void setAndIncrease(uint8_t*& mem);
     83      inline void getAndIncrease(uint8_t*& mem);
     84      inline uint32_t returnSize();
    8585     
    8686      T& variable_;
     
    9797     
    9898      virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
    99       virtual void getData(uint8_t*& mem, uint8_t mode);
     99      virtual inline void getData(uint8_t*& mem, uint8_t mode);
    100100      virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
    101       virtual uint32_t getSize(uint8_t mode);
     101      virtual inline uint32_t getSize(uint8_t mode);
    102102    private:
    103103      T varBuffer_;
     
    122122  }
    123123
    124   template <class T> void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
     124  template <class T> inline void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
    125125  {
    126126    if ( state_ == this->mode_ )
     
    143143  // write the data
    144144    setAndIncrease( mem );
    145 //   mem += SynchronisableVariable<T>::getSize();
    146145  // now do a callback if neccessary
    147146    if ( callback )
    148147      NetworkCallbackManager::triggerCallback( this->callback_ );
    149       //this->callback_->call();
    150   }
    151 
    152   template <class T> uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
     148  }
     149
     150  template <class T> inline uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
    153151  {
    154152    if ( mode == this->mode_ )
     
    304302    }
    305303
    306     template <class T> uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
     304    template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
    307305    {
    308306      return SynchronisableVariable<T>::returnSize() + sizeof(varReference_);
     
    312310}
    313311
     312#include "network/synchronisable/SynchronisableVariableSpecialisations.h"
    314313
    315314#endif
  • code/branches/netp/src/network/synchronisable/SynchronisableVariableSpecialisations.h

    • Property svn:mergeinfo set to (toggle deleted branches)
      /code/branches/buildsystem/src/network/synchronisable/SynchronisableVariable.cc1874-2276,​2278-2400
      /code/branches/buildsystem2/src/network/synchronisable/SynchronisableVariable.cc2506-2658
      /code/branches/buildsystem3/src/network/synchronisable/SynchronisableVariable.cc2662-2708
      /code/branches/ceguilua/src/network/synchronisable/SynchronisableVariable.cc1802-1808
      /code/branches/core3/src/network/synchronisable/SynchronisableVariable.cc1572-1739
      /code/branches/gcc43/src/network/synchronisable/SynchronisableVariable.cc1580
      /code/branches/gui/src/network/synchronisable/SynchronisableVariable.cc1635-1723
      /code/branches/input/src/network/synchronisable/SynchronisableVariable.cc1629-1636
      /code/branches/lodfinal/src/network/synchronisable/SynchronisableVariable.cc2372-2411
      /code/branches/network/src/network/synchronisable/SynchronisableVariable.cc2356
      /code/branches/network64/src/network/synchronisable/SynchronisableVariable.cc2210-2355
      /code/branches/objecthierarchy/src/network/synchronisable/SynchronisableVariable.cc1911-2085,​2100,​2110-2169
      /code/branches/objecthierarchy2/src/network/synchronisable/SynchronisableVariable.cc2171-2479
      /code/branches/overlay/src/network/synchronisable/SynchronisableVariable.cc2117-2385
      /code/branches/physics/src/network/synchronisable/SynchronisableVariable.cc1912-2055,​2107-2439
      /code/branches/physics_merge/src/network/synchronisable/SynchronisableVariable.cc2436-2457
      /code/branches/pickups/src/network/synchronisable/SynchronisableVariable.cc1926-2086,​2127
      /code/branches/pickups2/src/network/synchronisable/SynchronisableVariable.cc2107-2497
      /code/branches/presentation/src/network/synchronisable/SynchronisableVariable.cc2369-2652,​2654-2660
      /code/branches/questsystem/src/network/synchronisable/SynchronisableVariable.cc1894-2088
      /code/branches/questsystem2/src/network/synchronisable/SynchronisableVariable.cc2107-2259
      /code/branches/script_trigger/src/network/synchronisable/SynchronisableVariable.cc1295-1953,​1955
      /code/branches/weapon/src/network/synchronisable/SynchronisableVariable.cc1925-2094
      /code/branches/weapon2/src/network/synchronisable/SynchronisableVariable.cc2107-2488
    r2775 r2794  
    2727 */
    2828
    29 #include "SynchronisableVariable.h"
    3029#include <cstring>
    3130#include "util/Math.h"
    3231
     32#ifndef _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__
     33#define _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__
    3334
    3435namespace orxonox{
    3536
    36 uint8_t SynchronisableVariableBase::state_ = 0;
    37 
    3837
    3938
     
    4241// =========== bool
    4342
    44 template <> uint32_t SynchronisableVariable<const bool>::returnSize()
     43template <> inline uint32_t SynchronisableVariable<const bool>::returnSize()
    4544{
    4645  return sizeof(uint8_t);
    4746}
    4847
    49 template <> void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )
     48template <> inline void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )
    5049{
    5150  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
     
    5352}
    5453
    55 template <> void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )
     54template <> inline void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )
    5655{
    5756  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
     
    5958}
    6059
    61 template <> bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )
     60template <> inline bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )
    6261{
    6362  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
     
    6665// =========== char
    6766
    68 template <> uint32_t SynchronisableVariable<const char>::returnSize()
     67template <> inline uint32_t SynchronisableVariable<const char>::returnSize()
    6968{
    7069  return sizeof(uint8_t);
    7170}
    7271
    73 template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
     72template <> inline void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
    7473{
    7574  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
     
    7776}
    7877
    79 template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
     78template <> inline void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
    8079{
    8180  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
     
    8382}
    8483
    85 template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
     84template <> inline bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
    8685{
    8786  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
     
    9089// =========== unsigned char
    9190
    92 template <> uint32_t SynchronisableVariable<const unsigned char>::returnSize()
     91template <> inline uint32_t SynchronisableVariable<const unsigned char>::returnSize()
    9392{
    9493  return sizeof(uint8_t);
    9594}
    9695
    97 template <> void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem )
     96template <> inline void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem )
    9897{
    9998  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
     
    101100}
    102101
    103 template <> void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem )
     102template <> inline void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem )
    104103{
    105104  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
     
    107106}
    108107
    109 template <> bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )
     108template <> inline bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )
    110109{
    111110  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
     
    114113// =========== short
    115114
    116 template <> uint32_t SynchronisableVariable<const short>::returnSize()
     115template <> inline uint32_t SynchronisableVariable<const short>::returnSize()
    117116{
    118117  return sizeof(int16_t);
    119118}
    120119
    121 template <> void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )
     120template <> inline void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )
    122121{
    123122  *(short*)(&this->variable_) = *(int16_t*)(mem);
     
    125124}
    126125
    127 template <> void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )
     126template <> inline void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )
    128127{
    129128  *(int16_t*)(mem) = this->variable_;
     
    131130}
    132131
    133 template <> bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )
     132template <> inline bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )
    134133{
    135134  return *(int16_t*)(mem) == static_cast<int16_t>(this->variable_);
     
    138137// =========== unsigned short
    139138
    140 template <> uint32_t SynchronisableVariable<const unsigned short>::returnSize()
     139template <> inline uint32_t SynchronisableVariable<const unsigned short>::returnSize()
    141140{
    142141  return sizeof(uint16_t);
    143142}
    144143
    145 template <> void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )
     144template <> inline void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )
    146145{
    147146  *(unsigned short*)(&this->variable_) = *(uint16_t*)(mem);
     
    149148}
    150149
    151 template <> void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )
     150template <> inline void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )
    152151{
    153152  *(uint16_t*)(mem) = this->variable_;
     
    155154}
    156155
    157 template <> bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )
     156template <> inline bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )
    158157{
    159158  return *(uint16_t*)(mem) == this->variable_;
     
    162161// =========== int
    163162
    164 template <> uint32_t SynchronisableVariable<const int>::returnSize()
     163template <> inline uint32_t SynchronisableVariable<const int>::returnSize()
    165164{
    166165  return sizeof(int32_t);
    167166}
    168167
    169 template <> void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )
     168template <> inline void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )
    170169{
    171170  *(int *)(&this->variable_) = *(int32_t*)(mem);
     
    173172}
    174173
    175 template <> void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )
     174template <> inline void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )
    176175{
    177176  *(int32_t*)(mem) = this->variable_;
     
    179178}
    180179
    181 template <> bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )
     180template <> inline bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )
    182181{
    183182  return *(int32_t*)(mem) == this->variable_;
     
    186185// =========== unsigned int
    187186
    188 template <> uint32_t SynchronisableVariable<const unsigned int>::returnSize()
     187template <> inline uint32_t SynchronisableVariable<const unsigned int>::returnSize()
    189188{
    190189  return sizeof(uint32_t);
    191190}
    192191   
    193 template <> void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )
     192template <> inline void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )
    194193{
    195194  *(unsigned int*)(&this->variable_) = *(uint32_t*)(mem);
     
    197196}
    198197
    199 template <> void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )
     198template <> inline void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )
    200199{
    201200  *(uint32_t*)(mem) = this->variable_;
     
    203202}
    204203
    205 template <> bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )
     204template <> inline bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )
    206205{
    207206  return *(uint32_t*)(mem) == this->variable_;
     
    210209// =========== long
    211210
    212 template <> uint32_t SynchronisableVariable<const long>::returnSize()
     211template <> inline uint32_t SynchronisableVariable<const long>::returnSize()
    213212{
    214213  return sizeof(int32_t);
    215214}
    216215
    217 template <> void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )
     216template <> inline void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )
    218217{
    219218  *(long*)(&this->variable_) = *(int32_t*)(mem);
     
    221220}
    222221
    223 template <> void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )
     222template <> inline void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )
    224223{
    225224  *(int32_t*)(mem) = this->variable_;
     
    227226}
    228227
    229 template <> bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )
     228template <> inline bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )
    230229{
    231230  return *(int32_t*)(mem) == this->variable_;
     
    234233// =========== unsigned long
    235234
    236 template <> uint32_t SynchronisableVariable<const unsigned long>::returnSize()
     235template <> inline uint32_t SynchronisableVariable<const unsigned long>::returnSize()
    237236{
    238237  return sizeof(uint32_t);
    239238}
    240239
    241 template <> void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )
     240template <> inline void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )
    242241{
    243242  *(unsigned long*)(&this->variable_) = *(uint32_t*)(mem);
     
    245244}
    246245
    247 template <> void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )
     246template <> inline void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )
    248247{
    249248  *(uint32_t*)(mem) = this->variable_;
     
    251250}
    252251
    253 template <> bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )
     252template <> inline bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )
    254253{
    255254  return *(uint32_t*)(mem) == this->variable_;
     
    258257// =========== long long
    259258
    260 template <> uint32_t SynchronisableVariable<const long long>::returnSize()
     259template <> inline uint32_t SynchronisableVariable<const long long>::returnSize()
    261260{
    262261  return sizeof(int64_t);
    263262}
    264263
    265 template <> void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )
     264template <> inline void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )
    266265{
    267266  *(long long*)(&this->variable_) = *(int64_t*)(mem);
     
    269268}
    270269
    271 template <> void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )
     270template <> inline void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )
    272271{
    273272  *(int64_t*)(mem) = this->variable_;
     
    275274}
    276275
    277 template <> bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )
     276template <> inline bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )
    278277{
    279278  return *(int64_t*)(mem) == this->variable_;
     
    282281// =========== unsigned long long
    283282
    284 template <> uint32_t SynchronisableVariable<const unsigned long long>::returnSize()
     283template <> inline uint32_t SynchronisableVariable<const unsigned long long>::returnSize()
    285284{
    286285  return sizeof(uint64_t);
    287286}
    288287
    289 template <> void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem )
     288template <> inline void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem )
    290289{
    291290  *(unsigned long long*)(&this->variable_) = *(uint64_t*)(mem);
     
    293292}
    294293
    295 template <> void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )
     294template <> inline void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )
    296295{
    297296  *(uint64_t*)(mem) = this->variable_;
     
    299298}
    300299
    301 template <> bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )
     300template <> inline bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )
    302301{
    303302  return *(uint64_t*)(mem) == this->variable_;
     
    306305// =========== float
    307306
    308 template <> uint32_t SynchronisableVariable<const float>::returnSize()
     307template <> inline uint32_t SynchronisableVariable<const float>::returnSize()
    309308{
    310309  return sizeof(uint32_t);
    311310}
    312311
    313 template <> void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )
     312template <> inline void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )
    314313{
    315314  *(uint32_t*)(&this->variable_) = *(uint32_t*)(mem);
     
    317316}
    318317
    319 template <> void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )
     318template <> inline void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )
    320319{
    321320  *(uint32_t*)(mem) = *(uint32_t*)(&this->variable_);
     
    323322}
    324323
    325 template <> bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )
     324template <> inline bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )
    326325{
    327326  return *(uint32_t*)(mem) == *(uint32_t*)(&this->variable_);
     
    330329// =========== double
    331330
    332 template <> uint32_t SynchronisableVariable<const double>::returnSize()
     331template <> inline uint32_t SynchronisableVariable<const double>::returnSize()
    333332{
    334333  return sizeof(uint64_t);
    335334}
    336335
    337 template <> void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )
     336template <> inline void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )
    338337{
    339338  *(uint64_t*)(&this->variable_) = *(uint64_t*)(mem);
     
    341340}
    342341
    343 template <> void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )
     342template <> inline void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )
    344343{
    345344  *(uint64_t*)(mem) = *(uint64_t*)(&this->variable_);
     
    347346}
    348347
    349 template <> bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )
     348template <> inline bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )
    350349{
    351350  return *(uint64_t*)(mem) == *(uint64_t*)(&this->variable_);
     
    354353// =========== long double
    355354
    356 template <> uint32_t SynchronisableVariable<const long double>::returnSize()
     355template <> inline uint32_t SynchronisableVariable<const long double>::returnSize()
    357356{
    358357  return sizeof(uint64_t);
    359358}
    360359
    361 template <> void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem )
     360template <> inline void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem )
    362361{
    363362  double temp;
     
    367366}
    368367
    369 template <> void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem )
     368template <> inline void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem )
    370369{
    371370  double temp = static_cast<double>(this->variable_);
     
    374373}
    375374
    376 template <> bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )
     375template <> inline bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )
    377376{
    378377  double temp = static_cast<double>(this->variable_);
     
    382381// =========== string
    383382
    384 template <> uint32_t SynchronisableVariable<const std::string>::returnSize()
     383template <> inline uint32_t SynchronisableVariable<const std::string>::returnSize()
    385384{
    386385  return variable_.length()+1;
    387386}
    388387
    389 template <> void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem )
     388template <> inline void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem )
    390389{
    391390  memcpy(mem, this->variable_.c_str(), this->variable_.length()+1);
     
    393392}
    394393
    395 template <> void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )
     394template <> inline void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )
    396395{
    397396  *(std::string*)(&this->variable_) = std::string((const char *)mem);
     
    399398}
    400399
    401 template <> bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )
     400template <> inline bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )
    402401{
    403402  return std::string((const char*)mem)==this->variable_;
     
    406405// =========== Degree
    407406
    408 template <> uint32_t SynchronisableVariable<const Degree>::returnSize()
     407template <> inline uint32_t SynchronisableVariable<const Degree>::returnSize()
    409408{
    410409  return sizeof(Ogre::Real);
    411410}
    412411
    413 template <> void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )
     412template <> inline void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )
    414413{
    415414  Ogre::Real r = this->variable_.valueDegrees();
     
    418417}
    419418
    420 template <> void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )
     419template <> inline void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )
    421420{
    422421  Ogre::Real* r = (Ogre::Real*)mem;
     
    425424}
    426425
    427 template <> bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )
     426template <> inline bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )
    428427{
    429428  Ogre::Real* r = (Ogre::Real*)mem;
     
    432431
    433432}
     433
     434
     435#endif
  • code/branches/netp/src/orxonox/objects/controllers/AIController.cc

    r2662 r2794  
    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);
Note: See TracChangeset for help on using the changeset viewer.