Strange code in projectile.cc
by Gonzo T. Clown · in Torque Game Engine · 04/25/2004 (8:23 am) · 19 replies
I was having problems manipulating source Objects based on their projectiles and I noticed when performing a dump from function to function that the SourceObject and SourceSlot fields were being set correctly in the initial shot, but were not being passed correctly to other functions such as "onExplode". The result was always zero for the sourceObject. Not having the sourceObject greatly limits functionality.
So in projectile.cc at line 732 we find....
My question is, is there any point to this code besides making my life miserable? The engine has been set to "SourceIdTimeoutTicks = 7;" on line 128 of projectile.h which pretty much makes the whole sourceObject field pointless for anything other than a sniperlaser or sniper bullet.
As best I can tell this has absolutely no real fuction at all and should be removed. I'm going to comment it out in my version to see if it creates any unforseen problems.
So in projectile.cc at line 732 we find....
if(mSourceObject && mCurrTick > SourceIdTimeoutTicks)
{
mSourceObject = 0;
mSourceObjectId = 0;
}My question is, is there any point to this code besides making my life miserable? The engine has been set to "SourceIdTimeoutTicks = 7;" on line 128 of projectile.h which pretty much makes the whole sourceObject field pointless for anything other than a sniperlaser or sniper bullet.
As best I can tell this has absolutely no real fuction at all and should be removed. I'm going to comment it out in my version to see if it creates any unforseen problems.
About the author
#2
That will fix the problem. I see the need for the zeroing out of the mSourceObject variable now. But the mSourceObjectId was accidentally put in there I'm pretty sure. Anyway, comment out the line and then the proper source object will be passed from state to state with the projectile.
04/25/2004 (10:23 am)
Ok, got it fixed and tested. If you'll just comment out the mSourceObjectId line like this.....if(mSourceObject && mCurrTick > SourceIdTimeoutTicks)
{
mSourceObject = 0;
//mSourceObjectId = 0;
}That will fix the problem. I see the need for the zeroing out of the mSourceObject variable now. But the mSourceObjectId was accidentally put in there I'm pretty sure. Anyway, comment out the line and then the proper source object will be passed from state to state with the projectile.
#3
"Parent::processTick(move);"
is doubled up, once at the beginning of
void Projectile::processTick(const Move* move)
on line 734 and again at line 748.
04/25/2004 (3:26 pm)
Also, "Parent::processTick(move);"
is doubled up, once at the beginning of
void Projectile::processTick(const Move* move)
on line 734 and again at line 748.
#4
04/25/2004 (3:31 pm)
Ben, is this going in the HEAD?
#5
04/25/2004 (9:07 pm)
I'll look into this monday.
#6
04/25/2004 (11:15 pm)
Robert has also looked at this. Sounds like it's a legitimate snafu. we'll be clearing this up tomorrow with any luck.
#7
If I knew how to do it, I would love to pass the projectile's "sourceObject" ID on to the explosions it spawns. That would make identifying the source of a kill much much easier than the current way which is impossible, lol.
If you pass the source ID on to the explosions, then it would be cool to pass it to the explosion debri as well. That would allow for some very simple scripting and a lot more power and versitility to the engine IMO.
04/26/2004 (7:47 am)
Ben, I know you guys are busy as hell, but if someone could just give the projectile.cc a once over and maybe clean some things up, it would be greatly appreciated.If I knew how to do it, I would love to pass the projectile's "sourceObject" ID on to the explosions it spawns. That would make identifying the source of a kill much much easier than the current way which is impossible, lol.
If you pass the source ID on to the explosions, then it would be cool to pass it to the explosion debri as well. That would allow for some very simple scripting and a lot more power and versitility to the engine IMO.
#8
04/26/2004 (9:27 am)
"We'll be clearing this up tomorrow with any luck."
#9
04/28/2004 (1:57 pm)
I'm going to be uploading some fixes I've made to the projectiles in a little bit.
#11
04/30/2004 (10:27 pm)
Robert checked in his changes afaik.
#12
05/02/2004 (3:52 am)
Hmmm, they weren't documented in the CVS change list. I'll check the head to see if there are any changes.
#13
05/02/2004 (1:02 pm)
The change list may be busted due to our recent cvs server crash.
#14
05/04/2004 (1:51 am)
The projectile changes have been uploaded, the CVS server is just not updating the changelog. Also, due to the cvs server crash you may have problems merging/diffing so be careful in that regard.
#15
at least the commented out
//mSourceObjectId = 0;
is not in my version that I synced to arround the end of september 04.
although I don't see process tick doubled up, so I guess it was worked over..
was there a reason that
mSourceObjectId = 0; was left in there?
03/01/2005 (1:42 pm)
I don't think these ever made it into cvs?at least the commented out
//mSourceObjectId = 0;
is not in my version that I synced to arround the end of september 04.
although I don't see process tick doubled up, so I guess it was worked over..
was there a reason that
mSourceObjectId = 0; was left in there?
#16
03/01/2005 (1:55 pm)
Setting the SourceObject and SourceObjectId to zero is intentional. It's only ever needed, in stock torque, for making sure the collision response does not trigger on the firing object until the projectile is a safe distance from it. It serves no other purpose.
#17
SourceIdTimeoutTicks is 7 ticks. That is it lasts 7 * 32ms or ~224ms which is enough time to ensure that the projectile does not collide with the firing object.
03/01/2005 (1:59 pm)
BTW -SourceIdTimeoutTicks is 7 ticks. That is it lasts 7 * 32ms or ~224ms which is enough time to ensure that the projectile does not collide with the firing object.
#19
08/15/2005 (12:16 pm)
So what's the verdict on this? i ended up commenting out mSourceObjectId = 0, and things work correclty now (ie. i keep track of the source object, and it doesn't lose it). Gonzo, any help here?
Associate Kyle Carter