Changeset 7559 in orxonox.OLD for branches/network
- Timestamp:
- May 10, 2006, 12:11:43 AM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/synchronizeable.cc
r7512 r7559 89 89 /** 90 90 * get the diff to last acked state of userId 91 * 92 * each synchrinizeable defines its own stack of states received and sent over the network. The stack contains 93 * a per user entry for the last sent/received state This function returns a delta compressed state of the 94 * synchronizeable. This state will be transmitted over the network to the other participants 95 * 91 96 * @param userId user to create diff for 92 97 * @param data buffer to copy diff in 93 98 * @param maxLength max bytes to copy into data 94 99 * @param stateId id of current state 100 * @param fromStateId the reference state for the delta state 95 101 * @param priorityTH tells getStateDiff to not send element with priority \< priorityTH 96 102 * @return n bytes copied into data … … 115 121 while ( it != sentStates[userId].end() && (*it)->stateId < fromStateId ) 116 122 it++; 117 118 if ( it != sentStates[userId]. begin() )123 ///FIXED: altered begin() -> end() 124 if ( it != sentStates[userId].end() ) 119 125 { 120 126 for ( StateHistory::iterator it2 = sentStates[userId].begin(); it2 != it; it2++ ) … … 160 166 int n; 161 167 168 // now do the actual synchronization: kick all variables to write into a common buffer 162 169 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 163 170 { -
branches/network/src/lib/network/synchronizeable.h
r7508 r7559 58 58 void setIsServer( bool isServer ); 59 59 bool isServer(); 60 60 61 61 virtual void varChangeHandler( std::list<int> & id ); 62 62 63 63 int getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH ); 64 64 bool setStateDiff( int userId, byte* data, int length, int stateId, int fromStateId ); 65 65 66 66 void registerVar( SynchronizeableVar * var ); 67 67 int registerVarId( SynchronizeableVar * var ); 68 68 69 69 inline void setUniqueID( int id ){ uniqueID = id; } 70 70 inline int getUniqueID() const { return uniqueID; } … … 74 74 inline void setOwner(int owner){ this->owner = owner; } 75 75 76 /** @returns true if this Synchronizeable has to be synchronized over network */76 /** @returns true if this Synchronizeable wants to be synchronized over network */ 77 77 inline bool beSynchronized() { return this->bSynchronize; } 78 78 /** @param bSynchronize sets the Synchronizeable to be sunchronized or not */ … … 92 92 int hostID; //!< my own host id 93 93 bool bSynchronize; //!< do we need beeing synchronized? 94 94 95 95 SyncVarList syncVarList; //!< list containing variables to synchronize 96 97 UserStateHistory sentStates; //!< store already sent states to create diffs from 98 UserStateHistory recvStates; //!< store recieved states to apply diffs 96 97 UserStateHistory sentStates; //!< store already sent states to create diffs from, offset corresponds to the user id 98 UserStateHistory recvStates; //!< store recieved states to apply diffs, offset corresponds to the user id 99 99 100 100 }; -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc
r7459 r7559 46 46 int n = 0; 47 47 int res; 48 49 res = Converter::floatToByteArray( vPtrIn->v.x, buf , maxLength - n );48 49 res = Converter::floatToByteArray( vPtrIn->v.x, buf + n, maxLength - n ); 50 50 assert( res > 0 ); 51 51 n += res; 52 53 res = Converter::floatToByteArray( vPtrIn->v.y, buf , maxLength - n );52 53 res = Converter::floatToByteArray( vPtrIn->v.y, buf + n, maxLength - n ); 54 54 assert( res > 0 ); 55 55 n += res; 56 57 res = Converter::floatToByteArray( vPtrIn->v.z, buf , maxLength - n );56 57 res = Converter::floatToByteArray( vPtrIn->v.z, buf + n, maxLength - n ); 58 58 assert( res > 0 ); 59 59 n += res; 60 61 res = Converter::floatToByteArray( vPtrIn->w, buf , maxLength - n );60 61 res = Converter::floatToByteArray( vPtrIn->w, buf + n, maxLength - n ); 62 62 assert( res > 0 ); 63 63 n += res; 64 64 65 65 assert( 4*FLOATSIZE == n ); 66 66 67 67 return n; 68 68 } … … 77 77 { 78 78 assert( maxLength >= 4*FLOATSIZE ); 79 79 80 80 float x,y,z,w; 81 81 82 82 int res; 83 83 int n = 0; 84 84 85 85 res += Converter::byteArrayToFloat( buf + n, &x ); 86 86 assert( res > 0 ); 87 87 n += res; 88 88 89 89 res += Converter::byteArrayToFloat( buf + n, &x ); 90 90 assert( res > 0 ); 91 91 n += res; 92 92 93 93 res += Converter::byteArrayToFloat( buf + n, &x ); 94 94 assert( res > 0 ); 95 95 n += res; 96 96 97 97 res += Converter::byteArrayToFloat( buf + n, &w ); 98 98 assert( res > 0 ); 99 99 n += res; 100 100 101 101 *vPtrOut = Quaternion( Vector(x, y, z), w ); 102 102 103 103 assert( res == 4*FLOATSIZE ); 104 104 return res; -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc
r7459 r7559 18 18 19 19 20 20 21 /** 21 22 * standard constructor … … 26 27 assert( ptrIn ); 27 28 assert( ptrOut ); 28 29 29 30 this->ptrIn = ptrIn; 30 31 this->ptrOut = ptrOut; … … 32 33 this->permission = permission; 33 34 this->priority = priority; 34 this->real _priority = priority;35 this->realPriority = priority; 35 36 this->name = name; 36 37 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h
r7508 r7559 9 9 #include <string> 10 10 #include "netdefs.h" 11 #include <assert.h> 11 12 12 13 class SynchronizeableVar { … … 15 16 SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 ); 16 17 virtual ~SynchronizeableVar(); 17 18 18 19 /** 19 20 * check if synchronizeable wants to be informed on changes … … 21 22 */ 22 23 inline bool beWatched(){ return this->bWatched; } 23 24 24 25 /** 25 26 * write var data to byte buffer … … 29 30 */ 30 31 virtual int writeToBuf( byte * buf, int maxLength ) = 0; 31 32 32 33 /** 33 34 * read var data from byte buffer … … 37 38 */ 38 39 virtual int readFromBuf( byte * buf, int maxLength ) = 0; 39 40 40 41 /** 41 42 * check if writeToBuf will return the same size every time … … 43 44 */ 44 45 virtual bool hasStaticSize() = 0; 45 46 46 47 /** 47 48 * get size writeToBuf needs … … 49 50 */ 50 51 virtual int getSize(){ return length; } 51 52 52 53 /** 53 54 * check for permission to write … … 55 56 */ 56 57 inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; } 57 58 58 59 /** 59 60 * get variable name … … 61 62 */ 62 63 inline std::string getName(){ return name; } 63 64 64 65 /** 65 66 * set variable name … … 67 68 */ 68 69 inline void setName( std::string name ) { this->name = name; } 69 70 70 71 /** 71 72 * get priority … … 73 74 */ 74 75 inline int getPriority() { return this->priority; } 75 76 76 77 /** 77 78 * set priority … … 79 80 */ 80 81 inline void setPriority( int p ) { this->priority = p; } 81 82 82 83 /** 83 84 * reset priority to variable specific default value 84 85 */ 85 inline void resetPriority() { this->priority = this->real _priority; }86 inline void resetPriority() { this->priority = this->realPriority; } 86 87 87 88 … … 95 96 int permission; //!< who is allowed to change this var 96 97 int priority; //!< priority assigned to var 97 int real _priority; //!< priority assigned to var, increased every time not sent98 99 98 int realPriority; //!< priority assigned to var, increased every time not sent 99 100 100 101 std::string name; //!< variable name (for debugging) 101 102 -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc
r7459 r7559 47 47 int n = 0; 48 48 int res; 49 50 res = Converter::floatToByteArray( vPtrIn->x, buf , maxLength - n );49 50 res = Converter::floatToByteArray( vPtrIn->x, buf + n, maxLength - n ); 51 51 assert( res > 0 ); 52 52 n += res; 53 54 res = Converter::floatToByteArray( vPtrIn->y, buf , maxLength - n );53 54 res = Converter::floatToByteArray( vPtrIn->y, buf + n, maxLength - n ); 55 55 assert( res > 0 ); 56 56 n += res; 57 58 res = Converter::floatToByteArray( vPtrIn->z, buf , maxLength - n );57 58 res = Converter::floatToByteArray( vPtrIn->z, buf + n, maxLength - n ); 59 59 assert( res > 0 ); 60 60 n += res; 61 61 62 62 assert( 3*FLOATSIZE == n ); 63 63 64 64 return n; 65 65 } … … 74 74 { 75 75 assert( maxLength >= 3*FLOATSIZE ); 76 76 77 77 float x,y,z; 78 78 79 79 int res; 80 80 int n = 0; 81 81 82 82 res += Converter::byteArrayToFloat( buf + n, &x ); 83 83 assert( res > 0 ); 84 84 n += res; 85 85 86 86 res += Converter::byteArrayToFloat( buf + n, &x ); 87 87 assert( res > 0 ); 88 88 n += res; 89 89 90 90 res += Converter::byteArrayToFloat( buf + n, &x ); 91 91 assert( res > 0 ); 92 92 n += res; 93 93 94 94 *vPtrOut = Vector( x, y, z ); 95 95 96 96 assert( res == 3*FLOATSIZE ); 97 97 return res;
Note: See TracChangeset
for help on using the changeset viewer.