Jump to content

CommNet.CommLink return, sometimes, false information


Recommended Posts

While developing a new feature for my mod Antenna Helper I came across a bug in the CommLink list attached to each vessel.

In order to get the "real signal strength" of a vessel I need to multiply the signal strength of each link in the path between this vessel and the DSN. I do it like this :



foreach (Vessel v in FlightGlobals.Vessels) {

	double realSignal = 1d;

	foreach (CommNet.CommLink link in v.Connection.ControlPath) {

		realSignal *= link.signalStrength;
	}
}

And it works good, most of the time, sometimes the link.signalStrength is off, still in the 0 - 1 range but wrong according to the in-flight display :

  • in flight : it's always accurate
  • at the space center :
    * when coming from the main menu : accurate most of the time
    * when coming from the editor or the tracking station : always accurate
    * when coming from flight : always wrong
  • at the Tracking Station :
    * first time entering it : accurate most of the time
    * n+1 time entering it : always wrong

At first I believed I was getting the info too early, before the CommNet gets properly initialized, but even with a coroutine that wait 10s before retrieving the signal strength it was still off.

For a proper testing I wrote a little plugin that display all the link of all the vessel when a CommNet event is fired (only three exist : OnNetworkInitialized, OnCommStatusChange and OnCommHomeStatusChange), the plugin also display the link when pressing X.

You can find it, along with its source, here. (Launch a game, open the console and look for entry starting by "[CommTry]")

This save can be helpful, it has three ships, relay_A (signal of : 66%), relay_B (signal of : 36%) and transmitter (connected to relay_B : 69%, combined : 25%).

 

I wanted to bring it to the attention of the forum before writing a proper bug report, I check and it haven't been reported. But @TaxiService made a bug report about incorrect value in the CommNet instance. This may be connect to my issue but not sure : in the CommNet instance, values are always off (and way off, not even in the 0 - 1 range) but in the Vessel.Connection.ControlPath.CommLink they are sometimes valid...

@TaxiService your issue still stand, I add a method to test it in my plugin, press Y and it list all the existing links (from CommNet.CommNetNetwork.Instance.CommNet.Links).

Pinging @RoverDude, he was assigned @TaxiService issue.

 

Link to comment
Share on other sites

Hi Li0n,

On KSP 1.3.1.1891 (with DebugStuff, MM, StockRTAntennas and CommNetTry), I ran some of your scenarios that should give incorrect values but the values are always same on my side no matter what I tried.

sPsSTYj.png

Can you check if I performed the tests correctly?

P.S. The bug I reported in the bug tracker is due to the incorrect assignment logic. It has nothing to do with your bug.

Link to comment
Share on other sites

@TaxiService thanks for testing it. I've remade a test and can (re-)confirm :

YoHv0Ql.png

How to reproduce :

  1. Launch a save
  2. go to the tracking station
  3. back to the space center
  4. tracking station again

This steps always reproduce the issue.

I've made my test on Windows 10 x64 with the last version of KSP (x64). The install is clean, nothing except my CommTry.dll

Link to comment
Share on other sites

I've done a little more testing and find a way to reset the CommPath/Link to its "real" values (in the Tracking Station), one vessel at a time.

When focusing a vessel its CommPath gets updated, no event is fired but the values do change.

TZAbn8K.png

As you can see after focusing the vessel "Transmitter" its links show the "real" values. But it's not updated "recursively", the link attached to the relay this connection depend on isn't updated. Not sure that's clear, in the screenshot the two links underlined in red represent the same thing and should be equal.

How to reproduce this :

  1. launch the save I provided earlier
  2. go to the tracking station
  3. go back to the space center
  4. again to the tracking station
  5. open the console
  6. press X
  7. In the console you'll see a list of vessel and theirs links, one link per vessel, all green (the first CommTry block in the screenshot)
  8. Click on the "Transmitter" in the vessel list
  9. press X
  10. the transmitter links are updated but not the relay it depends on

 

I also found a CommNet.CommNetNetwork.Reset () method, unfortunately it doesn't solve this problem.

 

 

EDIT :

With my last discovery I found a workaround on how to get accurate signal strength of all the vessel in the tracking station : I set the PlanetariumCamera target to every vessel, then back to its original target. Doing this in one frame is transparent to the user and I am, relatively, sure that I get the right number.

Edited by Li0n
Link to comment
Share on other sites

Glad that you managed to find this workaround.

I managed to reproduce the bug but only in the official release build, KSP_x64. It is not there in the unity dev build, KSP_x64_Dbg. Both builds are same in file and product versions though.

I am not sure why the release build gives inaccurate values.

Link to comment
Share on other sites

23 minutes ago, TaxiService said:

I managed to reproduce the bug but only in the official release build, KSP_x64. It is not there in the unity dev build, KSP_x64_Dbg. Both builds are same in file and product versions though.

What's the unity dev build ?

For the way to reproduce it, after way more testing, I'm not sure anymore. I think I got the wrong values in all situation : Flight, Tracking Station and Space Center. It appears very often in the tracking station, never the first time tho. Very infrequently in Flight.

27 minutes ago, TaxiService said:

Glad that you managed to find this workaround.

Me too :D

How I implement it in the last version of Antenna Helper :

  • wait for GameEvents.CommNet.CommStatusChange to fire
  • wait .1s
  • focus the camera on the vessel that fire this event
  • The values are now correct

If one step is missing it, may, not works. :(

Link to comment
Share on other sites

1 hour ago, Li0n said:

What's the unity dev build ?

It is the unity player window exe came with the standard Unity installation per the thread on the debugging environment. 

Spoiler
  • First you need a Unity installation using the exact same version as your current KSP (For 1.1 you need Unity 5.2.4f1). That version is in the first line of the output_log.txt/Player.log.
  • Go to your Unity install for that version ( "C:\Program Files\Unity\Editor" most likely) and then go in the "Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_development_mono" sub-directory. Copy the "player_win.exe" file to your KSP dev install (next to KSP.exe)
  • Rename that "player_win.exe" to "KSP_x64_Dbg.exe"

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...