[Orxonox-commit 4193] r8864 - in code/trunk/src: modules/pickup modules/pickup/items orxonox/pickup

dafrick at orxonox.net dafrick at orxonox.net
Wed Aug 24 14:57:54 CEST 2011


Author: dafrick
Date: 2011-08-24 14:57:53 +0200 (Wed, 24 Aug 2011)
New Revision: 8864

Modified:
   code/trunk/src/modules/pickup/Pickup.cc
   code/trunk/src/modules/pickup/items/HealthPickup.cc
   code/trunk/src/orxonox/pickup/PickupIdentifier.cc
Log:
Improving output.


Modified: code/trunk/src/modules/pickup/Pickup.cc
===================================================================
--- code/trunk/src/modules/pickup/Pickup.cc	2011-08-24 11:17:36 UTC (rev 8863)
+++ code/trunk/src/modules/pickup/Pickup.cc	2011-08-24 12:57:53 UTC (rev 8864)
@@ -158,18 +158,12 @@
     */
     void Pickup::setActivationType(const std::string& type)
     {
-        if(Pickup::activationTypeImmediate_s.compare(type) == 0)
-        {
+        if(type == Pickup::activationTypeImmediate_s)
             this->activationType_ = pickupActivationType::immediate;
-        }
-        else if(Pickup::activationTypeOnUse_s.compare(type) == 0)
-        {
+        else if(type == Pickup::activationTypeOnUse_s)
             this->activationType_ = pickupActivationType::onUse;
-        }
         else
-        {
-            orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in pickup." << endl;
-        }
+            orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     }
 
     /**
@@ -180,18 +174,12 @@
     */
     void Pickup::setDurationType(const std::string& type)
     {
-        if(Pickup::durationTypeOnce_s.compare(type) == 0)
-        {
+        if(type == Pickup::durationTypeOnce_s)
             this->durationType_ = pickupDurationType::once;
-        }
-        else if(Pickup::durationTypeContinuous_s.compare(type) == 0)
-        {
+        else if(type == Pickup::durationTypeContinuous_s)
             this->durationType_ = pickupDurationType::continuous;
-        }
         else
-        {
-            orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in pickup." << endl;
-        }
+            orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     }
 
     /**

Modified: code/trunk/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.cc	2011-08-24 11:17:36 UTC (rev 8863)
+++ code/trunk/src/modules/pickup/items/HealthPickup.cc	2011-08-24 12:57:53 UTC (rev 8864)
@@ -75,11 +75,11 @@
     */
     void HealthPickup::initialize(void)
     {
-        this->health_ = 0;
-        this->healthRate_ = 0;
+        this->health_ = 0.0f;
+        this->healthRate_ = 0.0f;
         this->healthType_ = pickupHealthType::limited;
-        this->maxHealthSave_ = 0;
-        this->maxHealthOverwrite_ = 0;
+        this->maxHealthSave_ = 0.0f;
+        this->maxHealthOverwrite_ = 0.0f;
 
         this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     }
@@ -120,7 +120,7 @@
         XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
 
         if(!this->isContinuous())
-            this->healthRate_ = 0.0;
+            this->healthRate_ = 0.0f;
 
         this->initializeIdentifier();
     }
@@ -172,7 +172,7 @@
             }
 
             // If all health has been transferred.
-            if(this->getHealth() == 0)
+            if(this->getHealth() == 0.0f)
             {
                 this->setUsed(false);
             }
@@ -196,7 +196,7 @@
                 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
                     this->Pickupable::destroy();
 
-                float health = 0;
+                float health = 0.0f;
                 switch(this->getHealthTypeDirect())
                 {
                     case pickupHealthType::permanent:
@@ -233,7 +233,7 @@
 
                 if(pawn == NULL)
                 {
-                    orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << endl;
+                    orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is '" << carrier->getIdentifier()->getName() << "' instead of Pawn." << endl;
                     this->Pickupable::destroy();
                     return;
                 }
@@ -247,7 +247,7 @@
             }
 
             // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
-            if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
+            if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0.0f))
             {
                 this->Pickupable::destroy();
             }
@@ -266,9 +266,7 @@
         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
 
         if(pawn == NULL)
-        {
             orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl;
-        }
 
         return pawn;
     }
@@ -325,13 +323,11 @@
     void HealthPickup::setHealth(float health)
     {
         if(health >= 0.0f)
-        {
             this->health_ = health;
-        }
         else
         {
-            orxout(internal_error, context::pickups) << "Invalid health in HealthPickup." << endl;
-            this->health_ = 0.0;
+            orxout(internal_error, context::pickups) << "Invalid health '" << health << "' in HealthPickup. The health must be non.negative." << endl;
+            this->health_ = 0.0f;
         }
     }
 
@@ -343,14 +339,10 @@
     */
     void HealthPickup::setHealthRate(float rate)
     {
-        if(rate >= 0)
-        {
+        if(rate >= 0.0f)
             this->healthRate_ = rate;
-        }
         else
-        {
-            orxout(internal_error, context::pickups) << "Invalid healthSpeed in HealthPickup." << endl;
-        }
+            orxout(internal_error, context::pickups) << "Invalid healthRate '" << rate << "' in HealthPickup. The healthRate must be non-negative." << endl;
     }
 
     /**
@@ -362,21 +354,13 @@
     void HealthPickup::setHealthType(std::string type)
     {
         if(type == HealthPickup::healthTypeLimited_s)
-        {
             this->setHealthTypeDirect(pickupHealthType::limited);
-        }
         else if(type == HealthPickup::healthTypeTemporary_s)
-        {
             this->setHealthTypeDirect(pickupHealthType::temporary);
-        }
         else if(type == HealthPickup::healthTypePermanent_s)
-        {
             this->setHealthTypeDirect(pickupHealthType::permanent);
-        }
         else
-        {
-            orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
-        }
+            orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
     }
 
 }

Modified: code/trunk/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupIdentifier.cc	2011-08-24 11:17:36 UTC (rev 8863)
+++ code/trunk/src/orxonox/pickup/PickupIdentifier.cc	2011-08-24 12:57:53 UTC (rev 8864)
@@ -74,7 +74,7 @@
         assert(identifier->pickup_);
         assert(this->pickup_);
 
-        // If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
+        // If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), then obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
         if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
             return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
 
@@ -82,7 +82,7 @@
         // If the two have a different number of parameters then obviously something is very wrong.
         if(!(this->parameters_.size() == identifier->parameters_.size()))
         {
-            orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
+            orxout(internal_error, context::pickups) << "Two PickupIdentifiers of the same Class have a different number of parameters. " << this->parameters_.size() << " vs. " << identifier->parameters_.size() << ". This indicates a bug in " << this->pickup_->getIdentifier()->getName() << "." << endl;
             return this->parameters_.size()-identifier->parameters_.size();
         }
 
@@ -92,7 +92,7 @@
             // If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
             if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
             {
-                orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
+                orxout(internal_error, context::pickups) << this->pickup_->getIdentifier()->getName() <<  " Something went wrong in PickupIdentifier!" << endl;
                 return -1;
             }
             if(identifier->parameters_.find(it->first)->second != it->second)




More information about the Orxonox-commit mailing list