Blaarkies / ksp-visual-calculator

Online tool for Kerbal Space Program that helps players determine delta-v requirements for a mission, and what type of comms dishes a certain satellite requires.
https://ksp-visual-calculator.blaarkies.com
Other
23 stars 0 forks source link

import & reload fails #24

Closed radlerandi closed 3 years ago

radlerandi commented 3 years ago

Hello, i discovered this nice app yesterday and place some probes and relais stations at the orbits, saved, exported, but i'm not able to reload or import the json file. The save says: Last saved -89 days ago, Celestial bodies 17, Craft 6 but no craft is added to the screen when i press play or import the json file.

browser is Chrome with some addons. i tested with uBlock disabled, no difference. Do i make something wrong or is there a problem?

Also for my understanding: Which connection to Kerbal is used when there are multiple ones, the direct connection to Kerbal or a relais link with better connection percents?

Blaarkies commented 3 years ago

Hi @radlerandi

Sorry for that inconvenience. What you described is the correct course of actions to export a savegame to JSON and then import it again, it should work. Did it show any errors when importing the file? The notification bar at the bottom might show the error that it is encountering, or maybe the Chrome DevTools will show something if you are familiar with that (Press ctrl+shift+i to open it)

I have a suspicion that the savegame names are clashing. It is supposed to overwrite the existing savegame in your "Manage Savegames" window, and replace it with whatever is in the file. Will you please try the following:

  1. Delete/rename that savegame in the "Manage Savegames" window
  2. Load a different savegame, or Reset (start a new savegame)
  3. Import the previous JSON file
  4. It should immediately load up that savegame when it is imported

If that didn't work, I would find it very useful to get my hands on that JSON file for debugging whatever the cause isπŸ˜…

Which connection to Kerbal is used when...

In-game, the networks seems to prefer a direct connection to Kerbin (even if a relay connection would be stronger). In this app, the view perspective is a bit different, since you can look at all satellites at the same time: The signal lines in KSP Visual Calculator show all valid connections in a point-to-point format. To know if a satellite can communicate to Kerbin, you need to follow the signal lines back to Kerbin:

radlerandi commented 3 years ago

thanks for your quick answer. Indeed DevTools is showing errors on importing json to a new session or into archive:

main.83f6216fd5a0a6404824.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'draggableHandle' of undefined TypeError: Cannot read property 'draggableHandle' of undefined at main.83f6216fd5a0a6404824.js:1 at Array.map () at XI.setChildren (main.83f6216fd5a0a6404824.js:1) at main.83f6216fd5a0a6404824.js:1 at Array.forEach () at e (main.83f6216fd5a0a6404824.js:1) at main.83f6216fd5a0a6404824.js:1 at c._tapNext (main.83f6216fd5a0a6404824.js:1) at c._next (main.83f6216fd5a0a6404824.js:1) at c.next (main.83f6216fd5a0a6404824.js:1) at Z (polyfills.00096ed7d93ed26ee6df.js:1) at polyfills.00096ed7d93ed26ee6df.js:1 at a (main.83f6216fd5a0a6404824.js:1) at l.invoke (polyfills.00096ed7d93ed26ee6df.js:1) at Object.onInvoke (main.83f6216fd5a0a6404824.js:1) at l.invoke (polyfills.00096ed7d93ed26ee6df.js:1) at i.run (polyfills.00096ed7d93ed26ee6df.js:1) at polyfills.00096ed7d93ed26ee6df.js:1 at l.invokeTask (polyfills.00096ed7d93ed26ee6df.js:1) at Object.onInvokeTask (main.83f6216fd5a0a6404824.js:1)

I started from scratch for testing and until now some small constellations with 4 probes will load and import, but not my previous save file.

ksp-cp-savegame- k50g6309q1q56d67u-test.json.txt ksp-cp-savegame- h0s651hlgv1cqrght Duna Relay Network.json.txt

the second one, Duna Reley Network, is the one that is not loading.

Blaarkies commented 3 years ago

I took a quick look at importing the duna-relay-network file and it seems to have a problem with the "Untitled Space Craft" while rebuilding the state (converting the JSON data back into what we see in the app). Is there anything different about this craft, compared to the others?

image

I will need to do some proper debugging to get to the bottom of this one. This last week I have been filling up any test cases I might have missed initially, and this one is definitely going on the list 😁

Blaarkies commented 3 years ago

Found it! I can't believe how simple it is, or how i missed it. This is what causes the issue:

To fix the file, I just removed the "Untitled Space Craft" entry. This is obviously just temporary, I hope it helps until a fix is deployed. Duna Relay Network fixed savegame

I will deploy the fix for this one (and then close this issue) with the upcoming release (it adds lots of unit tests that pointed out lots of small issues that got fixed, and e2e tests that should ensure more stability).

For interest ‡ The issue in source code is here, it is missing a command to remove the craft from the hierarchy structure: https://github.com/Blaarkies/ksp-visual-calculator/blob/b401a8f15260afb7346032b9bfe1a0357f6f8115/src/app/services/space-object.service.ts#L244-L246

radlerandi commented 3 years ago

Nice! I'm glad you found the error :)

just one follow up question to my question of the relay network: I want to get more science points by delivering it over a better connection than direct transmission from the vessel, so i want to place these relay network satellites. But you said, when the vessel with the science data has a connection by itself to Kerbin it will not use the better connection over the network and i will not get a science bonus? I'm quite new to the game (40h) and want to get as much science as i can.

if i can not improve the science bonus i guess it is sufficient to use smaller relay antennas or to ditch the network completely.

Blaarkies commented 3 years ago

No problem at all, happy to help 😊 In Kerbal Space Program, while controlling a satellite, you can hover the mouse in the top left corner of the screen on the signal indicator (4 bars, looks like cellphone reception). This will show the percentage value of the current connection all the way to Kerbin:

image

According to KSP Wiki - CommNet where I got most of the info concerning communication networks

The game always favors a direct connection to Kerbin even if a more powerful relay is nearby.

One way to get around that, is to have your science-gathering-craft only have a simple Communitron-16 antenna onboard (little stick antenna with the red tip). This way it is too weak for a direct Kerbin connection, but will easily relay through an orbiting satellite equipped with a RA-2 Relay antenna. To get a near 100% signal back to Kerbin, you would need many RA-100 antennae on a single satellite...it is possible to construct such ship in orbit, but a bit impractical.

My advice would be to not worry about it too muchπŸ˜…, there's like 5 times as much science in the Jool system alone (green gas giant planet, a Jupiter analogue), and it is most fun exploring these while still hunting for more science and technology to unlock. There's some threads on the ksp forums that could explain the exact nature of science transmission? I just tend to do missions where I always return the craft because of Kerbals onboard, then you get the full science reward

Blaarkies commented 3 years ago

This fix has been deployed with the new release, more info at forum post

Thanks again for helping on this one 😊