Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9314


Ignore:
Timestamp:
Jul 8, 2012, 6:31:46 PM (12 years ago)
Author:
landauf
Message:

probably a bugfix: PickupIdentifier compared only the first parameter in the map.
also some performance enhancements

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

Legend:

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

    r9297 r9314  
    9292            const PickupIdentifier* id2 = (*it2)->getPickupIdentifier();
    9393
    94             if(id1->compare(id2) < 0)
    95                 return -1;
    96             if(id2->compare(id1) < 0)
    97                 return 1;
     94            int result = id1->compare(id2);
     95            if(result != 0)
     96                return result;
    9897        }
    9998
  • code/branches/presentation2012merge/src/orxonox/pickup/PickupIdentifier.cc

    r9305 r9314  
    7676
    7777        // 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.
    78         if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
     78        if(identifier->pickup_->getIdentifier() != this->pickup_->getIdentifier())
    7979            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
    8080
    8181        // If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
    8282        // If the two have a different number of parameters then obviously something is very wrong.
    83         if(!(this->parameters_.size() == identifier->parameters_.size()))
     83        if(this->parameters_.size() != identifier->parameters_.size())
    8484        {
    8585            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;
     
    8787        }
    8888
    89         // We iterate through all parameters and compare their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
    90         for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++)
     89        // We iterate through all parameters and compare their values (which are strings). The ordering is once again established by the alphabetical comparison of the two value strings.
     90        std::map<std::string, std::string>::const_iterator it1 = this->parameters_.begin();
     91        std::map<std::string, std::string>::const_iterator it2 = identifier->parameters_.begin();
     92        for( ; it1 != this->parameters_.end(); ++it1, ++it2)
    9193        {
    9294            // If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
    93             if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
     95            if(it1->first != it2->first)
    9496            {
    9597                orxout(internal_error, context::pickups) << this->pickup_->getIdentifier()->getName() <<  " Something went wrong in PickupIdentifier!" << endl;
    96                 return -1;
     98                return it1->first.compare(it2->first);
    9799            }
    98             if(identifier->parameters_.find(it->first)->second != it->second)
    99                 return it->second.compare(identifier->parameters_.find(it->first)->second);
     100
     101            int result = it1->second.compare(it2->second);
     102            if(result != 0)
     103                return result;
    100104        }
    101105
Note: See TracChangeset for help on using the changeset viewer.