Changeset 2794 for code/branches/netp/src
- Timestamp:
- Mar 17, 2009, 12:49:29 PM (16 years ago)
- 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 42 42 #include <enet/enet.h> 43 43 #include <iostream> 44 #include <cassert> 44 45 // boost.thread library for multithreading support 45 46 #include <boost/thread/thread.hpp> … … 166 167 if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){ 167 168 // we should never reach this point 169 assert(0); 168 170 quit=true; 169 171 continue; … … 206 208 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 207 209 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){ 209 211 switch (event.type) 210 212 { -
code/branches/netp/src/network/ClientConnection.h
r2773 r2794 53 53 const int NETWORK_PORT = 55556; 54 54 const int NETWORK_CLIENT_MAX_CONNECTIONS = 5; 55 const int NETWORK_CLIENT_WAIT_TIME = 1 ;56 const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds55 const int NETWORK_CLIENT_WAIT_TIME = 10; 56 const int NETWORK_CLIENT_CONNECT_TIMEOUT = 10000; // miliseconds 57 57 const int NETWORK_CLIENT_CHANNELS = 2; 58 58 -
code/branches/netp/src/network/ConnectionManager.cc
r2773 r2794 57 57 { 58 58 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; 63 60 } 64 61 } … … 198 195 if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){ 199 196 // we should never reach this point 197 assert(0); 200 198 quit=true; 201 199 continue; … … 214 212 case ENET_EVENT_TYPE_NONE: 215 213 //receiverThread_->yield(); 216 msleep(1 );214 msleep(10); 217 215 break; 218 216 } … … 266 264 } 267 265 268 bool ConnectionManager::processData(ENetEvent *event) {269 // just add packet to the buffer270 // this can be extended with some preprocessing271 return buffer.push(event);272 }273 274 275 266 276 267 int ConnectionManager::getClientID(ENetPeer* peer) { -
code/branches/netp/src/network/ConnectionManager.h
r2773 r2794 55 55 const int NETWORK_PORT = 55556; 56 56 const int NETWORK_MAX_CONNECTIONS = 50; 57 const int NETWORK_WAIT_TIMEOUT = 1 ;57 const int NETWORK_WAIT_TIMEOUT = 10; 58 58 const int NETWORK_DEFAULT_CHANNEL = 0; 59 59 … … 84 84 private: 85 85 ConnectionManager(const ConnectionManager& copy); // not used 86 bool processData(ENetEvent *event);86 inline bool processData(ENetEvent *event){ return buffer.push(event); } 87 87 void receiverThread(); 88 88 void disconnectClients(); -
code/branches/netp/src/network/TrafficControl.cc
r2662 r2794 90 90 void TrafficControl::setConfigValues() 91 91 { 92 SetConfigValue ( bActive_, true );93 SetConfigValue ( targetSize, 5000 );92 SetConfigValue ( bActive_, false ); 93 SetConfigValue ( targetSize, 10000 ); 94 94 } 95 95 -
code/branches/netp/src/network/packet/Packet.h
r2773 r2794 66 66 virtual unsigned int getSize() const =0; 67 67 virtual bool process()=0; 68 uint32_t getFlags()68 inline uint32_t getFlags() 69 69 { return flags_; } 70 in t getClientID()70 inline int getClientID() 71 71 { return clientID_; } 72 void setClientID( int id )72 inline void setClientID( int id ) 73 73 { clientID_ = id; } 74 74 -
code/branches/netp/src/network/synchronisable/SynchronisableVariable.h
r2710 r2794 79 79 virtual inline void* getReference(){ return (void *)&this->variable_; } 80 80 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(); 85 85 86 86 T& variable_; … … 97 97 98 98 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); 100 100 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); 102 102 private: 103 103 T varBuffer_; … … 122 122 } 123 123 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) 125 125 { 126 126 if ( state_ == this->mode_ ) … … 143 143 // write the data 144 144 setAndIncrease( mem ); 145 // mem += SynchronisableVariable<T>::getSize();146 145 // now do a callback if neccessary 147 146 if ( callback ) 148 147 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) 153 151 { 154 152 if ( mode == this->mode_ ) … … 304 302 } 305 303 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) 307 305 { 308 306 return SynchronisableVariable<T>::returnSize() + sizeof(varReference_); … … 312 310 } 313 311 312 #include "network/synchronisable/SynchronisableVariableSpecialisations.h" 314 313 315 314 #endif -
code/branches/netp/src/network/synchronisable/SynchronisableVariableSpecialisations.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/code/branches/buildsystem/src/network/synchronisable/SynchronisableVariable.cc 1874-2276,2278-2400 /code/branches/buildsystem2/src/network/synchronisable/SynchronisableVariable.cc 2506-2658 /code/branches/buildsystem3/src/network/synchronisable/SynchronisableVariable.cc 2662-2708 /code/branches/ceguilua/src/network/synchronisable/SynchronisableVariable.cc 1802-1808 /code/branches/core3/src/network/synchronisable/SynchronisableVariable.cc 1572-1739 /code/branches/gcc43/src/network/synchronisable/SynchronisableVariable.cc 1580 /code/branches/gui/src/network/synchronisable/SynchronisableVariable.cc 1635-1723 /code/branches/input/src/network/synchronisable/SynchronisableVariable.cc 1629-1636 /code/branches/lodfinal/src/network/synchronisable/SynchronisableVariable.cc 2372-2411 /code/branches/network/src/network/synchronisable/SynchronisableVariable.cc 2356 /code/branches/network64/src/network/synchronisable/SynchronisableVariable.cc 2210-2355 /code/branches/objecthierarchy/src/network/synchronisable/SynchronisableVariable.cc 1911-2085,2100,2110-2169 /code/branches/objecthierarchy2/src/network/synchronisable/SynchronisableVariable.cc 2171-2479 /code/branches/overlay/src/network/synchronisable/SynchronisableVariable.cc 2117-2385 /code/branches/physics/src/network/synchronisable/SynchronisableVariable.cc 1912-2055,2107-2439 /code/branches/physics_merge/src/network/synchronisable/SynchronisableVariable.cc 2436-2457 /code/branches/pickups/src/network/synchronisable/SynchronisableVariable.cc 1926-2086,2127 /code/branches/pickups2/src/network/synchronisable/SynchronisableVariable.cc 2107-2497 /code/branches/presentation/src/network/synchronisable/SynchronisableVariable.cc 2369-2652,2654-2660 /code/branches/questsystem/src/network/synchronisable/SynchronisableVariable.cc 1894-2088 /code/branches/questsystem2/src/network/synchronisable/SynchronisableVariable.cc 2107-2259 /code/branches/script_trigger/src/network/synchronisable/SynchronisableVariable.cc 1295-1953,1955 /code/branches/weapon/src/network/synchronisable/SynchronisableVariable.cc 1925-2094 /code/branches/weapon2/src/network/synchronisable/SynchronisableVariable.cc 2107-2488
r2775 r2794 27 27 */ 28 28 29 #include "SynchronisableVariable.h"30 29 #include <cstring> 31 30 #include "util/Math.h" 32 31 32 #ifndef _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__ 33 #define _NETWORK_SYNCHRONISABLEVARIABLESPECIALISATIONS__ 33 34 34 35 namespace orxonox{ 35 36 36 uint8_t SynchronisableVariableBase::state_ = 0;37 38 37 39 38 … … 42 41 // =========== bool 43 42 44 template <> uint32_t SynchronisableVariable<const bool>::returnSize()43 template <> inline uint32_t SynchronisableVariable<const bool>::returnSize() 45 44 { 46 45 return sizeof(uint8_t); 47 46 } 48 47 49 template <> void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )48 template <> inline void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem ) 50 49 { 51 50 *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem); … … 53 52 } 54 53 55 template <> void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )54 template <> inline void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem ) 56 55 { 57 56 *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_); … … 59 58 } 60 59 61 template <> bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )60 template <> inline bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem ) 62 61 { 63 62 return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_); … … 66 65 // =========== char 67 66 68 template <> uint32_t SynchronisableVariable<const char>::returnSize()67 template <> inline uint32_t SynchronisableVariable<const char>::returnSize() 69 68 { 70 69 return sizeof(uint8_t); 71 70 } 72 71 73 template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )72 template <> inline void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem ) 74 73 { 75 74 *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem); … … 77 76 } 78 77 79 template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )78 template <> inline void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem ) 80 79 { 81 80 *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_); … … 83 82 } 84 83 85 template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )84 template <> inline bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem ) 86 85 { 87 86 return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_); … … 90 89 // =========== unsigned char 91 90 92 template <> uint32_t SynchronisableVariable<const unsigned char>::returnSize()91 template <> inline uint32_t SynchronisableVariable<const unsigned char>::returnSize() 93 92 { 94 93 return sizeof(uint8_t); 95 94 } 96 95 97 template <> void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem )96 template <> inline void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem ) 98 97 { 99 98 *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem); … … 101 100 } 102 101 103 template <> void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem )102 template <> inline void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem ) 104 103 { 105 104 *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_); … … 107 106 } 108 107 109 template <> bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )108 template <> inline bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem ) 110 109 { 111 110 return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_); … … 114 113 // =========== short 115 114 116 template <> uint32_t SynchronisableVariable<const short>::returnSize()115 template <> inline uint32_t SynchronisableVariable<const short>::returnSize() 117 116 { 118 117 return sizeof(int16_t); 119 118 } 120 119 121 template <> void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )120 template <> inline void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem ) 122 121 { 123 122 *(short*)(&this->variable_) = *(int16_t*)(mem); … … 125 124 } 126 125 127 template <> void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )126 template <> inline void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem ) 128 127 { 129 128 *(int16_t*)(mem) = this->variable_; … … 131 130 } 132 131 133 template <> bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )132 template <> inline bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem ) 134 133 { 135 134 return *(int16_t*)(mem) == static_cast<int16_t>(this->variable_); … … 138 137 // =========== unsigned short 139 138 140 template <> uint32_t SynchronisableVariable<const unsigned short>::returnSize()139 template <> inline uint32_t SynchronisableVariable<const unsigned short>::returnSize() 141 140 { 142 141 return sizeof(uint16_t); 143 142 } 144 143 145 template <> void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )144 template <> inline void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem ) 146 145 { 147 146 *(unsigned short*)(&this->variable_) = *(uint16_t*)(mem); … … 149 148 } 150 149 151 template <> void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )150 template <> inline void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem ) 152 151 { 153 152 *(uint16_t*)(mem) = this->variable_; … … 155 154 } 156 155 157 template <> bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )156 template <> inline bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem ) 158 157 { 159 158 return *(uint16_t*)(mem) == this->variable_; … … 162 161 // =========== int 163 162 164 template <> uint32_t SynchronisableVariable<const int>::returnSize()163 template <> inline uint32_t SynchronisableVariable<const int>::returnSize() 165 164 { 166 165 return sizeof(int32_t); 167 166 } 168 167 169 template <> void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )168 template <> inline void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem ) 170 169 { 171 170 *(int *)(&this->variable_) = *(int32_t*)(mem); … … 173 172 } 174 173 175 template <> void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )174 template <> inline void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem ) 176 175 { 177 176 *(int32_t*)(mem) = this->variable_; … … 179 178 } 180 179 181 template <> bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )180 template <> inline bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem ) 182 181 { 183 182 return *(int32_t*)(mem) == this->variable_; … … 186 185 // =========== unsigned int 187 186 188 template <> uint32_t SynchronisableVariable<const unsigned int>::returnSize()187 template <> inline uint32_t SynchronisableVariable<const unsigned int>::returnSize() 189 188 { 190 189 return sizeof(uint32_t); 191 190 } 192 191 193 template <> void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )192 template <> inline void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem ) 194 193 { 195 194 *(unsigned int*)(&this->variable_) = *(uint32_t*)(mem); … … 197 196 } 198 197 199 template <> void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )198 template <> inline void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem ) 200 199 { 201 200 *(uint32_t*)(mem) = this->variable_; … … 203 202 } 204 203 205 template <> bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )204 template <> inline bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem ) 206 205 { 207 206 return *(uint32_t*)(mem) == this->variable_; … … 210 209 // =========== long 211 210 212 template <> uint32_t SynchronisableVariable<const long>::returnSize()211 template <> inline uint32_t SynchronisableVariable<const long>::returnSize() 213 212 { 214 213 return sizeof(int32_t); 215 214 } 216 215 217 template <> void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )216 template <> inline void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem ) 218 217 { 219 218 *(long*)(&this->variable_) = *(int32_t*)(mem); … … 221 220 } 222 221 223 template <> void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )222 template <> inline void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem ) 224 223 { 225 224 *(int32_t*)(mem) = this->variable_; … … 227 226 } 228 227 229 template <> bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )228 template <> inline bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem ) 230 229 { 231 230 return *(int32_t*)(mem) == this->variable_; … … 234 233 // =========== unsigned long 235 234 236 template <> uint32_t SynchronisableVariable<const unsigned long>::returnSize()235 template <> inline uint32_t SynchronisableVariable<const unsigned long>::returnSize() 237 236 { 238 237 return sizeof(uint32_t); 239 238 } 240 239 241 template <> void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )240 template <> inline void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem ) 242 241 { 243 242 *(unsigned long*)(&this->variable_) = *(uint32_t*)(mem); … … 245 244 } 246 245 247 template <> void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )246 template <> inline void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem ) 248 247 { 249 248 *(uint32_t*)(mem) = this->variable_; … … 251 250 } 252 251 253 template <> bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )252 template <> inline bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem ) 254 253 { 255 254 return *(uint32_t*)(mem) == this->variable_; … … 258 257 // =========== long long 259 258 260 template <> uint32_t SynchronisableVariable<const long long>::returnSize()259 template <> inline uint32_t SynchronisableVariable<const long long>::returnSize() 261 260 { 262 261 return sizeof(int64_t); 263 262 } 264 263 265 template <> void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )264 template <> inline void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem ) 266 265 { 267 266 *(long long*)(&this->variable_) = *(int64_t*)(mem); … … 269 268 } 270 269 271 template <> void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )270 template <> inline void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem ) 272 271 { 273 272 *(int64_t*)(mem) = this->variable_; … … 275 274 } 276 275 277 template <> bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )276 template <> inline bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem ) 278 277 { 279 278 return *(int64_t*)(mem) == this->variable_; … … 282 281 // =========== unsigned long long 283 282 284 template <> uint32_t SynchronisableVariable<const unsigned long long>::returnSize()283 template <> inline uint32_t SynchronisableVariable<const unsigned long long>::returnSize() 285 284 { 286 285 return sizeof(uint64_t); 287 286 } 288 287 289 template <> void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem )288 template <> inline void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem ) 290 289 { 291 290 *(unsigned long long*)(&this->variable_) = *(uint64_t*)(mem); … … 293 292 } 294 293 295 template <> void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )294 template <> inline void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem ) 296 295 { 297 296 *(uint64_t*)(mem) = this->variable_; … … 299 298 } 300 299 301 template <> bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )300 template <> inline bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem ) 302 301 { 303 302 return *(uint64_t*)(mem) == this->variable_; … … 306 305 // =========== float 307 306 308 template <> uint32_t SynchronisableVariable<const float>::returnSize()307 template <> inline uint32_t SynchronisableVariable<const float>::returnSize() 309 308 { 310 309 return sizeof(uint32_t); 311 310 } 312 311 313 template <> void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )312 template <> inline void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem ) 314 313 { 315 314 *(uint32_t*)(&this->variable_) = *(uint32_t*)(mem); … … 317 316 } 318 317 319 template <> void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )318 template <> inline void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem ) 320 319 { 321 320 *(uint32_t*)(mem) = *(uint32_t*)(&this->variable_); … … 323 322 } 324 323 325 template <> bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )324 template <> inline bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem ) 326 325 { 327 326 return *(uint32_t*)(mem) == *(uint32_t*)(&this->variable_); … … 330 329 // =========== double 331 330 332 template <> uint32_t SynchronisableVariable<const double>::returnSize()331 template <> inline uint32_t SynchronisableVariable<const double>::returnSize() 333 332 { 334 333 return sizeof(uint64_t); 335 334 } 336 335 337 template <> void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )336 template <> inline void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem ) 338 337 { 339 338 *(uint64_t*)(&this->variable_) = *(uint64_t*)(mem); … … 341 340 } 342 341 343 template <> void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )342 template <> inline void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem ) 344 343 { 345 344 *(uint64_t*)(mem) = *(uint64_t*)(&this->variable_); … … 347 346 } 348 347 349 template <> bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )348 template <> inline bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem ) 350 349 { 351 350 return *(uint64_t*)(mem) == *(uint64_t*)(&this->variable_); … … 354 353 // =========== long double 355 354 356 template <> uint32_t SynchronisableVariable<const long double>::returnSize()355 template <> inline uint32_t SynchronisableVariable<const long double>::returnSize() 357 356 { 358 357 return sizeof(uint64_t); 359 358 } 360 359 361 template <> void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem )360 template <> inline void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem ) 362 361 { 363 362 double temp; … … 367 366 } 368 367 369 template <> void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem )368 template <> inline void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem ) 370 369 { 371 370 double temp = static_cast<double>(this->variable_); … … 374 373 } 375 374 376 template <> bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )375 template <> inline bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem ) 377 376 { 378 377 double temp = static_cast<double>(this->variable_); … … 382 381 // =========== string 383 382 384 template <> uint32_t SynchronisableVariable<const std::string>::returnSize()383 template <> inline uint32_t SynchronisableVariable<const std::string>::returnSize() 385 384 { 386 385 return variable_.length()+1; 387 386 } 388 387 389 template <> void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem )388 template <> inline void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem ) 390 389 { 391 390 memcpy(mem, this->variable_.c_str(), this->variable_.length()+1); … … 393 392 } 394 393 395 template <> void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )394 template <> inline void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem ) 396 395 { 397 396 *(std::string*)(&this->variable_) = std::string((const char *)mem); … … 399 398 } 400 399 401 template <> bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )400 template <> inline bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem ) 402 401 { 403 402 return std::string((const char*)mem)==this->variable_; … … 406 405 // =========== Degree 407 406 408 template <> uint32_t SynchronisableVariable<const Degree>::returnSize()407 template <> inline uint32_t SynchronisableVariable<const Degree>::returnSize() 409 408 { 410 409 return sizeof(Ogre::Real); 411 410 } 412 411 413 template <> void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )412 template <> inline void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem ) 414 413 { 415 414 Ogre::Real r = this->variable_.valueDegrees(); … … 418 417 } 419 418 420 template <> void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )419 template <> inline void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem ) 421 420 { 422 421 Ogre::Real* r = (Ogre::Real*)mem; … … 425 424 } 426 425 427 template <> bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )426 template <> inline bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem ) 428 427 { 429 428 Ogre::Real* r = (Ogre::Real*)mem; … … 432 431 433 432 } 433 434 435 #endif -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
code/branches/netp/src/orxonox/objects/controllers/AIController.cc
r2662 r2794 101 101 void AIController::tick(float dt) 102 102 { 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 } 114 117 115 118 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.