[Orxonox-commit 3189] r7882 - code/branches/network6/src/libraries/network

scheusso at orxonox.net scheusso at orxonox.net
Mon Feb 14 09:00:48 CET 2011


Author: scheusso
Date: 2011-02-14 09:00:48 +0100 (Mon, 14 Feb 2011)
New Revision: 7882

Modified:
   code/branches/network6/src/libraries/network/Client.cc
   code/branches/network6/src/libraries/network/GamestateManager.cc
   code/branches/network6/src/libraries/network/Server.cc
Log:
improving gamestate processing and generation


Modified: code/branches/network6/src/libraries/network/Client.cc
===================================================================
--- code/branches/network6/src/libraries/network/Client.cc	2011-02-14 07:58:47 UTC (rev 7881)
+++ code/branches/network6/src/libraries/network/Client.cc	2011-02-14 08:00:48 UTC (rev 7882)
@@ -154,12 +154,14 @@
       {
         COUT(4) << "popping partial gamestate: " << std::endl;
 //         packet::Gamestate *gs = GamestateClient::getGamestate();
-        GamestateManager::update();
-        std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
-        std::vector<packet::Gamestate*>::iterator it;
-        for( it = gamestates.begin(); it != gamestates.end(); ++it )
+        if( GamestateManager::update() )
         {
-          (*it)->send( static_cast<Host*>(this) );
+          std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
+          std::vector<packet::Gamestate*>::iterator it;
+          for( it = gamestates.begin(); it != gamestates.end(); ++it )
+          {
+            (*it)->send( static_cast<Host*>(this) );
+          }
         }
         //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
 //         if(gs){

Modified: code/branches/network6/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/network6/src/libraries/network/GamestateManager.cc	2011-02-14 07:58:47 UTC (rev 7881)
+++ code/branches/network6/src/libraries/network/GamestateManager.cc	2011-02-14 08:00:48 UTC (rev 7882)
@@ -56,7 +56,7 @@
 // #include "TrafficControl.h"
 
 namespace orxonox
-{
+{ 
   GamestateManager::GamestateManager() :
   currentGamestate_(0), id_(0)
   {
@@ -109,7 +109,7 @@
     for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
       bool b = processGamestate(it->second);
       assert(b);
-//       sendAck( it->second->getID(), it->second->getPeerID() );
+      sendAck( it->second->getID(), it->second->getPeerID() );
       delete it->second;
     }
     // now clear the queue
@@ -139,7 +139,6 @@
   bool GamestateManager::getSnapshot(){
     if ( currentGamestate_ != 0 )
       delete currentGamestate_;
-    currentGamestate_ = new packet::Gamestate();
     uint8_t gsMode;
     if( GameMode::isMaster() )
       gsMode = packet::GAMESTATE_MODE_SERVER;
@@ -152,11 +151,19 @@
     {
       assert(peerMap_.size()!=0);
       newID = peerMap_[NETWORK_PEER_ID_SERVER].lastReceivedGamestateID;
+      if( newID == GAMESTATEID_INITIAL )
+      {
+        return false;
+      }
     }
     
-    if(!currentGamestate_->collectData(newID, gsMode)){ //we have no data to send
+    currentGamestate_ = new packet::Gamestate();
+    
+    if(!currentGamestate_->collectData(newID, gsMode))
+    { //we have no data to send
       delete currentGamestate_;
       currentGamestate_=0;
+      return false;
     }
     return true;
   }

Modified: code/branches/network6/src/libraries/network/Server.cc
===================================================================
--- code/branches/network6/src/libraries/network/Server.cc	2011-02-14 07:58:47 UTC (rev 7881)
+++ code/branches/network6/src/libraries/network/Server.cc	2011-02-14 08:00:48 UTC (rev 7882)
@@ -416,16 +416,16 @@
     w->setPeerID(clientID);
     b = w->send( static_cast<Host*>(this) );
     assert(b);
-    packet::Gamestate *g = new packet::Gamestate();
-    g->setPeerID(clientID);
-    b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
-    assert(b);
-    if(!b)
-      return false; //no data for the client
-//     b = g->compressData();
+//     packet::Gamestate *g = new packet::Gamestate();
+//     g->setPeerID(clientID);
+//     b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
 //     assert(b);
-    b = g->send( static_cast<Host*>(this) );
-    assert(b);
+//     if(!b)
+//       return false; //no data for the client
+// //     b = g->compressData();
+// //     assert(b);
+//     b = g->send( static_cast<Host*>(this) );
+//     assert(b);
     return true;
   }
 




More information about the Orxonox-commit mailing list