Page 2 of 4

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 4:28 pm
by x3n
i assume the rocket gets destroyed if it hits something, but it doesn't delete the controller. so when the controller tries to delete the rocket, the pointer isn't valid anymore. so you probably have to delete the controller in the destructor of SimpleRocket.

i know it's a mess, because there's usually a player associated to a controllable entity which manages both controller and the entity. but in this case there's no player, so we need some workarounds ;)


i don't know why the rocket isn't visible. maybe it gets destroyed right after it spawns? add some debug output to the constructor and the destructor of simplerocket, so you can see when it gets created and destroyed.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 02, 2010 11:35 am
by tyderion
ah that with the output is a good idea, why didn't I think of this?

If I try to destroy the controller of the simplerocket in the destructor of the simplerocket (delete this->getController()) then orxonox cannot start, it seems to destroy one SimpleRocket while starting...
again i've attached a screenshot and committed this version.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 02, 2010 6:13 pm
by greenman
this is probably because of the factory creation (mentioned in the introduction). you need to check whether the controller is 0 or not and (in the ctor of the rocket) set the ctroller pointer to 0 by default

Code: Select all

if( this->controller_ ) delete this->controller_
something like this

also: i saw that you do delete this in the RocketController destructor. this is always a bad idea and probably just a mistake ;)

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 02, 2010 7:54 pm
by tyderion
ah yes I wanted to use something like

Code: Select all

if( this->controller_ ) delete this->controller_
but it tells me I cannot access this private variable.
I used

Code: Select all

if (this->hasLocalController()) delete this->getController();
but Orxonox still crashes while starting...

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 02, 2010 7:59 pm
by x3n
yes, orxonox creates and destroys one instance of each object on startup. however the constructor stops at RegisterObject(...), so you can't initialize your object.

try this in the destructor:

Code: Select all

SimpleRocket::~SimpleRocket()
{
    if (this->isInitialized())
    {
        COUT(0)<< "simplerocket destroyed\n";
        delete this->getController();
    }
}
isInitialized() is an inherited function from BaseObject

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 02, 2010 9:03 pm
by tyderion
ah now Orxonox can start again.
but the rocket still isn't visible after constructing it (controller as well as rocket get successfully constructed as well as destroyed when going back to the mainmenu.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Mon May 03, 2010 9:21 am
by greenman
i made some changes and the rocket is visible now
however the "spawnpoint", the velocity and the scaling are still wrong

had to change setMeshSource("Rocket.mesh") to "rocket.mesh" but i think this was not a problem on windows

Re: Rocket-Ticket Questionthread (... haha)

Posted: Mon May 03, 2010 10:04 am
by tyderion
cool. For me up to now the important thing has been to get the rocket to spawn. Now that that works I hope I can progress faster :)

thank you very much :)

Re: Rocket-Ticket Questionthread (... haha)

Posted: Mon May 03, 2010 11:45 am
by tyderion
okay the first step is done. The rocket spawns near the spaceship.
I'll post again if I get stuck (and I'm sure I will ...)
thanks again

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri May 07, 2010 2:15 pm
by tyderion
Ok I ran into the next problem.
When i invoke "destroy()" from the Simplerocket (or from the rocketcontroller) orxonox crashes.
If I don't invoke destroy() the rocket doesn't get destructed even though it crashes with things (e.g. a drone) and explodes.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri May 07, 2010 4:18 pm
by greenman
without a backtrace (orxonox_crash.log) it's hard to say, but do you have any references to the rocketcontroller (not in the simplerocket) which are invalid when you destroy the rocket (and also the controller) ?

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri May 07, 2010 5:15 pm
by tyderion
hmm I can't find this file... (orxonox_crash.log).
Right now I am looking for references to the controller.
When I construct the controller in the function SimpleRocketFire.fire() I use a pointer but this pointer isn't existing anymore later is it? (I'm a bit confused :? )

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 09, 2010 2:58 pm
by greenman
the file is in build/log/orxonox_crash.log

about the pointer it depends. as long as you don't delete (or destroy) the controller the pointer is valid, or what exactly do you mean?

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sun May 09, 2010 6:08 pm
by x3n
the file doesn't exist on windows. on linux, see greenmans post.

i suggest to visit us in the PPS tomorrow, this makes it easier for us to reproduce and debug the problem.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Mon May 10, 2010 1:39 pm
by greenman
fixed a problem with the rocket

it successfully collides against an asteroid now (not yet tested with bots)