Changeset 8864 for code/trunk/src/modules
- Timestamp:
- Aug 24, 2011, 2:57:53 PM (13 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/Pickup.cc
r8858 r8864 159 159 void Pickup::setActivationType(const std::string& type) 160 160 { 161 if(Pickup::activationTypeImmediate_s.compare(type) == 0) 162 { 161 if(type == Pickup::activationTypeImmediate_s) 163 162 this->activationType_ = pickupActivationType::immediate; 164 } 165 else if(Pickup::activationTypeOnUse_s.compare(type) == 0) 166 { 163 else if(type == Pickup::activationTypeOnUse_s) 167 164 this->activationType_ = pickupActivationType::onUse; 168 }169 165 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; 173 167 } 174 168 … … 181 175 void Pickup::setDurationType(const std::string& type) 182 176 { 183 if(Pickup::durationTypeOnce_s.compare(type) == 0) 184 { 177 if(type == Pickup::durationTypeOnce_s) 185 178 this->durationType_ = pickupDurationType::once; 186 } 187 else if(Pickup::durationTypeContinuous_s.compare(type) == 0) 188 { 179 else if(type == Pickup::durationTypeContinuous_s) 189 180 this->durationType_ = pickupDurationType::continuous; 190 }191 181 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; 195 183 } 196 184 -
code/trunk/src/modules/pickup/items/HealthPickup.cc
r8858 r8864 76 76 void HealthPickup::initialize(void) 77 77 { 78 this->health_ = 0 ;79 this->healthRate_ = 0 ;78 this->health_ = 0.0f; 79 this->healthRate_ = 0.0f; 80 80 this->healthType_ = pickupHealthType::limited; 81 this->maxHealthSave_ = 0 ;82 this->maxHealthOverwrite_ = 0 ;81 this->maxHealthSave_ = 0.0f; 82 this->maxHealthOverwrite_ = 0.0f; 83 83 84 84 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); … … 121 121 122 122 if(!this->isContinuous()) 123 this->healthRate_ = 0.0 ;123 this->healthRate_ = 0.0f; 124 124 125 125 this->initializeIdentifier(); … … 173 173 174 174 // If all health has been transferred. 175 if(this->getHealth() == 0 )175 if(this->getHealth() == 0.0f) 176 176 { 177 177 this->setUsed(false); … … 197 197 this->Pickupable::destroy(); 198 198 199 float health = 0 ;199 float health = 0.0f; 200 200 switch(this->getHealthTypeDirect()) 201 201 { … … 234 234 if(pawn == NULL) 235 235 { 236 orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is noPawn." << endl;236 orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is '" << carrier->getIdentifier()->getName() << "' instead of Pawn." << endl; 237 237 this->Pickupable::destroy(); 238 238 return; … … 248 248 249 249 // 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)) 251 251 { 252 252 this->Pickupable::destroy(); … … 267 267 268 268 if(pawn == NULL) 269 {270 269 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl; 271 }272 270 273 271 return pawn; … … 326 324 { 327 325 if(health >= 0.0f) 328 {329 326 this->health_ = health; 330 }331 327 else 332 328 { 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; 335 331 } 336 332 } … … 344 340 void HealthPickup::setHealthRate(float rate) 345 341 { 346 if(rate >= 0) 347 { 342 if(rate >= 0.0f) 348 343 this->healthRate_ = rate; 349 }350 344 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; 354 346 } 355 347 … … 363 355 { 364 356 if(type == HealthPickup::healthTypeLimited_s) 365 {366 357 this->setHealthTypeDirect(pickupHealthType::limited); 367 }368 358 else if(type == HealthPickup::healthTypeTemporary_s) 369 {370 359 this->setHealthTypeDirect(pickupHealthType::temporary); 371 }372 360 else if(type == HealthPickup::healthTypePermanent_s) 373 {374 361 this->setHealthTypeDirect(pickupHealthType::permanent); 375 }376 362 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; 380 364 } 381 365
Note: See TracChangeset
for help on using the changeset viewer.