-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add back isStar to GetBodyReferencing #20
Conversation
For the previous code to pass, the vessel's mainBody would have to be the sun (not a planet directly orbiting the sun) and the sun would have to not be a star, which is impossible.
This looks good to me, I was about to do this myself but you beat me to it by a good 18 hours... lol. I'll accept this merge, and build a release off of it. |
What are you thinking here ? |
I wasn't too sure upon the usage of the |
Ugh, this is what I get for trying to rush-merge something while at work. Sorry. "Overloading KSPs default GetBodyReferencing() seems very awkward, so probably best to simply make a localStar() function that does not stop the loop early, but goes to the first found star." That would be the right way to do this. As this is, I have a strong feeling this may actually break atmospheric temps on planets again, I will test when I get home. I tested it via remote desktop briefly and it looked correct but I'm not even certain I was using the correct build. Sorry for being overeager there. |
Proposal: What if we just fixed the one function that seems to need this special use case of looking for a star, the one under // Get Thermal Stats? Like this? if (sun == GetBodyReferencing(vessel.mainBody.referenceBody)) EDIT: A quick test indicates this works: https://img.techpowerup.org/200720/screenshot58.jpg I will implement it on my bleeding edge branch first, before pushing it to main this time. |
Wouldn't that pass |
"Wouldn't that pass null to GetBodyReferencing if the vessel is orbiting the Sun?" Yeah, I thought about that, but thought it should be ok, it should get shutdown here: The GetBodyReferencing code:
"while (body?.orbit?.referenceBody != null " for the nullcheck that should stop trouble. Which would then return back body, AKA the star it's orbiting. Or am I wrong somewhere? It's been a long day. I guess a quick test case would be to teleport to the sun and see? Actually, I think you might be right, because we are calling methods on Null and that is never good. My brain is just dead, lol. |
Or maybe I'm right, dunno. I just tested it in Solar orbit and no null refs to be found? Actually, it seems to be behaving perfectly. Test on my branch if you'd like. It's in the latest release (as are your particles democat3457!) github.com/R-T-B/Kopernicus/ |
Actually, you are correct with the
still applies. With the current logic, a vessel orbiting the Mun wouldn't pass the check because the method passes Kerbin, of which the method will return Kerbin, not the Sun. |
Will look into that soon, thanks. Does seem logical. There are various ways to fix that, of course. I'll push an attempt to bleeding this evening. |
It was absent in Kopernicus 1.8.1, appearing only in the panelsFix branch not any release, so there should be no-one depending on it. Having this subtly-different override of a KSP function seems unwise.
Well, this is a very roundabout way of getting things right only sometimes. Someday I will update my gcc to this newfangled C#, but it will take a while to learn. |
This should work, though, right? @Keith-OHara
|
I think so. Compared to an inline search straight to that star
with whatever null-pointer checks are needed and idiomatic in C#, maybe |
If it's used for one purpose and only once, then yes, it is confusing. However, since the method's intent is very similar to that of |
"It was absent in Kopernicus 1.8.1, appearing only in the panelsFix branch not any release, so there should be no-one depending on it. Having this subtly-different override of a KSP function seems unwise." As mentioned in the bug report, I agree. We need a dedicated function that is not an overload. I propose further discussion of this issue is moved to the bug report. We are splitting dialog pretty bad. |
#19