Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9305


Ignore:
Timestamp:
Jun 18, 2012, 9:54:49 PM (12 years ago)
Author:
landauf
Message:

simplified code a little by using MultiType instead of explicit conversion

Location:
code/branches/presentation2012merge/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/modules/pickup/Pickup.cc

    r9279 r9305  
    9090    void Pickup::initializeIdentifier(void)
    9191    {
    92         std::string val1 = this->getActivationType();
    93         std::string type1 = "activationType";
    94         this->pickupIdentifier_->addParameter(type1, val1);
    95 
    96         std::string val2 = this->getDurationType();
    97         std::string type2 = "durationType";
    98         this->pickupIdentifier_->addParameter(type2, val2);
     92        this->pickupIdentifier_->addParameter("activationType", this->getActivationType());
     93        this->pickupIdentifier_->addParameter("durationType", this->getDurationType());
    9994    }
    10095
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc

    r9279 r9305  
    8282    void DamageBoostPickup::initializeIdentifier(void)
    8383    {
    84         std::stringstream stream;
    85         stream << this->getDuration();
    86         std::string type1 = "duration";
    87         std::string val1 = stream.str();
    88         this->pickupIdentifier_->addParameter(type1, val1);
    89 
    90         stream.clear();
    91         stream << this->getDamageMultiplier();
    92         std::string type2 = "damageMultiplier";
    93         std::string val2 = stream.str();
    94         this->pickupIdentifier_->addParameter(type2, val2);
    95 
     84        this->pickupIdentifier_->addParameter("duration", this->getDuration());
     85        this->pickupIdentifier_->addParameter("damageMultiplier", this->getDamageMultiplier());
    9686    }
    9787
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc

    r9279 r9305  
    8585    void DronePickup::initializeIdentifier(void)
    8686    {
    87         std::string val = this->getDroneTemplate();
    88         std::string type = "droneTemplate";
    89         this->pickupIdentifier_->addParameter(type, val);
     87        this->pickupIdentifier_->addParameter("droneTemplate", this->getDroneTemplate());
    9088    }
    9189
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc

    r9279 r9305  
    9191    void HealthPickup::initializeIdentifier(void)
    9292    {
    93         std::stringstream stream;
    94         stream << this->getHealth();
    95         std::string type1 = "health";
    96         std::string val1 = stream.str();
    97         this->pickupIdentifier_->addParameter(type1, val1);
    98 
    99         std::string val2 = this->getHealthType();
    100         std::string type2 = "healthType";
    101         this->pickupIdentifier_->addParameter(type2, val2);
    102 
    103         stream.clear();
    104         stream << this->getHealthRate();
    105         std::string val3 = stream.str();
    106         std::string type3 = "healthRate";
    107         this->pickupIdentifier_->addParameter(type3, val3);
     93        this->pickupIdentifier_->addParameter("health", this->getHealth());
     94        this->pickupIdentifier_->addParameter("healthType", this->getHealthType());
     95        this->pickupIdentifier_->addParameter("healthRate", this->getHealthRate());
    10896    }
    10997
  • code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc

    r9279 r9305  
    8383    void InvisiblePickup::initializeIdentifier(void)
    8484    {
    85         std::stringstream stream;
    86         stream << this->getDuration();
    87         std::string type1 = "duration";
    88         std::string val1 = stream.str();
    89         this->pickupIdentifier_->addParameter(type1, val1);
     85        this->pickupIdentifier_->addParameter("duration", this->getDuration());
    9086    }
    9187
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc

    r9279 r9305  
    9090    void MetaPickup::initializeIdentifier(void)
    9191    {
    92         std::string val = this->getMetaType();
    93         std::string type = "metaType";
    94         this->pickupIdentifier_->addParameter(type, val);
     92        this->pickupIdentifier_->addParameter("metaType", this->getMetaType());
    9593    }
    9694
  • code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc

    r9279 r9305  
    8484    void ShieldPickup::initializeIdentifier(void)
    8585    {
    86         std::stringstream stream;
    87         stream << this->getDuration();
    88         std::string type1 = "duration";
    89         std::string val1 = stream.str();
    90         this->pickupIdentifier_->addParameter(type1, val1);
    91 
    92         stream.clear();
    93         stream << this->getShieldHealth();
    94         std::string type2 = "ShieldHealth";
    95         std::string val2 = stream.str();
    96         this->pickupIdentifier_->addParameter(type2, val2);
    97 
    98         stream.clear();
    99         stream << this->getShieldAbsorption();
    100         std::string type3 = "ShieldAbsorption";
    101         std::string val3 = stream.str();
    102         this->pickupIdentifier_->addParameter(type3, val3);
    103 
     86        this->pickupIdentifier_->addParameter("duration", this->getDuration());
     87        this->pickupIdentifier_->addParameter("ShieldHealth", this->getShieldHealth());
     88        this->pickupIdentifier_->addParameter("ShieldAbsorption", this->getShieldAbsorption());
    10489    }
    10590
  • code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc

    r9279 r9305  
    8383    void ShrinkPickup::initializeIdentifier(void)
    8484    {
    85         std::stringstream stream;
    86         stream << this->getShrinkFactor();
    87         std::string type1 = "shrinkFactor";
    88         std::string val1 = stream.str();
    89         this->pickupIdentifier_->addParameter(type1, val1);
    90 
    91         stream.clear();
    92         stream << this->getDuration();
    93         std::string val2 = stream.str();
    94         std::string type2 = "duration";
    95         this->pickupIdentifier_->addParameter(type2, val2);
    96 
    97         stream.clear();
    98         stream << this->getShrinkDuration();
    99         std::string val3 = stream.str();
    100         std::string type3 = "shrinkDuration";
    101         this->pickupIdentifier_->addParameter(type3, val3);
     85        this->pickupIdentifier_->addParameter("shrinkFactor", this->getShrinkFactor());
     86        this->pickupIdentifier_->addParameter("duration", this->getDuration());
     87        this->pickupIdentifier_->addParameter("shrinkDuration", this->getShrinkDuration());
    10288    }
    10389
  • code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc

    r9279 r9305  
    8484    void SpeedPickup::initializeIdentifier(void)
    8585    {
    86         std::stringstream stream;
    87         stream << this->getDuration();
    88         std::string type1 = "duration";
    89         std::string val1 = stream.str();
    90         this->pickupIdentifier_->addParameter(type1, val1);
    91 
    92         stream.clear();
    93         stream << this->getSpeedAdd();
    94         std::string type2 = "speedAdd";
    95         std::string val2 = stream.str();
    96         this->pickupIdentifier_->addParameter(type2, val2);
    97 
    98         stream.clear();
    99         stream << this->getSpeedMultiply();
    100         std::string type3 = "speedMultiply";
    101         std::string val3 = stream.str();
    102         this->pickupIdentifier_->addParameter(type3, val3);
     86        this->pickupIdentifier_->addParameter("duration", this->getDuration());
     87        this->pickupIdentifier_->addParameter("speedAdd", this->getSpeedAdd());
     88        this->pickupIdentifier_->addParameter("speedMultiply", this->getSpeedMultiply());
    10389    }
    10490
  • code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc

    r9294 r9305  
    113113        Returns false if the parameter already existed, true if not.
    114114    */
    115     bool PickupIdentifier::addParameter(const std::string& name, const std::string& value)
     115    bool PickupIdentifier::addParameter(const std::string& name, const MultiType& value)
    116116    {
    117117        orxout(verbose, context::pickups) << "PickupIdentifier " << name << ", " << value << endl;
     
    123123        }
    124124
    125         this->parameters_[name] = value;
     125        this->parameters_[name] = value.getString();
    126126
    127127        return true;
  • code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.h

    r9294 r9305  
    7272            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).
    7373
    74             bool addParameter(const std::string& name, const std::string& value); //!< Add a parameter to the PickupIdentifier.
     74            bool addParameter(const std::string& name, const MultiType& value); //!< Add a parameter to the PickupIdentifier.
    7575
    7676        private:
Note: See TracChangeset for help on using the changeset viewer.