Author Topic: Found another bug with a BC function.  (Read 469 times)

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Found another bug with a BC function.
« on: July 03, 2009, 08:46:04 PM »
Didn't know exactly where to post this, so I went here since it's about a bug in BC.

Could be a good idea for Mleo to try to fix in his DiamondBC lol, or Defiant in KM... Dunno. Anyway, it's good to know so I'm posting this to warn all scripters here.


I was in-game, at the console creating a torpedo T and attaching it to a obj P (P.AttachObject(T)), trying out different values for the torpedo to see the glow and all. When I wanted to delete T, I used:
Code: [Select]
T.SetLifetime(0)
P.DetachObject(T)
To properly delete T at that moment.

One time I did that, then I closed and reopened the console to see if T had really vanished, and it did like it should, and then I typed and pressed enter:
Code: [Select]
r = T.GetRadius()To get the torp's radius, which I wanted to check something out. However when I pressed enter to get the radius, BAM!
Crash to desktop.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Found another bug with a BC function.
« Reply #1 on: July 04, 2009, 08:42:03 AM »
It's not something I (or anyone else) can truely guard against, after you delete it, it's removed from memory, meaning you are actually trying to access garbage.
I'm not even sure if a torpedo has a (real) radius, I take it it worked before you set the lifetime to 0?

You might be able to detect this if you can still retrieve it's ObjID, and then if App.IsNull(<ID>) returns 0, then it's still an ok object.

Of course, it's still a possibility that the radius is gotten from the AniNode (or something similar) and if that doesn't exist (because it doesn't have an onscreen object because the lifetime is 0) then it might also crash, in that case it might be even harder to detect.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Found another bug with a BC function.
« Reply #2 on: July 04, 2009, 12:57:08 PM »
Yea it worked before deleting the torp.

But the torp's radius is strange... First of because the relation between core and glow size;  And most importantly because it seems that the torp's radius is also dependant on the obj he's attached to. Attaching a torp (no glow, no flare, core size = 70) to a Sovereign gave it a radius of 70.71, while the Sovvie's radius is 4.xxxxx. And attaching that same torp to a planet ship (radius 743) gave the torp a radius of over 2000.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Found another bug with a BC function.
« Reply #3 on: July 04, 2009, 07:19:01 PM »
While I'm not exactly sure about this, it's possible due to some scaling thing.
Planet models are infact quite small, and are scaled up.

It's possible that this scaling does something to it's "space" (when you attach something to something else, you change it's origin, and each space has an origin).
It looks like the scale is dependent on the space the object is currently in.

Assuming the ship isn't scaled, that could also be the reason.
Then it's possible that the .71 is merely a floating point error (in whatever floating point standard Totaly Games used).
Or that it takes in account of some grow factor (I believe it's the glow that grows and shrinks, and not the core).
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.