Page 1 of 1

Illegal division by zero

PostPosted: Sat Jun 30, 2007 9:53 am
by Troodon
Hi
I get this error when I turn the engines on in my rocket launch project: "Illegal division by zero in draw actor of smoke".
Here is the draw actor of smoke and I don't see there illegal division:

Code: Select all
angle = (Rocket.animpos/Rocket.nframes)*360.0;
directional_velocity = -6;

PostPosted: Sat Jun 30, 2007 11:59 am
by DocRabbit
Rocket.nframes would be the most likely candidate here. I would create a text actor and check the values of it and see if you get a zero.

Another way is you could wrap it with an IF statement like this:

Code: Select all
if(Rocket.nframes!=0)
{
...
}


That would prevent it from using a zero in the division area.
Don't know what it would do with the rest of your program, just try and see it affects it in a negative way.

PostPosted: Sat Jun 30, 2007 2:27 pm
by Oman
wat does if (something != number meane... (i mean, what does the != do?

PostPosted: Sat Jun 30, 2007 2:41 pm
by Kodo
!= means 'not equal to'

PostPosted: Sat Jun 30, 2007 2:43 pm
by metal_pt
Means:
if (something is different from something else)
It is like <> in other script laguages.

PostPosted: Sat Jun 30, 2007 2:57 pm
by DocRabbit
Off the subject but funny none the less...

Doing a google search for != vs == yielded the top link to Victoria's Secret website. :lol:

Would have thought it would have been something in C or Java...

PostPosted: Sat Jun 30, 2007 10:25 pm
by Fuzzy
append 0.0001 to the frame number just for the division.

angle = (Rocket.animpos/(Rocket.nframes+0.0001))*360.0;

PostPosted: Sun Jul 01, 2007 5:12 am
by Troodon
Well...I found no errors in that code so the error object display must have been a bug. I tested the whole formula with text actors and it works. The problem became after I inserted this lines of code.

Code: Select all
if (burning == 1 && strcmp(tankstatus, "closed") == 0)
{
    DAMAGE = 1;
}

PostPosted: Sun Jul 01, 2007 12:52 pm
by DocRabbit
maybe it stems from a null or zero length string in tankstatus variable. I am sure that strcmp uses the length of in its calculations, so that may be where it is at. Maybe initialize tankstatus with content that won't trigger any of your checks, but will fill it with something. Also, may be try this in place of code you have, just in case. Should not make a difference, but you never know.

Code: Select all
if (burning == 1 && !strcmp(tankstatus, "closed"))
{
    DAMAGE = 1;
}

PostPosted: Sun Jul 01, 2007 4:51 pm
by Troodon
Thanks for the help guys (or/and ladies) but nothing suggested yet haven't work. As you can see from my signature, I'll be off for a week.
I could send the project to someone but it's still very complicated (complex rocket launching system what is controlled by multifunctional displays where you enter commands). Because it's not ready yet, I should write a manual to the tester just to be able to see the error. :P
See you after one week!