[Orxonox-commit 3131] r7825 - in code/branches/network6/src/libraries/network: . packet synchronisable
scheusso at orxonox.net
scheusso at orxonox.net
Wed Dec 29 23:41:51 CET 2010
Author: scheusso
Date: 2010-12-29 23:41:51 +0100 (Wed, 29 Dec 2010)
New Revision: 7825
Modified:
code/branches/network6/src/libraries/network/ClientConnection.cc
code/branches/network6/src/libraries/network/Connection.cc
code/branches/network6/src/libraries/network/Connection.h
code/branches/network6/src/libraries/network/GamestateManager.cc
code/branches/network6/src/libraries/network/packet/Gamestate.cc
code/branches/network6/src/libraries/network/synchronisable/Synchronisable.cc
Log:
-enabling client-side gamestate diffing
-added some optimisations
Modified: code/branches/network6/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/network6/src/libraries/network/ClientConnection.cc 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/ClientConnection.cc 2010-12-29 22:41:51 UTC (rev 7825)
@@ -41,6 +41,7 @@
ClientConnection::ClientConnection():
+ Connection(NETWORK_PEER_ID_SERVER),
established_(false),
server_(NULL)
{
Modified: code/branches/network6/src/libraries/network/Connection.cc
===================================================================
--- code/branches/network6/src/libraries/network/Connection.cc 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/Connection.cc 2010-12-29 22:41:51 UTC (rev 7825)
@@ -42,8 +42,8 @@
{
const boost::posix_time::millisec NETWORK_COMMUNICATION_THREAD_WAIT_TIME(20);
- Connection::Connection():
- host_(0), bCommunicationThreadRunning_(false), nextPeerID_(NETWORK_PEER_ID_SERVER+1)
+ Connection::Connection(uint32_t firstPeerID):
+ host_(0), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)
{
enet_initialize();
atexit(enet_deinitialize);
Modified: code/branches/network6/src/libraries/network/Connection.h
===================================================================
--- code/branches/network6/src/libraries/network/Connection.h 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/Connection.h 2010-12-29 22:41:51 UTC (rev 7825)
@@ -104,7 +104,7 @@
virtual ~Connection();
protected:
- Connection();
+ Connection(uint32_t firstPeerID = NETWORK_PEER_ID_SERVER+1);
void startCommunicationThread();
void stopCommunicationThread();
Modified: code/branches/network6/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/network6/src/libraries/network/GamestateManager.cc 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/GamestateManager.cc 2010-12-29 22:41:51 UTC (rev 7825)
@@ -148,7 +148,10 @@
if( GameMode::isMaster() )
newID = ++id_;
else
+ {
+ assert(peerMap_.size()!=0);
newID = peerMap_[NETWORK_PEER_ID_SERVER].lastProcessedGamestateID;
+ }
if(!currentGamestate_->collectData(newID, gsMode)){ //we have no data to send
delete currentGamestate_;
@@ -171,7 +174,7 @@
COUT(5) << "Server: not sending gamestate" << std::endl;
continue;
}
- COUT(4) << "client id: " << peerIt->first << std::endl;
+ COUT(5) << "client id: " << peerIt->first << std::endl;
COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
int peerID = peerIt->first; //get client id
@@ -243,7 +246,7 @@
// bool b = gs->compressData();
// assert(b);
clock.capture();
- COUT(4) << "diff and compress time: " << clock.getDeltaTime() << endl;
+ COUT(5) << "diff and compress time: " << clock.getDeltaTime() << endl;
// COUT(5) << "sending gamestate with id " << gs->getID();
// if(gamestate->isDiffed())
// COUT(5) << " and baseid " << gs->getBaseID() << endl;
Modified: code/branches/network6/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/network6/src/libraries/network/packet/Gamestate.cc 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/packet/Gamestate.cc 2010-12-29 22:41:51 UTC (rev 7825)
@@ -106,7 +106,7 @@
assert(data_==0);
uint32_t size = calcGamestateSize(id, mode);
- COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
+ COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
if(size==0)
return false;
data_ = new uint8_t[size + GamestateHeader::getSize()];
Modified: code/branches/network6/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/network6/src/libraries/network/synchronisable/Synchronisable.cc 2010-12-28 18:11:32 UTC (rev 7824)
+++ code/branches/network6/src/libraries/network/synchronisable/Synchronisable.cc 2010-12-29 22:41:51 UTC (rev 7825)
@@ -294,7 +294,7 @@
* This function takes a bytestream and loads the data into the registered variables
* @param mem pointer to the bytestream
* @param mode same as in getData
- * @param forceCallback FIXME - add doc!
+ * @param forceCallback this makes updateData call each callback
* @return true/false
*/
bool Synchronisable::updateData(uint8_t*& mem, uint8_t mode, bool forceCallback)
@@ -371,13 +371,14 @@
/**
* This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
* @param id gamestate id
- * @param mode FIXME - add doc!
+ * @param mode Synchronisation mode (toclient, toserver or bidirectional)
* @return true/false
*/
bool Synchronisable::doSync(int32_t id, uint8_t mode)
{
- if(mode==0x0)
- mode=state_;
+// if(mode==0x0)
+// mode=state_;
+ assert(mode!=0x0);
return ( (this->objectMode_ & mode)!=0 && (!syncList_.empty() ) );
}
More information about the Orxonox-commit
mailing list