[Orxonox-commit 4634] r9305 - in code/branches/presentation2012merge/src: modules/pickup modules/pickup/items orxonox/pickup
landauf at orxonox.net
landauf at orxonox.net
Mon Jun 18 21:54:50 CEST 2012
Author: landauf
Date: 2012-06-18 21:54:49 +0200 (Mon, 18 Jun 2012)
New Revision: 9305
Modified:
code/branches/presentation2012merge/src/modules/pickup/Pickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc
code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc
code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc
code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.h
Log:
simplified code a little by using MultiType instead of explicit conversion
Modified: code/branches/presentation2012merge/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/Pickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/Pickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -89,13 +89,8 @@
*/
void Pickup::initializeIdentifier(void)
{
- std::string val1 = this->getActivationType();
- std::string type1 = "activationType";
- this->pickupIdentifier_->addParameter(type1, val1);
-
- std::string val2 = this->getDurationType();
- std::string type2 = "durationType";
- this->pickupIdentifier_->addParameter(type2, val2);
+ this->pickupIdentifier_->addParameter("activationType", this->getActivationType());
+ this->pickupIdentifier_->addParameter("durationType", this->getDurationType());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -81,18 +81,8 @@
*/
void DamageBoostPickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getDuration();
- std::string type1 = "duration";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- stream.clear();
- stream << this->getDamageMultiplier();
- std::string type2 = "damageMultiplier";
- std::string val2 = stream.str();
- this->pickupIdentifier_->addParameter(type2, val2);
-
+ this->pickupIdentifier_->addParameter("duration", this->getDuration());
+ this->pickupIdentifier_->addParameter("damageMultiplier", this->getDamageMultiplier());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -84,9 +84,7 @@
*/
void DronePickup::initializeIdentifier(void)
{
- std::string val = this->getDroneTemplate();
- std::string type = "droneTemplate";
- this->pickupIdentifier_->addParameter(type, val);
+ this->pickupIdentifier_->addParameter("droneTemplate", this->getDroneTemplate());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -90,21 +90,9 @@
*/
void HealthPickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getHealth();
- std::string type1 = "health";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- std::string val2 = this->getHealthType();
- std::string type2 = "healthType";
- this->pickupIdentifier_->addParameter(type2, val2);
-
- stream.clear();
- stream << this->getHealthRate();
- std::string val3 = stream.str();
- std::string type3 = "healthRate";
- this->pickupIdentifier_->addParameter(type3, val3);
+ this->pickupIdentifier_->addParameter("health", this->getHealth());
+ this->pickupIdentifier_->addParameter("healthType", this->getHealthType());
+ this->pickupIdentifier_->addParameter("healthRate", this->getHealthRate());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -82,11 +82,7 @@
*/
void InvisiblePickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getDuration();
- std::string type1 = "duration";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
+ this->pickupIdentifier_->addParameter("duration", this->getDuration());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -89,9 +89,7 @@
*/
void MetaPickup::initializeIdentifier(void)
{
- std::string val = this->getMetaType();
- std::string type = "metaType";
- this->pickupIdentifier_->addParameter(type, val);
+ this->pickupIdentifier_->addParameter("metaType", this->getMetaType());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -83,24 +83,9 @@
*/
void ShieldPickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getDuration();
- std::string type1 = "duration";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- stream.clear();
- stream << this->getShieldHealth();
- std::string type2 = "ShieldHealth";
- std::string val2 = stream.str();
- this->pickupIdentifier_->addParameter(type2, val2);
-
- stream.clear();
- stream << this->getShieldAbsorption();
- std::string type3 = "ShieldAbsorption";
- std::string val3 = stream.str();
- this->pickupIdentifier_->addParameter(type3, val3);
-
+ this->pickupIdentifier_->addParameter("duration", this->getDuration());
+ this->pickupIdentifier_->addParameter("ShieldHealth", this->getShieldHealth());
+ this->pickupIdentifier_->addParameter("ShieldAbsorption", this->getShieldAbsorption());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -82,23 +82,9 @@
void ShrinkPickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getShrinkFactor();
- std::string type1 = "shrinkFactor";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- stream.clear();
- stream << this->getDuration();
- std::string val2 = stream.str();
- std::string type2 = "duration";
- this->pickupIdentifier_->addParameter(type2, val2);
-
- stream.clear();
- stream << this->getShrinkDuration();
- std::string val3 = stream.str();
- std::string type3 = "shrinkDuration";
- this->pickupIdentifier_->addParameter(type3, val3);
+ this->pickupIdentifier_->addParameter("shrinkFactor", this->getShrinkFactor());
+ this->pickupIdentifier_->addParameter("duration", this->getDuration());
+ this->pickupIdentifier_->addParameter("shrinkDuration", this->getShrinkDuration());
}
/**
Modified: code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -83,23 +83,9 @@
*/
void SpeedPickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getDuration();
- std::string type1 = "duration";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- stream.clear();
- stream << this->getSpeedAdd();
- std::string type2 = "speedAdd";
- std::string val2 = stream.str();
- this->pickupIdentifier_->addParameter(type2, val2);
-
- stream.clear();
- stream << this->getSpeedMultiply();
- std::string type3 = "speedMultiply";
- std::string val3 = stream.str();
- this->pickupIdentifier_->addParameter(type3, val3);
+ this->pickupIdentifier_->addParameter("duration", this->getDuration());
+ this->pickupIdentifier_->addParameter("speedAdd", this->getSpeedAdd());
+ this->pickupIdentifier_->addParameter("speedMultiply", this->getSpeedMultiply());
}
/**
Modified: code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc 2012-06-18 19:54:49 UTC (rev 9305)
@@ -112,7 +112,7 @@
@return
Returns false if the parameter already existed, true if not.
*/
- bool PickupIdentifier::addParameter(const std::string& name, const std::string& value)
+ bool PickupIdentifier::addParameter(const std::string& name, const MultiType& value)
{
orxout(verbose, context::pickups) << "PickupIdentifier " << name << ", " << value << endl;
@@ -122,7 +122,7 @@
return false;
}
- this->parameters_[name] = value;
+ this->parameters_[name] = value.getString();
return true;
}
Modified: code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.h
===================================================================
--- code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.h 2012-06-17 21:04:25 UTC (rev 9304)
+++ code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.h 2012-06-18 19:54:49 UTC (rev 9305)
@@ -71,7 +71,7 @@
virtual int compare(const PickupIdentifier* identifier) const; //!< Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b).
- bool addParameter(const std::string& name, const std::string& value); //!< Add a parameter to the PickupIdentifier.
+ bool addParameter(const std::string& name, const MultiType& value); //!< Add a parameter to the PickupIdentifier.
private:
Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
More information about the Orxonox-commit
mailing list