[Orxonox-commit 7758] r12350 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
pomselj at orxonox.net
pomselj at orxonox.net
Thu May 9 13:56:28 CEST 2019
Author: pomselj
Date: 2019-05-09 13:56:28 +0200 (Thu, 09 May 2019)
New Revision: 12350
Modified:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
Log:
Eliminated nullptrs in stones_ that were there due to wrong size of num_stones. Still Seg fault when exiting
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-05-09 11:33:42 UTC (rev 12349)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-05-09 11:56:28 UTC (rev 12350)
@@ -224,10 +224,13 @@
}
this->activeWalls_.push_back(this->futureWall_);
+ for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++) {
+ if (this->futureWall_->getStone(i) == nullptr) {
+ orxout() << "Added nullptr to std::list stones_" << endl;
+ }
-
- for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++)
this->stones_.push_back(this->futureWall_->getStone(i));
+ }
//new location of ship
//new amount of balls
//create balls
@@ -234,7 +237,7 @@
//insert new wall
}
- void OrxoBlox::createWall(void){
+ void OrxoBlox::createWall(){
this->futureWall_ = new OrxoBloxWall(this->center_->getContext());
// Apply the stone template to the stone.
this->futureWall_->addTemplate(this->center_->getWallTemplate());
@@ -257,16 +260,20 @@
this->ball_->setSpeed(this->center_->getBallSpeed());
}
- /*OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
+ OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
orxout() << "Checking for Collision" << endl;
Vector3 BallPosition = Ball->getPosition();
for(OrxoBloxStones* someStone : this->stones_)
{
+ if(someStone == nullptr)
+ {
+ continue;
+ }
orxout() << "Checking a stone" << endl;
const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
int size = someStone->getSize();
- if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) ||
+ if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) &&
(BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) {
orxout() << "FOUND ONE" << endl;
return someStone;
@@ -274,6 +281,6 @@
}
orxout() << "Found nothing...." << endl;
return nullptr;
- }*/
+ }
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-09 11:33:42 UTC (rev 12349)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-09 11:56:28 UTC (rev 12350)
@@ -148,7 +148,6 @@
if (position.z > this->fieldHeight_ / 2){
// Set the ball to be exactly at the boundary.
position.z = this-> fieldHeight_ / 2;
- // Set the velocity to zero
orxoblox_->LevelUp();
@@ -211,7 +210,7 @@
this->setVelocity(velocity);
if (position != this->getPosition())
this->setPosition(position);
- //this->Collides((this->orxoblox_->CheckForCollision(this)));
+ this->Collides((this->orxoblox_->CheckForCollision(this)));
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc 2019-05-09 11:33:42 UTC (rev 12349)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc 2019-05-09 11:56:28 UTC (rev 12350)
@@ -28,12 +28,15 @@
}
- void OrxoBloxWall::createWall(void){
+ void OrxoBloxWall::createWall(){
for (unsigned int i=0; i<this->num_Stones_;++i){
unsigned int j=1 + static_cast<unsigned int>(rnd(2.0f)); //<! random number between 0 and 2;
if(j<2){
this->size_ = 9.0f;
OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
+ if (stone == nullptr) {
+ std::abort();
+ }
this->TotalStones_.push_back(stone);
this->attach(stone);
float x_=(this->center_->getFieldDimension()).x;
@@ -56,8 +59,10 @@
}
+ this->num_Stones_ = TotalStones_.size();
+
// OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
// if(this->orxoblox_ != nullptr)
// {
More information about the Orxonox-commit
mailing list