Changeset 2245
- Timestamp:
- Nov 22, 2008, 11:54:48 AM (16 years ago)
- Location:
- code/branches/network64/src
- Files:
-
- 2 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network64/src/network/NetworkPrereqs.h
r2171 r2245 70 70 class GamestateManager; 71 71 class GamestateHandler; 72 class NetworkCallbackBase; 72 73 class PacketBuffer; 73 74 class Server; 74 75 class ServerFrameListener; 75 76 class Synchronisable; 77 class SynchronisableVariableBase; 78 template <class T> class SynchronisableVariable; 79 template <class T> class SynchronisableVariableBidirectional; 76 80 struct ClientList; 77 81 struct PacketEnvelope; 78 82 struct QueueItem; 79 83 struct syncData; 80 struct synchronisableVariable;81 84 namespace packet{ 82 85 class Gamestate; -
code/branches/network64/src/network/synchronisable/CMakeLists.txt
r2211 r2245 1 1 SET( SRC_FILES 2 2 Synchronisable.cc 3 SynchronisableVariable.cc 3 4 ) 4 5 -
code/branches/network64/src/network/synchronisable/Synchronisable.cc
r2211 r2245 40 40 41 41 #include "Synchronisable.h" 42 #include "SynchronisableSpecialisations.cc" // this defines all specialisations for registerVariable 42 43 43 44 #include <cstring> … … 78 79 objectID=OBJECTID_UNKNOWN; 79 80 classID = (unsigned int)-1; 80 syncList = new std::list<synchronisableVariable *>;81 81 82 82 … … 114 114 // delete callback function objects 115 115 if(!Identifier::isCreatingHierarchy()){ 116 for(std::list< synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)117 delete (*it) ->callback;116 for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++) 117 delete (*it); 118 118 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 119 119 deletedObjects_.push(objectID); … … 127 127 if (it != objectMap_.end()) 128 128 objectMap_.erase(it); 129 }130 131 /**132 * This function gets called after all neccessary data has been passed to the object133 * Overload this function and recall the create function of the parent class134 * @return true/false135 */136 bool Synchronisable::create(){137 this->classID = this->getIdentifier()->getNetworkID();138 // COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;139 140 // COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;141 // objectMap_[objectID]=this;142 // assert(objectMap_[objectID]==this);143 // assert(objectMap_[objectID]->objectID==objectID);144 return true;145 129 } 146 130 … … 204 188 if (b) 205 189 { 206 b = no->create();190 // b = no->create(); 207 191 assert(b); 208 192 } … … 261 245 * @param cb callback object that should get called, if the value of the variable changes 262 246 */ 263 void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){ 247 248 /* void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){ 264 249 assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster); 265 250 // create temporary synch.Var struct … … 294 279 } 295 280 #endif 296 } 297 298 void Synchronisable::unregisterVariable(void *var){ 299 std::list<synchronisableVariable *>::iterator it = syncList->begin(); 300 while(it!=syncList->end()){ 301 if( (*it)->var == var ){ 302 delete *it; 303 syncList->erase(it); 304 return; 305 } 306 else 307 it++; 308 } 309 bool unregistered_nonexistent_variable = false; 310 assert(unregistered_nonexistent_variable); //if we reach this point something went wrong: 311 // the variable has not been registered before 312 } 313 281 }*/ 282 314 283 315 284 /** … … 343 312 assert(this->classID==this->getIdentifier()->getNetworkID()); 344 313 // this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this 345 std::list< synchronisableVariable*>::iterator i;314 std::list<SynchronisableVariableBase*>::iterator i; 346 315 unsigned int size; 347 316 size=getSize(id, mode); … … 361 330 COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl; 362 331 // copy to location 363 for(i=syncList->begin(); i!=syncList->end(); ++i){ 364 if( ((*i)->mode & mode) == 0 ){ 365 COUT(5) << "not getting data: " << std::endl; 366 continue; // this variable should only be received 367 } 368 369 // =========== start bidirectional stuff ============= 370 // if the variable gets synchronised bidirectional, then add the reference to the bytestream 371 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 372 { 373 if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \ 374 ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) ) 375 { 376 // MASTER 377 if((*i)->type==DATA){ 378 if( memcmp((*i)->var,(*i)->varBuffer,(*i)->size) != 0 ) //check whether the variable changed during the last tick 379 { 380 ((*i)->varReference)++; //the variable changed so increase the refnr 381 memcpy((*i)->varBuffer, (*i)->var, (*i)->size); //set the buffer to the new value 382 } 383 } 384 else //STRING 385 { 386 if( *static_cast<std::string*>((*i)->var) != *static_cast<std::string*>((*i)->varBuffer) ) //the string changed 387 { 388 ((*i)->varReference)++; //the variable changed 389 *static_cast<std::string*>((*i)->varBuffer) = *static_cast<std::string*>((*i)->var); //now set the buffer to the new value 390 } 391 } 392 } 393 // copy the reference number to the stream 394 *(uint8_t*)mem = (*i)->varReference; 395 mem += sizeof( (*i)->varReference ); 396 tempsize += sizeof( (*i)->varReference ); 397 } 398 // ================== end bidirectional stuff 399 400 switch((*i)->type){ 401 case DATA: 402 memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size); 403 mem += (*i)->size; 404 tempsize += (*i)->size; 405 break; 406 case STRING: 407 memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) ); 408 mem += sizeof(size_t); 409 const char *data = ( ( *(std::string *) (*i)->var).c_str()); 410 memcpy( mem, (void*)data, (*i)->size); 411 COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl; 412 mem += (*i)->size; 413 tempsize += (*i)->size + sizeof(size_t); 414 break; 415 } 332 for(i=syncList.begin(); i!=syncList.end(); ++i){ 333 (*i)->getData( mem, mode ); 334 tempsize += (*i)->getSize( mode ); 416 335 } 417 336 assert(tempsize==size); … … 429 348 if(mode==0x0) 430 349 mode=state_; 431 std::list< synchronisableVariable *>::iterator i;350 std::list<SynchronisableVariableBase *>::iterator i; 432 351 //assert(objectMode_!=0x0); 433 352 //assert( (mode ^ objectMode_) != 0); 434 if(syncList ->empty()){353 if(syncList.empty()){ 435 354 COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl; 436 355 return false; 437 356 } 438 357 439 uint8_t *data=mem;358 uint8_t* data=mem; 440 359 // start extract header 441 360 synchronisableHeader *syncHeader = (synchronisableHeader *)mem; … … 452 371 453 372 COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl; 454 for(i=syncList->begin(); i!=syncList->end() && mem <= data+syncHeader->size; i++){ 455 if( ((*i)->mode ^ mode) == 0 ){ 456 COUT(5) << "synchronisable: not updating variable " << std::endl; 457 // if we have a forcecallback then do the callback 458 continue; // this variable should only be set 459 } 460 COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl; 461 bool callback=false; 462 bool master=false; 463 464 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 465 { 466 uint8_t refNr = *(uint8_t *)mem; 467 if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \ 468 ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) ) 469 { // MASTER 470 master=true; 471 if( refNr != (*i)->varReference || ( memcmp((*i)->var, (*i)->varBuffer, (*i)->size) != 0 ) ) 472 { // DISCARD data 473 if( (*i)->type == DATA ) 474 { 475 mem += sizeof((*i)->varReference) + (*i)->size; 476 } 477 else //STRING 478 { 479 mem += sizeof(size_t) + *(size_t *)mem; 480 } 481 if( forceCallback && (*i)->callback) 482 (*i)->callback->call(); 483 continue; 484 }//otherwise everything is ok and we update the value 485 } 486 else // SLAVE 487 { 488 if( (*i)->varReference == refNr ){ 489 //discard data because it's outdated or not different to what we've got 490 if( (*i)->type == DATA ) 491 { 492 mem += sizeof((*i)->varReference) + (*i)->size; 493 } 494 else //STRING 495 { 496 mem += sizeof(size_t) + *(size_t *)mem; 497 } 498 if( forceCallback && (*i)->callback) 499 (*i)->callback->call(); 500 continue; 501 } 502 else 503 (*i)->varReference = refNr; //copy the reference value for this variable 504 } 505 mem += sizeof((*i)->varReference); 506 } 507 508 switch((*i)->type){ 509 case DATA: 510 if((*i)->callback) // check whether this variable changed (but only if callback was set) 511 { 512 if(memcmp((*i)->var, mem, (*i)->size) != 0) 513 callback=true; 514 } 515 if( master ) 516 { 517 if( callback || memcmp((*i)->var, mem, (*i)->size) != 0 ) 518 //value changed, so set the buffer to the new value 519 memcpy((*i)->varBuffer, mem, (*i)->size); 520 } 521 memcpy((*i)->var, mem, (*i)->size); 522 mem += (*i)->size; 523 break; 524 case STRING: 525 (*i)->size = *(size_t *)mem; 526 mem += sizeof(size_t); 527 528 if( (*i)->callback) // check whether this string changed 529 if( *static_cast<std::string*>((*i)->var) != std::string((char *)mem) ) 530 callback=true; 531 if( master ) 532 { 533 if( callback || *static_cast<std::string*>((*i)->var) != std::string((char *)mem) ) 534 //string changed. set the buffer to the new one 535 *static_cast<std::string*>((*i)->varBuffer)=*static_cast<std::string*>( (void*)(mem+sizeof(size_t)) ); 536 } 537 538 *((std::string *)((*i)->var)) = std::string((const char*)mem); 539 COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl; 540 mem += (*i)->size; 541 break; 542 } 543 // call the callback function, if defined 544 if((callback || forceCallback) && (*i)->callback) 545 (*i)->callback->call(); 373 for(i=syncList.begin(); i!=syncList.end() && mem <= data+syncHeader->size; i++) 374 { 375 (*i)->putData( mem, mode, forceCallback ); 546 376 } 547 377 assert(mem == data+syncHeader->size); … … 561 391 if(!doSync(id, mode)) 562 392 return 0; 563 std::list<synchronisableVariable *>::iterator i; 564 for(i=syncList->begin(); i!=syncList->end(); i++){ 565 if( ((*i)->mode & mode) == 0 ) 566 continue; // this variable should only be received, so dont add its size to the send-size 567 switch((*i)->type){ 568 case DATA: 569 tsize+=(*i)->size; 570 break; 571 case STRING: 572 tsize+=sizeof(int); 573 (*i)->size=((std::string *)(*i)->var)->length()+1; 574 COUT(5) << "String size: " << (*i)->size << std::endl; 575 tsize+=(*i)->size; 576 break; 577 } 578 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 579 { 580 tsize+=sizeof( (*i)->varReference ); 581 } 393 std::list<SynchronisableVariableBase*>::iterator i; 394 for(i=syncList.begin(); i!=syncList.end(); i++){ 395 tsize += (*i)->getSize( mode ); 582 396 } 583 397 return tsize; … … 592 406 if(mode==0x0) 593 407 mode=state_; 594 return ( (objectMode_&mode)!=0 && (!syncList ->empty() ) );408 return ( (objectMode_&mode)!=0 && (!syncList.empty() ) ); 595 409 } 596 410 … … 623 437 objectMode_=mode; 624 438 } 625 439 626 440 627 441 } -
code/branches/network64/src/network/synchronisable/Synchronisable.h
r2211 r2245 35 35 #include <map> 36 36 #include <queue> 37 #include "util/Integers.h" 37 #include <cassert> 38 #include "util/Math.h" 39 #include "util/mbool.h" 38 40 #include "core/OrxonoxClass.h" 39 #include "core/XMLIncludes.h" 41 // TODO: this has to be removed 42 // #include <OgreLight.h> 43 // #include "OrxonoxPrereqs.h" 44 // ============================ 40 45 #include "NetworkCallback.h" 41 #include " util/Integers.h"46 #include "SynchronisableVariable.h" 42 47 43 #define REGISTERDATA(varname, ...) \48 /*#define REGISTERDATA(varname, ...) \ 44 49 registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__) 45 50 #define REGISTERSTRING(stringname, ...) \ 46 registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__) 51 registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/ 47 52 48 53 namespace orxonox … … 50 55 static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1; 51 56 52 namespace direction{53 enum syncdirection{57 namespace objectDirection{ 58 enum objectdirection{ 54 59 toclient=0x1, 55 60 toserver=0x2, 56 bidirectional=0x3, 57 serverMaster=0x3, 58 clientMaster=0x7 61 bidirectional=0x3 59 62 }; 60 63 } 61 62 namespace syncmode{63 enum mode{64 once=0,65 always=166 };67 }68 69 enum variableType{70 DATA,71 STRING,72 };73 64 74 65 struct _NetworkExport synchronisableHeader{ … … 80 71 }; 81 72 82 struct _NetworkExport synchronisableVariable{83 size_t size;84 uint8_t mode; // this determines in which direction the variable gets synchronised85 void *var;86 variableType type;87 NetworkCallbackBase *callback;88 void *varBuffer;89 uint8_t varReference;90 };91 73 92 74 /** … … 101 83 virtual ~Synchronisable(); 102 84 103 104 virtual bool create();105 85 static void setClient(bool b); 106 86 … … 115 95 protected: 116 96 Synchronisable(BaseObject* creator); 117 void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0); 118 void unregisterVariable(void *var); 97 // void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0); 98 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 99 template <class T> void unregisterVariable(T& var); 119 100 void setObjectMode(uint8_t mode); 120 101 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; } … … 133 114 unsigned int classID; 134 115 135 std::list< synchronisableVariable *> *syncList;116 std::list<SynchronisableVariableBase*> syncList; 136 117 static uint8_t state_; // detemines wheter we are server (default) or client 137 118 bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) … … 141 122 static std::queue<unsigned int> deletedObjects_; 142 123 }; 124 125 template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 126 { 127 if (bidirectional) 128 syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb)); 129 else 130 syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb)); 131 } 132 133 template <class T> void Synchronisable::unregisterVariable(T& var){ 134 std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); 135 while(it!=syncList.end()){ 136 if( ((*it)->getReference()) == &var ){ 137 delete (*it); 138 syncList.erase(it); 139 return; 140 } 141 else 142 it++; 143 } 144 bool unregistered_nonexistent_variable = false; 145 assert(unregistered_nonexistent_variable); //if we reach this point something went wrong: 146 // the variable has not been registered before 147 } 148 149 // ================= Specialisation declarations 150 template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 151 template <> void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 152 template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 153 template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 154 template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 155 template <> void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 156 template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 157 template <> void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 158 template <> void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 159 template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 160 template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 161 // template <> void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 162 // template <> void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 143 163 } 144 164 -
code/branches/network64/src/orxonox/OrxonoxStableHeaders.h
r2211 r2245 1 /*2 * ORXONOX - the hottest 3D action shooter ever to exist3 * > www.orxonox.net <4 *5 *6 * License notice:7 *8 * This program is free software; you can redistribute it and/or9 * modify it under the terms of the GNU General Public License10 * as published by the Free Software Foundation; either version 211 * of the License, or (at your option) any later version.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU General Public License for more details.17 *18 * You should have received a copy of the GNU General Public License19 * along with this program; if not, write to the Free Software20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.21 *22 * Author:23 * Reto Grieder24 * Co-authors:25 * ...26 *27 */28 29 /**30 @file31 @brief Contains the frequently used header files of our own writing32 */33 34 #ifndef _OrxonoxStableHeaders_H__35 #define _OrxonoxStableHeaders_H__36 37 #include "util/OrxonoxPlatform.h"38 39 #if defined(ORXONOX_ENABLE_PCH)40 41 // including std headers here is useless since they're already precompiled42 43 #ifndef WIN32_LEAN_AND_MEAN44 // prevent Ogre from including winsock.h that messes with winsock2.h from enet45 # define WIN32_LEAN_AND_MEAN46 #endif47 #include <Ogre.h>48 #include <CEGUI.h>49 #include "ois/OIS.h"50 #include <boost/thread/recursive_mutex.hpp>51 //#include <boost/thread/mutex.hpp>52 //#include <boost/thread/condition.hpp>53 //#include <boost/thread/thread.hpp>54 #include <boost/static_assert.hpp>55 #include "tinyxml/ticpp.h"56 #include "tinyxml/tinyxml.h"57 #include "tolua/tolua++.h"58 59 //Get around Windows hackery (windows.h is included by Ogre.h)60 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN3261 # ifdef max62 # undef max63 # endif64 # ifdef min65 # undef min66 # endif67 #endif68 69 //----------- Our files ----------70 //--------------------------------71 //// only include when not debugging so that we may find issues with missing headers quicker72 //#if defined(NDEBUG)73 74 #include "util/Convert.h"75 #include "util/Debug.h"76 #include "util/Exception.h"77 #include "util/Math.h"78 #include "util/Multitype.h"79 #include "util/Sleep.h"80 #include "util/String.h"81 #include "util/SubString.h"82 83 #include "core/BaseObject.h"84 #include "core/ConsoleCommand.h"85 #include "core/CoreIncludes.h"86 #include "core/ConfigValueIncludes.h"87 #include "core/CommandExecutor.h"88 #include "core/Core.h"89 #include "core/Executor.h"90 #include "core/ObjectList.h"91 #include "core/Super.h"92 #include "core/XMLIncludes.h"93 #include "core/XMLPort.h"94 #include "core/input/SimpleInputState.h"95 #include "core/input/InputManager.h"96 97 #include "network/synchronisable/Synchronisable.h"98 99 #include "Settings.h"100 101 //#endif /* ifdef NDEBUG */102 103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */104 105 #endif /* _OrxonoxStableHeaders_H__ */ -
code/branches/network64/src/orxonox/objects/Level.cc
r2171 r2245 83 83 void Level::registerVariables() 84 84 { 85 REGISTERSTRING(this->xmlfilename_, direction::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));86 REGISTERSTRING(this->name_, direction::toclient, new NetworkCallback<Level>(this, &Level::changedName));87 REGISTERSTRING(this->description_, direction::toclient);85 registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile)); 86 registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName)); 87 registerVariable(this->description_, variableDirection::toclient); 88 88 } 89 89 -
code/branches/network64/src/orxonox/objects/Scene.cc
r2171 r2245 114 114 void Scene::registerVariables() 115 115 { 116 REGISTERSTRING(this->skybox_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));117 REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));116 registerVariable(this->skybox_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox)); 117 registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight)); 118 118 } 119 119 -
code/branches/network64/src/orxonox/objects/Test.cc
r2171 r2245 70 70 void Test::registerVariables() 71 71 { 72 REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ));73 REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ));74 REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ));75 REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ));72 registerVariable ( v1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 )); 73 registerVariable ( v2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 )); 74 registerVariable ( v3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ), true ); 75 registerVariable ( v4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ), true ); 76 76 } 77 77 -
code/branches/network64/src/orxonox/objects/Test.h
r2211 r2245 55 55 void checkV4(); 56 56 57 void printV1(){ instance_->checkV1(); }58 void printV2(){ instance_->checkV2(); }59 void printV3(){ instance_->checkV3(); }60 void printV4(){ instance_->checkV4(); }57 static void printV1(){ instance_->checkV1(); } 58 static void printV2(){ instance_->checkV2(); } 59 static void printV3(){ instance_->checkV3(); } 60 static void printV4(){ instance_->checkV4(); } 61 61 62 62 private: -
code/branches/network64/src/orxonox/objects/infos/HumanPlayer.cc
r2171 r2245 67 67 void HumanPlayer::registerVariables() 68 68 { 69 REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));69 registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick)); 70 70 71 REGISTERDATA(this->clientID_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));72 REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));73 REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));71 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged)); 72 registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized)); 73 registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized)); 74 74 } 75 75 … … 99 99 100 100 if (!Core::isMaster()) 101 this->setObjectMode( direction::bidirectional);101 this->setObjectMode(objectDirection::bidirectional); 102 102 else 103 103 this->setName(this->nick_); -
code/branches/network64/src/orxonox/objects/infos/PlayerInfo.cc
r2171 r2245 69 69 void PlayerInfo::registerVariables() 70 70 { 71 REGISTERSTRING(this->name_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));72 REGISTERDATA (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));73 REGISTERDATA (this->bReadyToSpawn_, direction::toserver);71 registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 72 registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 73 registerVariable(this->bReadyToSpawn_, variableDirection::toserver); 74 74 } 75 75 -
code/branches/network64/src/orxonox/objects/worldentities/Billboard.cc
r2171 r2245 64 64 void Billboard::registerVariables() 65 65 { 66 REGISTERSTRING(this->material_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));67 REGISTERDATA (this->colour_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));66 registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial)); 67 registerVariable(this->colour_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour)); 68 68 } 69 69 -
code/branches/network64/src/orxonox/objects/worldentities/ControllableEntity.cc
r2171 r2245 165 165 this->client_overwrite_ = this->server_overwrite_; 166 166 COUT(0) << "CE: bidirectional synchronization" << std::endl; 167 this->setObjectMode( direction::bidirectional);167 this->setObjectMode(objectDirection::bidirectional); 168 168 } 169 169 } … … 178 178 this->playerID_ = OBJECTID_UNKNOWN; 179 179 this->bControlled_ = false; 180 this->setObjectMode( direction::toclient);180 this->setObjectMode(objectDirection::toclient); 181 181 182 182 if (this->bDestroyWhenPlayerLeft_) … … 248 248 void ControllableEntity::registerVariables() 249 249 { 250 REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);251 252 REGISTERDATA(this->client_overwrite_, direction::toserver);253 254 REGISTERDATA(this->server_position_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));255 REGISTERDATA(this->server_velocity_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));256 REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));257 REGISTERDATA(this->server_overwrite_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));258 259 REGISTERDATA(this->client_position_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));260 REGISTERDATA(this->client_velocity_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));261 REGISTERDATA(this->client_orientation_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));262 263 264 REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));250 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 251 252 registerVariable(this->client_overwrite_, variableDirection::toserver); 253 254 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 255 registerVariable(this->server_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity)); 256 registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 257 registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 258 259 registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 260 registerVariable(this->client_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity)); 261 registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 262 263 264 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 265 265 } 266 266 -
code/branches/network64/src/orxonox/objects/worldentities/Light.cc
r2171 r2245 79 79 void Light::registerVariables() 80 80 { 81 REGISTERDATA(this->type_, direction::toclient, new NetworkCallback<Light>(this, &Light::changedType));82 REGISTERDATA(this->light_->getDiffuseColour(), direction::toclient);83 REGISTERDATA(this->light_->getSpecularColour(), direction::toclient);84 REGISTERDATA(this->light_->getDirection(), direction::toclient);81 registerVariable((int &)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::changedType)); 82 registerVariable(this->light_->getDiffuseColour(), variableDirection::toclient); 83 registerVariable(this->light_->getSpecularColour(), variableDirection::toclient); 84 registerVariable(this->light_->getDirection(), variableDirection::toclient); 85 85 } 86 86 -
code/branches/network64/src/orxonox/objects/worldentities/Model.cc
r2171 r2245 61 61 void Model::registerVariables() 62 62 { 63 REGISTERSTRING(this->meshSrc_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));64 REGISTERDATA(this->bCastShadows_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));63 registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh)); 64 registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows)); 65 65 } 66 66 -
code/branches/network64/src/orxonox/objects/worldentities/MovableEntity.cc
r2171 r2245 84 84 void MovableEntity::registerVariables() 85 85 { 86 REGISTERDATA(this->velocity_.x, direction::toclient);87 REGISTERDATA(this->velocity_.y, direction::toclient);88 REGISTERDATA(this->velocity_.z, direction::toclient);89 90 REGISTERDATA(this->rotationAxis_.x, direction::toclient);91 REGISTERDATA(this->rotationAxis_.y, direction::toclient);92 REGISTERDATA(this->rotationAxis_.z, direction::toclient);93 94 REGISTERDATA(this->rotationRate_, direction::toclient);95 96 REGISTERDATA(this->overwrite_position_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));97 REGISTERDATA(this->overwrite_orientation_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));86 registerVariable(this->velocity_.x, variableDirection::toclient); 87 registerVariable(this->velocity_.y, variableDirection::toclient); 88 registerVariable(this->velocity_.z, variableDirection::toclient); 89 90 registerVariable(this->rotationAxis_.x, variableDirection::toclient); 91 registerVariable(this->rotationAxis_.y, variableDirection::toclient); 92 registerVariable(this->rotationAxis_.z, variableDirection::toclient); 93 94 registerVariable(this->rotationRate_, variableDirection::toclient); 95 96 registerVariable(this->overwrite_position_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition)); 97 registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation)); 98 98 } 99 99 -
code/branches/network64/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2171 r2245 75 75 void ParticleEmitter::registerVariables() 76 76 { 77 REGISTERSTRING(this->source_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));78 REGISTERDATA (this->LOD_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));77 registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged)); 78 registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged)); 79 79 } 80 80 -
code/branches/network64/src/orxonox/objects/worldentities/PositionableEntity.cc
r2171 r2245 48 48 void PositionableEntity::registerVariables() 49 49 { 50 REGISTERDATA(this->getPosition().x, direction::toclient);51 REGISTERDATA(this->getPosition().y, direction::toclient);52 REGISTERDATA(this->getPosition().z, direction::toclient);50 registerVariable(this->getPosition().x, variableDirection::toclient); 51 registerVariable(this->getPosition().y, variableDirection::toclient); 52 registerVariable(this->getPosition().z, variableDirection::toclient); 53 53 54 REGISTERDATA(this->getOrientation().w, direction::toclient);55 REGISTERDATA(this->getOrientation().x, direction::toclient);56 REGISTERDATA(this->getOrientation().y, direction::toclient);57 REGISTERDATA(this->getOrientation().z, direction::toclient);54 registerVariable(this->getOrientation().w, variableDirection::toclient); 55 registerVariable(this->getOrientation().x, variableDirection::toclient); 56 registerVariable(this->getOrientation().y, variableDirection::toclient); 57 registerVariable(this->getOrientation().z, variableDirection::toclient); 58 58 } 59 59 } -
code/branches/network64/src/orxonox/objects/worldentities/WorldEntity.cc
r2171 r2245 96 96 void WorldEntity::registerVariables() 97 97 { 98 REGISTERDATA(this->bActive_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));99 REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));100 101 REGISTERDATA(this->getScale3D().x, direction::toclient);102 REGISTERDATA(this->getScale3D().y, direction::toclient);103 REGISTERDATA(this->getScale3D().z, direction::toclient);104 105 REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));98 registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 99 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); 100 101 registerVariable(this->getScale3D().x, variableDirection::toclient); 102 registerVariable(this->getScale3D().y, variableDirection::toclient); 103 registerVariable(this->getScale3D().z, variableDirection::toclient); 104 105 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent)); 106 106 } 107 107 -
code/branches/network64/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2171 r2245 80 80 void Pawn::registerVariables() 81 81 { 82 REGISTERDATA(this->bAlive_, direction::toclient);83 REGISTERDATA(this->health_, direction::toclient);82 registerVariable(this->bAlive_, variableDirection::toclient); 83 registerVariable(this->health_, variableDirection::toclient); 84 84 } 85 85 -
code/branches/network64/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2171 r2245 82 82 void SpaceShip::registerVariables() 83 83 { 84 REGISTERDATA(this->maxSpeed_, direction::toclient);85 REGISTERDATA(this->maxSecondarySpeed_, direction::toclient);86 REGISTERDATA(this->maxRotation_, direction::toclient);87 REGISTERDATA(this->translationAcceleration_, direction::toclient);88 REGISTERDATA(this->rotationAcceleration_, direction::toclient);89 REGISTERDATA(this->translationDamping_, direction::toclient);84 registerVariable(this->maxSpeed_, variableDirection::toclient); 85 registerVariable(this->maxSecondarySpeed_, variableDirection::toclient); 86 registerVariable(this->maxRotation_, variableDirection::toclient); 87 registerVariable(this->translationAcceleration_, variableDirection::toclient); 88 registerVariable(this->rotationAcceleration_, variableDirection::toclient); 89 registerVariable(this->translationDamping_, variableDirection::toclient); 90 90 } 91 91 -
code/branches/network64/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2171 r2245 86 86 void Spectator::registerVariables() 87 87 { 88 REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));89 REGISTERDATA(this->bGreeting_, direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));90 REGISTERDATA(this->hudmode_, direction::toclient);88 registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 89 registerVariable(this->bGreeting_, variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 90 registerVariable(this->hudmode_, variableDirection::toclient); 91 91 } 92 92 -
code/branches/network64/src/util/mbool.h
r2171 r2245 36 36 struct _UtilExport mbool 37 37 { 38 // friend Synchronisable::registerVariable<>() 38 39 public: 39 40 inline mbool(bool value = false) … … 67 68 inline bool operator!() const 68 69 { return (!this->value_.bool_); } 70 71 inline unsigned char& getMemory(){ return value_.memory_; } 69 72 70 73 private:
Note: See TracChangeset
for help on using the changeset viewer.