Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Improving output.

Location:
code/trunk/src/modules/pickup
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.