Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8864 for code/trunk


Ignore:
Timestamp:
Aug 24, 2011, 2:57:53 PM (13 years ago)
Author:
dafrick
Message:

Improving output.

Location:
code/trunk/src
Files:
3 edited

Legend:

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

    r8858 r8864  
    159159    void Pickup::setActivationType(const std::string& type)
    160160    {
    161         if(Pickup::activationTypeImmediate_s.compare(type) == 0)
    162         {
     161        if(type == Pickup::activationTypeImmediate_s)
    163162            this->activationType_ = pickupActivationType::immediate;
    164         }
    165         else if(Pickup::activationTypeOnUse_s.compare(type) == 0)
    166         {
     163        else if(type == Pickup::activationTypeOnUse_s)
    167164            this->activationType_ = pickupActivationType::onUse;
    168         }
    169165        else
    170         {
    171             orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in pickup." << endl;
    172         }
     166            orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
    173167    }
    174168
     
    181175    void Pickup::setDurationType(const std::string& type)
    182176    {
    183         if(Pickup::durationTypeOnce_s.compare(type) == 0)
    184         {
     177        if(type == Pickup::durationTypeOnce_s)
    185178            this->durationType_ = pickupDurationType::once;
    186         }
    187         else if(Pickup::durationTypeContinuous_s.compare(type) == 0)
    188         {
     179        else if(type == Pickup::durationTypeContinuous_s)
    189180            this->durationType_ = pickupDurationType::continuous;
    190         }
    191181        else
    192         {
    193             orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in pickup." << endl;
    194         }
     182            orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
    195183    }
    196184
  • code/trunk/src/modules/pickup/items/HealthPickup.cc

    r8858 r8864  
    7676    void HealthPickup::initialize(void)
    7777    {
    78         this->health_ = 0;
    79         this->healthRate_ = 0;
     78        this->health_ = 0.0f;
     79        this->healthRate_ = 0.0f;
    8080        this->healthType_ = pickupHealthType::limited;
    81         this->maxHealthSave_ = 0;
    82         this->maxHealthOverwrite_ = 0;
     81        this->maxHealthSave_ = 0.0f;
     82        this->maxHealthOverwrite_ = 0.0f;
    8383
    8484        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     
    121121
    122122        if(!this->isContinuous())
    123             this->healthRate_ = 0.0;
     123            this->healthRate_ = 0.0f;
    124124
    125125        this->initializeIdentifier();
     
    173173
    174174            // If all health has been transferred.
    175             if(this->getHealth() == 0)
     175            if(this->getHealth() == 0.0f)
    176176            {
    177177                this->setUsed(false);
     
    197197                    this->Pickupable::destroy();
    198198
    199                 float health = 0;
     199                float health = 0.0f;
    200200                switch(this->getHealthTypeDirect())
    201201                {
     
    234234                if(pawn == NULL)
    235235                {
    236                     orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << endl;
     236                    orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is '" << carrier->getIdentifier()->getName() << "' instead of Pawn." << endl;
    237237                    this->Pickupable::destroy();
    238238                    return;
     
    248248
    249249            // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
    250             if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
     250            if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0.0f))
    251251            {
    252252                this->Pickupable::destroy();
     
    267267
    268268        if(pawn == NULL)
    269         {
    270269            orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl;
    271         }
    272270
    273271        return pawn;
     
    326324    {
    327325        if(health >= 0.0f)
    328         {
    329326            this->health_ = health;
    330         }
    331327        else
    332328        {
    333             orxout(internal_error, context::pickups) << "Invalid health in HealthPickup." << endl;
    334             this->health_ = 0.0;
     329            orxout(internal_error, context::pickups) << "Invalid health '" << health << "' in HealthPickup. The health must be non.negative." << endl;
     330            this->health_ = 0.0f;
    335331        }
    336332    }
     
    344340    void HealthPickup::setHealthRate(float rate)
    345341    {
    346         if(rate >= 0)
    347         {
     342        if(rate >= 0.0f)
    348343            this->healthRate_ = rate;
    349         }
    350344        else
    351         {
    352             orxout(internal_error, context::pickups) << "Invalid healthSpeed in HealthPickup." << endl;
    353         }
     345            orxout(internal_error, context::pickups) << "Invalid healthRate '" << rate << "' in HealthPickup. The healthRate must be non-negative." << endl;
    354346    }
    355347
     
    363355    {
    364356        if(type == HealthPickup::healthTypeLimited_s)
    365         {
    366357            this->setHealthTypeDirect(pickupHealthType::limited);
    367         }
    368358        else if(type == HealthPickup::healthTypeTemporary_s)
    369         {
    370359            this->setHealthTypeDirect(pickupHealthType::temporary);
    371         }
    372360        else if(type == HealthPickup::healthTypePermanent_s)
    373         {
    374361            this->setHealthTypeDirect(pickupHealthType::permanent);
    375         }
    376362        else
    377         {
    378             orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
    379         }
     363            orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
    380364    }
    381365
  • code/trunk/src/orxonox/pickup/PickupIdentifier.cc

    r8858 r8864  
    7575        assert(this->pickup_);
    7676
    77         // 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.
     77        // 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.
    7878        if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
    7979            return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
     
    8383        if(!(this->parameters_.size() == identifier->parameters_.size()))
    8484        {
    85             orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
     85            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;
    8686            return this->parameters_.size()-identifier->parameters_.size();
    8787        }
     
    9393            if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
    9494            {
    95                 orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
     95                orxout(internal_error, context::pickups) << this->pickup_->getIdentifier()->getName() <<  " Something went wrong in PickupIdentifier!" << endl;
    9696                return -1;
    9797            }
Note: See TracChangeset for help on using the changeset viewer.