[Orxonox-commit 3714] r8394 - in code/trunk/src/libraries: core network network/packet

scheusso at orxonox.net scheusso at orxonox.net
Tue May 3 09:19:53 CEST 2011


Author: scheusso
Date: 2011-05-03 09:19:52 +0200 (Tue, 03 May 2011)
New Revision: 8394

Modified:
   code/trunk/src/libraries/core/ThreadPool.cc
   code/trunk/src/libraries/network/GamestateManager.cc
   code/trunk/src/libraries/network/packet/Gamestate.cc
Log:
-fixed a memory leak (thx reto)
-some OrxVerify messages


Modified: code/trunk/src/libraries/core/ThreadPool.cc
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.cc	2011-05-03 03:07:42 UTC (rev 8393)
+++ code/trunk/src/libraries/core/ThreadPool.cc	2011-05-03 07:19:52 UTC (rev 8394)
@@ -40,7 +40,7 @@
 
     ThreadPool::~ThreadPool()
     {
-        OrxVerify(this->setNrOfThreads(0) == 0, "" );
+        OrxVerify(this->setNrOfThreads(0) == 0, "ERROR: could not join remaining threads in ThreadPool" );
     }
 
     void ThreadPool::addThreads( unsigned int nr )
@@ -88,14 +88,14 @@
             if ( ! (*it)->isWorking() )
             {
                 // If that fails, then there is some code error
-                OrxVerify( (*it)->evaluateExecutor( executor ), "" );
+                OrxVerify( (*it)->evaluateExecutor( executor ), "ERROR: could not evaluate Executor" );
                 return true;
             }
         }
         if ( addThread )
         {
             addThreads( 1 );
-            OrxVerify( this->threadPool_.back()->evaluateExecutor( executor ), "" ); // access the last element
+            OrxVerify( this->threadPool_.back()->evaluateExecutor( executor ), "ERROR: could not evaluate Executor" ); // access the last element
             return true;
         }
         else

Modified: code/trunk/src/libraries/network/GamestateManager.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateManager.cc	2011-05-03 03:07:42 UTC (rev 8393)
+++ code/trunk/src/libraries/network/GamestateManager.cc	2011-05-03 07:19:52 UTC (rev 8394)
@@ -93,7 +93,8 @@
   {
     assert(gs);
     std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
-    if(it!=gamestateQueue.end()){
+    if(it!=gamestateQueue.end())
+    {
       // delete obsolete gamestate
       delete it->second;
     }
@@ -107,8 +108,9 @@
         return true;
     std::map<unsigned int, packet::Gamestate*>::iterator it;
     // now push only the most recent gamestates we received (ignore obsolete ones)
-    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
-      OrxVerify(processGamestate(it->second), "");
+    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++)
+    {
+      OrxVerify(processGamestate(it->second), "ERROR: could not process Gamestate");
       sendAck( it->second->getID(), it->second->getPeerID() );
       delete it->second;
     }
@@ -361,7 +363,7 @@
   {
     if(gs->isCompressed())
     {
-       OrxVerify(gs->decompressData(), "");
+       OrxVerify(gs->decompressData(), "ERROR: could not decompress Gamestate");
     }
     assert(!gs->isDiffed());
     uint8_t gsMode;

Modified: code/trunk/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Gamestate.cc	2011-05-03 03:07:42 UTC (rev 8393)
+++ code/trunk/src/libraries/network/packet/Gamestate.cc	2011-05-03 07:19:52 UTC (rev 8394)
@@ -201,7 +201,7 @@
     else
     {
 //       COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;
-      OrxVerify(s->updateData(mem, mode), "");
+      OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
     }
   }
   assert((uintptr_t)(mem-data_) == GamestateHeader::getSize()+header_.getDataSize());
@@ -262,12 +262,12 @@
 {
   uint8_t *d1 = data_+GamestateHeader::getSize();
   uint8_t *d2 = gs.data_+GamestateHeader::getSize();
-  GamestateHeader* h1 = new GamestateHeader(data_);
-  GamestateHeader* h2 = new GamestateHeader(gs.data_);
-  assert(h1->getDataSize() == h2->getDataSize());
+  GamestateHeader h1(data_);
+  GamestateHeader h2(gs.data_);
+  assert(h1.getDataSize() == h2.getDataSize());
   assert(!isCompressed());
   assert(!gs.isCompressed());
-  return memcmp(d1, d2, h1->getDataSize())==0;
+  return memcmp(d1, d2, h1.getDataSize())==0;
 }
 
 




More information about the Orxonox-commit mailing list