Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 22, 2014, 2:18:47 PM (11 years ago)
Author:
noep
Message:

Removed all segfaults (or at least those we found…)

Location:
code/branches/modularships/src/orxonox/items
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc

    r10058 r10071  
    143143            switch (this->targetParam_) {
    144144            case null:
     145                if (!this->parent_->getParent()->getShipPartByName(targetName_))
     146                    return;
    145147                this->parent_->getParent()->getShipPartByName(targetName_)->setEventExecution(false);
    146148                this->parent_->getParent()->killShipPart(targetName_);
  • code/branches/modularships/src/orxonox/items/ShipPart.cc

    r10068 r10071  
    5555        this->setAlive(true);
    5656        this->setEventExecution(true);
     57        this->healthMem_ = 100;
    5758    }
    5859
     
    102103        // Remove this ShipPart from the parent.
    103104        this->parent_->removeShipPart(this);
     105        delete this;
    104106    }
    105107
     
    201203    {
    202204        this->health_ = health;
     205    }
     206
     207    void ShipPart::setAlive(bool var)
     208    {
     209        this->alive_ = var;
     210        orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl;
    203211    }
    204212
     
    236244
    237245        // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
    238         if (this->health_ < 0.2 * this->maxHealth_)
    239         {
     246        if ((this->health_ < 0.2 * this->maxHealth_) && (this->healthMem_ == 40))
     247        {
     248            this->healthMem_ = 20;
    240249            ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!");
    241250            return;
    242251        }
    243         if (this->health_ < 0.4 * this->maxHealth_)
    244         {
     252        if ((this->health_ < 0.4 * this->maxHealth_) && (this->healthMem_ == 60))
     253        {
     254            this->healthMem_ = 40;
    245255            ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!");
    246256            return;
    247257        }
    248         if (this->health_ < 0.6 * this->maxHealth_)
    249         {
     258        if ((this->health_ < 0.6 * this->maxHealth_) && (this->healthMem_ == 80))
     259        {
     260            this->healthMem_ = 60;
    250261            ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!");
    251262            return;
    252263        }
    253         if (this->health_ < 0.8 * this->maxHealth_)
    254         {
     264        if ((this->health_ < 0.8 * this->maxHealth_) && (this->healthMem_ == 100))
     265        {
     266            this->healthMem_ = 80;
    255267            ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!");
    256268            return;
  • code/branches/modularships/src/orxonox/items/ShipPart.h

    r10067 r10071  
    7272                { return this->parent_; }
    7373
    74             inline void setAlive(bool var)
    75                 { this->alive_ = var; }
     74            void setAlive(bool var);
    7675            inline bool isAlive()
    7776                { return this->alive_; }
     
    125124            bool eventExecution_;
    126125
     126            float healthMem_;
     127
    127128            Vector3 explosionPosition_;
    128129
Note: See TracChangeset for help on using the changeset viewer.