[Orxonox-commit 3692] r8373 - in code/trunk/src/libraries: core network network/packet

rgrieder at orxonox.net rgrieder at orxonox.net
Mon May 2 05:00:21 CEST 2011


Author: rgrieder
Date: 2011-05-02 05:00:20 +0200 (Mon, 02 May 2011)
New Revision: 8373

Modified:
   code/trunk/src/libraries/core/ThreadPool.cc
   code/trunk/src/libraries/network/GamestateManager.cc
   code/trunk/src/libraries/network/packet/Gamestate.cc
Log:
Replaced code like
bool b = someFunction(); assert(b);
with
OrxVerify(someFunction(), "");
to remove warnings in release mode.

Modified: code/trunk/src/libraries/core/ThreadPool.cc
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.cc	2011-05-01 19:02:38 UTC (rev 8372)
+++ code/trunk/src/libraries/core/ThreadPool.cc	2011-05-02 03:00:20 UTC (rev 8373)
@@ -27,8 +27,9 @@
  */
 
 #include "ThreadPool.h"
+
+#include "util/OrxAssert.h"
 #include "Thread.h"
-#include <cassert>
 
 namespace orxonox
 {
@@ -39,8 +40,7 @@
 
     ThreadPool::~ThreadPool()
     {
-        unsigned int a = this->setNrOfThreads(0);
-        assert(a == 0);
+        OrxVerify(this->setNrOfThreads(0) == 0, "" );
     }
 
     void ThreadPool::addThreads( unsigned int nr )
@@ -87,16 +87,15 @@
         {
             if ( ! (*it)->isWorking() )
             {
-                bool b = (*it)->evaluateExecutor( executor );
-                assert(b); // if b is false then there is some code error
+                // If that fails, then there is some code error
+                OrxVerify( (*it)->evaluateExecutor( executor ), "" );
                 return true;
             }
         }
         if ( addThread )
         {
             addThreads( 1 );
-            bool b = this->threadPool_.back()->evaluateExecutor( executor ); // access the last element
-            assert(b);
+            OrxVerify( this->threadPool_.back()->evaluateExecutor( 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-01 19:02:38 UTC (rev 8372)
+++ code/trunk/src/libraries/network/GamestateManager.cc	2011-05-02 03:00:20 UTC (rev 8373)
@@ -53,6 +53,7 @@
 #include "core/GameMode.h"
 #include "util/Debug.h"
 #include "util/Clock.h"
+#include "util/OrxAssert.h"
 // #include "TrafficControl.h"
 
 namespace orxonox
@@ -107,8 +108,7 @@
     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++){
-      bool b = processGamestate(it->second);
-      assert(b);
+      OrxVerify(processGamestate(it->second), "");
       sendAck( it->second->getID(), it->second->getPeerID() );
       delete it->second;
     }
@@ -251,8 +251,7 @@
     }
 
 
-//     bool b = gs->compressData();
-//     assert(b);
+//     OrxVerify(gs->compressData(), "");
     clock.capture();
     COUT(5) << "diff and compress time: " << clock.getDeltaTime() << endl;
 //     COUT(5) << "sending gamestate with id " << gs->getID();
@@ -362,8 +361,7 @@
   {
     if(gs->isCompressed())
     {
-       bool b = gs->decompressData();
-       assert(b);
+       OrxVerify(gs->decompressData(), "");
     }
     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-01 19:02:38 UTC (rev 8372)
+++ code/trunk/src/libraries/network/packet/Gamestate.cc	2011-05-02 03:00:20 UTC (rev 8373)
@@ -31,6 +31,7 @@
 #include <zlib.h>
 
 #include "util/Debug.h"
+#include "util/OrxAssert.h"
 #include "core/GameMode.h"
 #include "core/ObjectList.h"
 #include "network/synchronisable/Synchronisable.h"
@@ -200,8 +201,7 @@
     else
     {
 //       COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;
-      bool b = s->updateData(mem, mode);
-      assert(b);
+      OrxVerify(s->updateData(mem, mode), "");
     }
   }
   assert((uintptr_t)(mem-data_) == GamestateHeader::getSize()+header_.getDataSize());




More information about the Orxonox-commit mailing list