Changeset 2309
- Timestamp:
- Dec 2, 2008, 9:10:00 PM (16 years ago)
- Location:
- code/branches/network64/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network64/src/core/CoreIncludes.h
r2171 r2309 48 48 #include "Functor.h" 49 49 #include "util/Debug.h" 50 #include "util/Integers.h" 50 51 51 52 -
code/branches/network64/src/core/Factory.cc
r2171 r2309 58 58 @return The Identifier 59 59 */ 60 Identifier* Factory::getIdentifier(const u nsigned int id)60 Identifier* Factory::getIdentifier(const uint32_t id) 61 61 { 62 std::map<u nsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);62 std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id); 63 63 if (it != getFactoryPointer()->identifierNetworkIDMap_.end()) 64 64 return it->second; … … 85 85 @param newID The new networkID 86 86 */ 87 void Factory::changeNetworkID(Identifier* identifier, const u nsigned int oldID, const unsigned int newID)87 void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID) 88 88 { 89 89 getFactoryPointer()->identifierNetworkIDMap_.erase(oldID); -
code/branches/network64/src/core/Factory.h
r2171 r2309 49 49 #include <map> 50 50 #include <string> 51 #include "util/Integers.h" 51 52 52 53 namespace orxonox … … 60 61 public: 61 62 static Identifier* getIdentifier(const std::string& name); 62 static Identifier* getIdentifier(const u nsigned int id);63 static Identifier* getIdentifier(const uint32_t id); 63 64 static void add(const std::string& name, Identifier* identifier); 64 static void changeNetworkID(Identifier* identifier, const u nsigned int oldID, const unsigned int newID);65 static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID); 65 66 static void createClassHierarchy(); 66 67 … … 83 84 84 85 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 85 std::map<u nsigned int, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier86 std::map<uint32_t, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier 86 87 }; 87 88 -
code/branches/network64/src/core/Identifier.cc
r2171 r2309 235 235 @param id The new network ID 236 236 */ 237 void Identifier::setNetworkID(u nsigned int id)237 void Identifier::setNetworkID(uint32_t id) 238 238 { 239 239 Factory::changeNetworkID(this, this->classID_, id); -
code/branches/network64/src/core/Identifier.h
r2171 r2309 230 230 231 231 /** @brief Returns the network ID to identify a class through the network. @return the network ID */ 232 inline const u nsigned int getNetworkID() const { return this->classID_; }232 inline const uint32_t getNetworkID() const { return this->classID_; } 233 233 234 234 /** @brief Sets the network ID to a new value. @param id The new value */ 235 void setNetworkID(u nsigned int id);235 void setNetworkID(uint32_t id); 236 236 237 237 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); … … 315 315 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 316 316 static int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 317 u nsigned int classID_;//!< The network ID to identify a class through the network317 uint32_t classID_; //!< The network ID to identify a class through the network 318 318 319 319 bool bHasConfigValues_; //!< True if this class has at least one assigned config value -
code/branches/network64/src/network/GamestateClient.cc
r2211 r2309 36 36 #include "core/Iterator.h" 37 37 #include "synchronisable/Synchronisable.h" 38 #include "synchronisable/NetworkCallbackManager.h" 38 39 #include "packet/Acknowledgement.h" 39 40 … … 77 78 packet::Gamestate *processed = processGamestate(tempGamestate_); 78 79 // assert(processed); 80 81 //now call the queued callbacks 82 NetworkCallbackManager::callCallbacks(); 83 79 84 if (!processed) 80 85 return false; -
code/branches/network64/src/network/GamestateManager.cc
r2211 r2309 50 50 #include "ClientInformation.h" 51 51 #include "synchronisable/Synchronisable.h" 52 #include "synchronisable/NetworkCallbackManager.h" 52 53 53 54 namespace orxonox … … 86 87 // now clear the queue 87 88 gamestateQueue.clear(); 89 //and call all queued callbacks 90 NetworkCallbackManager::callCallbacks(); 88 91 return true; 89 92 } -
code/branches/network64/src/network/NetworkPrereqs.h
r2245 r2309 71 71 class GamestateHandler; 72 72 class NetworkCallbackBase; 73 template <class T> class NetworkCallback; 74 class NetworkCallbackManager; 73 75 class PacketBuffer; 74 76 class Server; -
code/branches/network64/src/network/packet/Gamestate.cc
r2171 r2309 73 73 bool Gamestate::collectData(int id, uint8_t mode) 74 74 { 75 u nsigned int tempsize=0, currentsize=0;75 uint32_t tempsize=0, currentsize=0; 76 76 assert(data_==0); 77 u nsigned int size = calcGamestateSize(id, mode);77 uint32_t size = calcGamestateSize(id, mode); 78 78 79 79 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; … … 166 166 } 167 167 168 u nsigned int Gamestate::getSize() const168 uint32_t Gamestate::getSize() const 169 169 { 170 170 assert(data_); … … 251 251 assert(HEADER->compressed); 252 252 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl; 253 u nsigned int datasize = HEADER->datasize;254 u nsigned int compsize = HEADER->compsize;255 u nsigned int bufsize;253 uint32_t datasize = HEADER->datasize; 254 uint32_t compsize = HEADER->compsize; 255 uint32_t bufsize; 256 256 // assert(compsize<=datasize); 257 257 bufsize = datasize; … … 302 302 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/; 303 303 uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_); 304 u nsigned int of=0; // pointers offset305 u nsigned int dest_length=0;304 uint32_t of=0; // pointers offset 305 uint32_t dest_length=0; 306 306 dest_length=HEADER->datasize; 307 307 if(dest_length==0) … … 334 334 Gamestate* Gamestate::doSelection(unsigned int clientID){ 335 335 assert(data_); 336 std::map<u nsigned int, Synchronisable *>::iterator it;336 std::map<uint32_t, Synchronisable *>::iterator it; 337 337 338 338 // allocate memory for new data … … 347 347 348 348 synchronisableHeader *oldobjectheader, *newobjectheader; 349 u nsigned int objectOffset;349 uint32_t objectOffset; 350 350 351 351 //copy in the zeros … … 353 353 oldobjectheader = (synchronisableHeader*)origdata; 354 354 newobjectheader = (synchronisableHeader*)newdata; 355 u nsigned int objectsize = oldobjectheader->size;355 uint32_t objectsize = oldobjectheader->size; 356 356 assert(it->second->objectID==oldobjectheader->objectID); 357 357 *newobjectheader = *oldobjectheader; … … 382 382 383 383 //preparations 384 std::map<u nsigned int, Synchronisable *>::iterator it;384 std::map<uint32_t, Synchronisable *>::iterator it; 385 385 uint8_t *origdata, *basedata, *destdata, *ndata; 386 u nsigned int objectOffset, streamOffset=0; //data offset387 u nsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;386 uint32_t objectOffset, streamOffset=0; //data offset 387 uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 388 388 synchronisableHeader *origheader; 389 389 synchronisableHeader *destheader; … … 402 402 403 403 //copy and partially diff the object header 404 assert(sizeof(synchronisableHeader)==3*sizeof(u nsigned int)+sizeof(bool));404 assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool)); 405 405 *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff) 406 406 *(bool*)(destdata+sizeof(uint32_t)) = sendData; … … 450 450 451 451 //preparations 452 std::map<u nsigned int, Synchronisable *>::iterator it;452 std::map<uint32_t, Synchronisable *>::iterator it; 453 453 uint8_t *origdata, *basedata, *destdata, *ndata; 454 u nsigned int objectOffset, streamOffset=0; //data offset455 u nsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;454 uint32_t objectOffset, streamOffset=0; //data offset 455 uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 456 456 synchronisableHeader *origheader; 457 457 synchronisableHeader *destheader; … … 470 470 471 471 //copy and partially diff the object header 472 assert(sizeof(synchronisableHeader)==3*sizeof(u nsigned int)+sizeof(bool));473 *(u nsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)474 *(bool*)(destdata+sizeof(u nsigned int)) = *(bool*)(origdata+sizeof(unsigned int));475 sendData = *(bool*)(origdata+sizeof(u nsigned int));472 assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool)); 473 *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff) 474 *(bool*)(destdata+sizeof(uint32_t)) = *(bool*)(origdata+sizeof(uint32_t)); 475 sendData = *(bool*)(origdata+sizeof(uint32_t)); 476 476 if(sendData){ 477 *(u nsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)478 *(u nsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)477 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it) 478 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it) 479 479 }else{ 480 *(u nsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;481 *(u nsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;480 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0; 481 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0; 482 482 } 483 483 objectOffset=sizeof(synchronisableHeader); … … 517 517 uint8_t *basep = GAMESTATE_START(base->data_); 518 518 uint8_t *gs = GAMESTATE_START(this->data_); 519 u nsigned int of=0; // pointers offset520 u nsigned int dest_length=0;519 uint32_t of=0; // pointers offset 520 uint32_t dest_length=0; 521 521 dest_length=HEADER->datasize; 522 522 if(dest_length==0) … … 548 548 549 549 550 u nsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)551 { 552 u nsigned int size=0;550 uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode) 551 { 552 uint32_t size=0; 553 553 // get the start of the Synchronisable list 554 554 ObjectList<Synchronisable>::iterator it; -
code/branches/network64/src/network/packet/Gamestate.h
r2211 r2309 85 85 // Packet functions 86 86 private: 87 virtual u nsigned int getSize() const;87 virtual uint32_t getSize() const; 88 88 virtual bool process(); 89 89 90 90 bool operator ==(packet::Gamestate gs); 91 91 private: 92 u nsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);92 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 93 93 void removeObject(ObjectListIterator<Synchronisable> &it); 94 std::map<u nsigned int, Synchronisable*> dataMap_;94 std::map<uint32_t, Synchronisable*> dataMap_; 95 95 }; 96 96 -
code/branches/network64/src/network/synchronisable/CMakeLists.txt
r2307 r2309 1 1 SET( SRC_FILES 2 NetworkCallbackManager.cc 2 3 Synchronisable.cc 3 4 SynchronisableSpecialisations.cc -
code/branches/network64/src/network/synchronisable/NetworkCallback.h
r2211 r2309 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * 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 of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Oliver Scheuss, (C) 2008 24 * Co-authors: 25 * ... 26 * 27 */ 28 29 1 30 #ifndef _NETWORK_CALLBACK__ 2 31 #define _NETWORK_CALLBACK__ 3 32 4 33 #include "network/NetworkPrereqs.h" 34 #include "NetworkCallbackManager.h" 5 35 6 36 namespace orxonox{ 37 7 38 class _NetworkExport NetworkCallbackBase 8 39 { 9 40 public: 10 41 virtual void call() = 0; 11 virtual ~NetworkCallbackBase() {} 42 NetworkCallbackBase(){ NetworkCallbackManager::registerCallback( this ); } 43 virtual ~NetworkCallbackBase() {} 12 44 }; 13 45 … … 26 58 }; 27 59 28 29 60 } 30 61 -
code/branches/network64/src/network/synchronisable/Synchronisable.cc
r2307 r2309 55 55 56 56 57 std::map<u nsigned int, Synchronisable *> Synchronisable::objectMap_;58 std::queue<u nsigned int> Synchronisable::deletedObjects_;57 std::map<uint32_t, Synchronisable *> Synchronisable::objectMap_; 58 std::queue<uint32_t> Synchronisable::deletedObjects_; 59 59 60 60 uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client … … 77 77 else 78 78 objectID=OBJECTID_UNKNOWN; 79 classID = (unsigned int)-1;79 classID = static_cast<uint32_t>(-1); 80 80 81 81 … … 122 122 // objectMap_.erase(objectID); 123 123 } 124 std::map<u nsigned int, Synchronisable*>::iterator it;124 std::map<uint32_t, Synchronisable*>::iterator it; 125 125 it = objectMap_.find(objectID); 126 126 if (it != objectMap_.end()) … … 199 199 * @return true/false 200 200 */ 201 bool Synchronisable::deleteObject(u nsigned int objectID){201 bool Synchronisable::deleteObject(uint32_t objectID){ 202 202 // assert(getSynchronisable(objectID)); 203 203 if(!getSynchronisable(objectID)) … … 218 218 * @return pointer to the Synchronisable with the objectID 219 219 */ 220 Synchronisable* Synchronisable::getSynchronisable(u nsigned int objectID){221 std::map<u nsigned int, Synchronisable*>::iterator it1;220 Synchronisable* Synchronisable::getSynchronisable(uint32_t objectID){ 221 std::map<uint32_t, Synchronisable*>::iterator it1; 222 222 it1 = objectMap_.find(objectID); 223 223 if (it1 != objectMap_.end()) … … 295 295 * @return true: if !doSync or if everything was successfully saved 296 296 */ 297 bool Synchronisable::getData(uint8_t*& mem, unsigned int id, uint8_t mode){297 bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){ 298 298 if(mode==0x0) 299 299 mode=state_; … … 302 302 return true; 303 303 //std::cout << "inside getData" << std::endl; 304 u nsigned int tempsize = 0;304 uint32_t tempsize = 0; 305 305 if(classID==0) 306 306 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; 307 307 308 if (this->classID == (unsigned int)-1)308 if (this->classID == static_cast<uint32_t>(-1)) 309 309 this->classID = this->getIdentifier()->getNetworkID(); 310 310 … … 312 312 // this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this 313 313 std::list<SynchronisableVariableBase*>::iterator i; 314 u nsigned int size;314 uint32_t size; 315 315 size=getSize(id, mode); 316 316 … … 384 384 * @return amount of bytes 385 385 */ 386 uint32_t Synchronisable::getSize( unsigned int id, uint8_t mode){386 uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){ 387 387 int tsize=sizeof(synchronisableHeader); 388 388 if(mode==0x0) … … 402 402 * @return true/false 403 403 */ 404 bool Synchronisable::doSync( unsigned int id, uint8_t mode){404 bool Synchronisable::doSync(int32_t id, uint8_t mode){ 405 405 if(mode==0x0) 406 406 mode=state_; … … 408 408 } 409 409 410 bool Synchronisable::doSelection( unsigned int id){410 bool Synchronisable::doSelection(int32_t id){ 411 411 return true; //TODO: change this 412 412 //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0); -
code/branches/network64/src/network/synchronisable/Synchronisable.h
r2307 r2309 53 53 namespace orxonox 54 54 { 55 static const u nsigned int OBJECTID_UNKNOWN = (unsigned int)-1;55 static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1); 56 56 57 57 namespace objectDirection{ … … 86 86 87 87 static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0); 88 static bool deleteObject(u nsigned int objectID);89 static Synchronisable *getSynchronisable(u nsigned int objectID);88 static bool deleteObject(uint32_t objectID); 89 static Synchronisable *getSynchronisable(uint32_t objectID); 90 90 static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); } 91 static u nsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }91 static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; } 92 92 93 inline u nsigned int getObjectID(){return objectID;}94 inline u nsigned int getClassID(){return classID;}93 inline uint32_t getObjectID(){return objectID;} 94 inline uint32_t getClassID(){return classID;} 95 95 protected: 96 96 Synchronisable(BaseObject* creator); … … 103 103 104 104 private: 105 bool getData(uint8_t*& men, unsigned int id, uint8_t mode=0x0);106 uint32_t getSize( unsigned int id, uint8_t mode=0x0);105 bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0); 106 uint32_t getSize(int32_t id, uint8_t mode=0x0); 107 107 bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false); 108 108 bool isMyData(uint8_t* mem); 109 bool doSelection( unsigned int id);110 bool doSync( unsigned int id, uint8_t mode=0x0);109 bool doSelection(int32_t id); 110 bool doSync(int32_t id, uint8_t mode=0x0); 111 111 112 u nsigned int objectID;113 u nsigned int creatorID;114 u nsigned int classID;112 uint32_t objectID; 113 uint32_t creatorID; 114 uint32_t classID; 115 115 116 116 std::list<SynchronisableVariableBase*> syncList; … … 119 119 unsigned int objectFrequency_; 120 120 int objectMode_; 121 static std::map<u nsigned int, Synchronisable *> objectMap_;122 static std::queue<u nsigned int> deletedObjects_;121 static std::map<uint32_t, Synchronisable *> objectMap_; 122 static std::queue<uint32_t> deletedObjects_; 123 123 }; 124 124 -
code/branches/network64/src/network/synchronisable/SynchronisableSpecialisations.cc
r2307 r2309 37 37 template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) 38 38 { 39 registerVariable(variable.r, mode, 0, bidirectional);40 registerVariable(variable.g, mode, 0, bidirectional);41 registerVariable(variable.b, mode, 0, bidirectional);39 registerVariable(variable.r, mode, cb, bidirectional); 40 registerVariable(variable.g, mode, cb, bidirectional); 41 registerVariable(variable.b, mode, cb, bidirectional); 42 42 registerVariable(variable.a, mode, cb, bidirectional); 43 43 } … … 49 49 template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) 50 50 { 51 registerVariable(variable.x, mode, 0, bidirectional);51 registerVariable(variable.x, mode, cb, bidirectional); 52 52 registerVariable(variable.y, mode, cb, bidirectional); 53 53 } … … 59 59 template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) 60 60 { 61 registerVariable(variable.x, mode, 0, bidirectional);62 registerVariable(variable.y, mode, 0, bidirectional);61 registerVariable(variable.x, mode, cb, bidirectional); 62 registerVariable(variable.y, mode, cb, bidirectional); 63 63 registerVariable(variable.z, mode, cb, bidirectional); 64 64 } … … 70 70 template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) 71 71 { 72 registerVariable(variable.x, mode, 0, bidirectional);73 registerVariable(variable.y, mode, 0, bidirectional);74 registerVariable(variable.z, mode, 0, bidirectional);72 registerVariable(variable.x, mode, cb, bidirectional); 73 registerVariable(variable.y, mode, cb, bidirectional); 74 registerVariable(variable.z, mode, cb, bidirectional); 75 75 registerVariable(variable.w, mode, cb, bidirectional); 76 76 } … … 87 87 template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) 88 88 { 89 registerVariable(variable.w, mode, 0, bidirectional); 90 registerVariable(variable.x, mode, 0, bidirectional); 91 registerVariable(variable.y, mode, 0, bidirectional); 89 registerVariable(variable.x, mode, cb, bidirectional); 90 registerVariable(variable.y, mode, cb, bidirectional); 92 91 registerVariable(variable.z, mode, cb, bidirectional); 92 registerVariable(variable.w, mode, cb, bidirectional); 93 93 } 94 94 template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional) -
code/branches/network64/src/network/synchronisable/SynchronisableVariable.cc
r2255 r2309 64 64 } 65 65 66 // =========== char 67 68 template <> uint32_t SynchronisableVariable<const char>::returnSize() 69 { 70 return sizeof(uint8_t); 71 } 72 73 template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem ) 74 { 75 *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem); 76 mem += SynchronisableVariable<const char>::returnSize(); 77 } 78 79 template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem ) 80 { 81 *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_); 82 mem += SynchronisableVariable<const char>::returnSize(); 83 } 84 85 template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem ) 86 { 87 return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_); 88 } 89 66 90 // =========== unsigned char 67 91 -
code/branches/network64/src/network/synchronisable/SynchronisableVariable.h
r2307 r2309 39 39 #include "core/CoreIncludes.h" 40 40 #include "network/synchronisable/NetworkCallback.h" 41 #include "network/synchronisable/NetworkCallbackManager.h" 41 42 42 43 namespace orxonox{ … … 119 120 { 120 121 if (this->callback_ != 0) 121 delete this->callback_;122 NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion 122 123 } 123 124 … … 146 147 // now do a callback if neccessary 147 148 if ( callback ) 148 this->callback_->call(); 149 NetworkCallbackManager::triggerCallback( this->callback_ ); 150 //this->callback_->call(); 149 151 } 150 152 … … 299 301 // now do a callback if neccessary 300 302 if ( callback ) 301 this->callback_->call(); 303 NetworkCallbackManager::triggerCallback( this->callback_ ); 304 //this->callback_->call(); 302 305 } 303 306 -
code/branches/network64/src/orxonox/objects/Test.cc
r2245 r2309 61 61 void Test::setConfigValues() 62 62 { 63 SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/; 64 SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/; 65 SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/; 66 SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/; 63 SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/; 64 SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/; 65 SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/; 66 SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/; 67 68 SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/; 69 SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/; 70 SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/; 71 SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/; 67 72 } 68 73 … … 70 75 void Test::registerVariables() 71 76 { 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 ); 77 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 )); 78 registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 )); 79 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true ); 80 registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true ); 81 82 registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 )); 83 registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 )); 84 registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true ); 85 registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true ); 76 86 } 77 87 78 void Test::checkV1(){ 79 COUT(1) << "V1 changed: " << v1 << std::endl; 80 } 88 void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; } 89 void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; } 90 void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; } 91 void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; } 81 92 82 void Test::checkV2(){ 83 COUT(1) << "V2 changed: " << v2 << std::endl; 84 } 85 86 void Test::checkV3(){ 87 COUT(1) << "V3 changed: " << v3 << std::endl; 88 } 89 90 void Test::checkV4(){ 91 COUT(1) << "V4 changed: " << v4 << std::endl; 92 } 93 93 void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; } 94 void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; } 95 void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; } 96 void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; } 94 97 95 98 } -
code/branches/network64/src/orxonox/objects/Test.h
r2245 r2309 34 34 #include "network/synchronisable/Synchronisable.h" 35 35 36 37 typedef int TYPE; 38 typedef unsigned int UTYPE; 39 40 36 41 namespace orxonox 37 42 { … … 45 50 void registerVariables(); 46 51 47 void setV1(unsigned int value){ v1 = value; }48 void setV2(unsigned int value){ v2 = value; }49 void setV3(unsigned int value){ v3 = value; }50 void setV4(unsigned int value){ v4 = value; }51 52 52 void checkV1(); 53 void checkV2(); 54 void checkV3(); 55 void checkV4(); 53 //unsigned functions 54 void setU1(UTYPE value){ u1 = value; } 55 void setU2(UTYPE value){ u2 = value; } 56 void setU3(UTYPE value){ u3 = value; } 57 void setU4(UTYPE value){ u4 = value; } 58 void checkU1(); 59 void checkU2(); 60 void checkU3(); 61 void checkU4(); 56 62 57 static void printV1(){ instance_->checkV1(); } 58 static void printV2(){ instance_->checkV2(); } 59 static void printV3(){ instance_->checkV3(); } 60 static void printV4(){ instance_->checkV4(); } 63 //signed functions 64 void setS1(TYPE value){ s1 = value; } 65 void setS2(TYPE value){ s2 = value; } 66 void setS3(TYPE value){ s3 = value; } 67 void setS4(TYPE value){ s4 = value; } 68 void checkS1(); 69 void checkS2(); 70 void checkS3(); 71 void checkS4(); 72 73 static void printV1(){ instance_->checkU1(); } 74 static void printV2(){ instance_->checkU2(); } 75 static void printV3(){ instance_->checkU3(); } 76 static void printV4(){ instance_->checkU4(); } 61 77 62 78 private: 63 unsigned int v1; 64 unsigned int v2; 65 unsigned int v3; 66 unsigned int v4; 79 UTYPE u1; 80 UTYPE u2; 81 UTYPE u3; 82 UTYPE u4; 83 84 TYPE s1; 85 TYPE s2; 86 TYPE s3; 87 TYPE s4; 67 88 68 89 static Test* instance_;
Note: See TracChangeset
for help on using the changeset viewer.