[Orxonox-commit 149] r2832 - in branches/netp/src/network: packet synchronisable
scheusso at orxonox.net
scheusso at orxonox.net
Mon Mar 23 14:53:10 CET 2009
Author: scheusso
Date: 2009-03-23 13:53:10 +0000 (Mon, 23 Mar 2009)
New Revision: 2832
Modified:
branches/netp/src/network/packet/Gamestate.cc
branches/netp/src/network/synchronisable/Synchronisable.cc
branches/netp/src/network/synchronisable/Synchronisable.h
Log:
further improvements in network (eliminated double calls of Synchronisable::getSize)
Modified: branches/netp/src/network/packet/Gamestate.cc
===================================================================
--- branches/netp/src/network/packet/Gamestate.cc 2009-03-23 13:39:47 UTC (rev 2831)
+++ branches/netp/src/network/packet/Gamestate.cc 2009-03-23 13:53:10 UTC (rev 2832)
@@ -106,7 +106,12 @@
ObjectList<Synchronisable>::iterator it;
for(it = ObjectList<Synchronisable>::begin(); it; ++it){
- tempsize=it->getSize(id, mode);
+// tempsize=it->getSize(id, mode);
+
+ tempsize = it->getData(mem, id, mode);
+ if ( it->doSync( id, mode ) )
+ dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
+
#ifndef NDEBUG
if(currentsize+tempsize > size){
assert(0); // if we don't use multithreading this part shouldn't be neccessary
@@ -122,11 +127,8 @@
size = currentsize+addsize;
}// stop allocate additional memory
#endif
-
- if ( it->doSync( id, mode ) )
- dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
- if(!it->getData(mem, id, mode))
- return false; // mem pointer gets automatically increased because of call by reference
+// if(!it->getData(mem, id, mode))
+// return false; // mem pointer gets automatically increased because of call by reference
// increase size counter by size of current synchronisable
currentsize+=tempsize;
}
Modified: branches/netp/src/network/synchronisable/Synchronisable.cc
===================================================================
--- branches/netp/src/network/synchronisable/Synchronisable.cc 2009-03-23 13:39:47 UTC (rev 2831)
+++ branches/netp/src/network/synchronisable/Synchronisable.cc 2009-03-23 13:53:10 UTC (rev 2832)
@@ -237,12 +237,12 @@
* 0x3: bidirectional
* @return true: if !doSync or if everything was successfully saved
*/
- bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
+ uint32_t Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
if(mode==0x0)
mode=state_;
//if this tick is we dont synchronise, then abort now
if(!doSync(id, mode))
- return true;
+ return 0;
uint32_t tempsize = 0;
if (this->classID==0)
COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
@@ -278,7 +278,7 @@
size=getSize(id, mode);
assert(tempsize==size);
#endif
- return true;
+ return tempsize;
}
Modified: branches/netp/src/network/synchronisable/Synchronisable.h
===================================================================
--- branches/netp/src/network/synchronisable/Synchronisable.h 2009-03-23 13:39:47 UTC (rev 2831)
+++ branches/netp/src/network/synchronisable/Synchronisable.h 2009-03-23 13:53:10 UTC (rev 2832)
@@ -146,7 +146,7 @@
private:
- bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
+ uint32_t getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
uint32_t getSize(int32_t id, uint8_t mode=0x0);
bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
bool isMyData(uint8_t* mem);
More information about the Orxonox-commit
mailing list