Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12350 for code/branches


Ignore:
Timestamp:
May 9, 2019, 1:56:28 PM (6 years ago)
Author:
pomselj
Message:

Eliminated nullptrs in stones_ that were there due to wrong size of num_stones. Still Seg fault when exiting

Location:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12349 r12350  
    225225
    226226        this->activeWalls_.push_back(this->futureWall_);
    227 
    228 
    229         for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++)
     227        for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++) {
     228            if (this->futureWall_->getStone(i) == nullptr) {
     229                orxout() << "Added nullptr to std::list stones_" << endl;
     230            }
     231
    230232            this->stones_.push_back(this->futureWall_->getStone(i));
     233        }
    231234        //new location of ship
    232235        //new amount of balls
     
    235238    }
    236239
    237     void OrxoBlox::createWall(void){
     240    void OrxoBlox::createWall(){
    238241        this->futureWall_ = new OrxoBloxWall(this->center_->getContext());
    239242        // Apply the stone template to the stone.
     
    258261    }
    259262
    260     /*OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
     263    OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
    261264
    262265        orxout() << "Checking for Collision" << endl;
     
    264267        for(OrxoBloxStones* someStone : this->stones_)
    265268        {
     269            if(someStone == nullptr)
     270            {
     271                continue;
     272            }
    266273            orxout() << "Checking a stone" << endl;
    267274            const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
    268275            int size = someStone->getSize();
    269             if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) ||
     276            if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) &&
    270277                (BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) {
    271278                orxout() << "FOUND ONE" << endl;
     
    275282        orxout() << "Found nothing...." << endl;
    276283        return nullptr;
    277     }*/
     284    }
    278285   
    279286}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12349 r12350  
    149149                // Set the ball to be exactly at the boundary.
    150150                position.z = this-> fieldHeight_ / 2;
    151                 // Set the velocity to zero
    152151               
    153152                orxoblox_->LevelUp();
     
    212211        if (position != this->getPosition())
    213212            this->setPosition(position);
    214         //this->Collides((this->orxoblox_->CheckForCollision(this)));
     213        this->Collides((this->orxoblox_->CheckForCollision(this)));
    215214
    216215 
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc

    r12346 r12350  
    2929
    3030
    31     void OrxoBloxWall::createWall(void){
     31    void OrxoBloxWall::createWall(){
    3232        for (unsigned int i=0; i<this->num_Stones_;++i){
    3333            unsigned int j=1 + static_cast<unsigned int>(rnd(2.0f)); //<! random number between 0 and 2;
     
    3535                this->size_ = 9.0f;
    3636                OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
     37                if (stone == nullptr) {
     38                    std::abort();
     39                }
    3740                this->TotalStones_.push_back(stone);
    3841                this->attach(stone);
     
    5659
    5760        }
     61
     62        this->num_Stones_ = TotalStones_.size();
    5863
    5964
Note: See TracChangeset for help on using the changeset viewer.