Project

General

Profile

Bug #16087

Asteroids change shape on reload of a save

Added by Anonymous about 7 years ago. Updated about 6 years ago.

Status:
Closed
Severity:
Normal
Assignee:
-
Category:
Buildings
Target version:
Start date:
10/07/2017
% Done:

100%

Version:
Platform:
Linux, Windows
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

Reported https://forum.kerbalspaceprogram.com/index.php?/topic/166223-131-asteroid-procedural-generation-reset/
including its undesired effect on anything connected to the asteroid.

To reproduce:
Scenario "Asteroid Redirect Mission 2: ready to capture"
Screenshot asteroid
Quicksave / Reload
Note asteroid shape has changed

ARM_Asteroid2.sfs (62 KB) ARM_Asteroid2.sfs as installed in .../saves/scenarios/ Anonymous, 10/12/2017 04:57 AM
quicksave.sfs (62.7 KB) quicksave.sfs from saves/scenarios/ARM_Asteroid2 Anonymous, 10/12/2017 04:57 AM
persistent.sfs (62.7 KB) persistent.sfs from saves/scenarios/ARM_Asteroid2 Anonymous, 10/12/2017 04:58 AM
screenshot0.jpg (51.5 KB) screenshot0.jpg on starting scenario Anonymous, 10/12/2017 04:59 AM
screenshot1.jpg (51.2 KB) screenshot1.jpg after quicksave/reload Anonymous, 10/12/2017 04:59 AM
output_log.txt (550 KB) output_log.txt [email protected] Anonymous, 10/12/2017 05:05 AM
AsteroidShapeSaves.zip (193 KB) AsteroidShapeSaves.zip example_using_fresh_saves_from_1.3.1.1891 Anonymous, 10/22/2017 04:29 AM
persistent.loadmeta (267 Bytes) persistent.loadmeta [email protected] NoShadows, 12/05/2017 06:44 AM
persistent.sfs (3.32 MB) persistent.sfs [email protected] NoShadows, 12/05/2017 06:45 AM
31811
31812

History

#1 Updated by Anonymous about 7 years ago

  • Severity changed from Low to Normal

#2 Updated by Squelch about 7 years ago

  • Status changed from New to Need More Info

I am unable to reproduce. The asteroid is identical in screenshots taken before a quicksave compared to another taken after a load. Do you have mods installed? Could you please attach your logs?

#3 Updated by Squelch about 7 years ago

  • Status changed from Need More Info to Updated
  • % Done changed from 0 to 10

The forum post indicates that this is related to older saves. Asteroids do not change shape following the reproduction steps in 1.3.1.

The workaround is to load the game in 1.3.0, go to the captured asteroid, undock, and save. When this save is loaded in 1.3.1 the asteroid can be captured again without causing problems.

#4 Updated by Anonymous about 7 years ago

31811
31812

No mods. As you say, it is an issue of importing save-files from older versions.

The file ARM_Asteroid2.sfs in a fresh install happens to be the same file as shipped with 1.2.0, and has a ModuleAsteroid having an 8-digit seed = 34614706, so it was just a convenient way to make a brief bug report. Quicksave produces a quicksave.sfs with the ModuleAsteroid seed = 3.46147E+07, and a peristent.sfs with seed = 8.588609E+07.

Version 1.3.1.1836-prerelease preserved the 8-digit seed. Some save-games have bases built around asteroids, which might be impractical to bring forward to 1.3.1

#5 Updated by Anonymous about 7 years ago

The issue is not restricted to older saves.

Saves and log in the attached AsteroidShapeSaves.zip made by these steps: ====
Version 1.3.1.1891; start new sandbox game.
Tracking station; Track 6 asteroids (first two have same name)
Rename the asteroids Alpha, Beta, etc.
Vehicle Assembly Building, launch stock Ion-powered Probe
Alt-F12/SetOrbit/Rendezvous with each asteroid in turn, screenshot, save, reload, screenshot.
Alt-F12/SetOrbit/Rendezvous back to Alpha, save.
Second visit to 'Alpha' shows a different shape than the first.
--
Load the save "AtDelta"; switch craft to asteroid 'Delta' using '[' ; quicksave.
The resulting quicksave.sfs that shows a different asteroid shape on each F9 reload.

#6 Updated by allista about 7 years ago

  • Platform Linux added
  • Platform deleted (Windows)

I confirm this issue on 1.3.1 on Linux.

Asteroids do change when first loaded from 1.3.0 save.
The reason is the incorrect format in which ModuleAsteroid.seed is saved:
In 1.3.1 there's no KSPUtil.LocalizeNumber(int value, string format) method;
so when BaseListField.Save calls KSPUtil.LocalizeNumber((int)obj), the variant
with float argument gets called with implicit conversion:
KSPUtil.LocalizeNumber((float) (int) obj, string.Empty).
As the result the newly saved .sfs file contains this:

MODULE
{
    name = ModuleAsteroid
    isEnabled = True
    seed = 5.788284E+07            <===== incorrect format of the seed = 57882842 present in the original .sfs
    AsteroidName = Ast. N3559095
    prefabBaseURL = Procedural/PA_E
    currentState = 1
    stagingEnabled = True

After that the BaseField is unable to parse the value back:
Invalid integer value! Field seed, value 5.788284E+07 on object of type ModuleAsteroid
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
PDebug:Error(Object)
BaseField:ReadPvt(FieldInfo, String, Object)
BaseField:Read(String, Object)
BaseFieldList:Load(ConfigNode)
PartModule:Load(ConfigNode)
Part:LoadModule(ConfigNode, Int32&)
ProtoPartModuleSnapshot:Load(Part, Int32&)
ProtoPartSnapshot:Load(Vessel, Boolean)
ProtoVessel:LoadObjects()
Vessel:Load()
Vessel:Update()

and the seed field stays at its default value, -1, and the asteroid is regenerated with the new seed, which is also saved as float.

#7 Updated by allista about 7 years ago

  • Platform Windows added

#8 Updated by Anonymous about 7 years ago

And reiterating that the shape changes and 'Invalid integer value' errors appear in the logs from a fresh game from version 1.3.1.

#9 Updated by alukyane about 7 years ago

Confirming this for a new save in 1.3.1, on Windows 10. Other properties of the asteroid stay the same, but the shape is new every time.

#10 Updated by allista about 7 years ago

I have a temporary fix JUST for asteroids (while this bug affects much more).
It is built into the common library for my mods, AT_Utils:
https://github.com/allista/AT_Utils/releases/tag/v1.5.0
If you use any of my mods you just need to upgrade and the fix will be installed automatically.
If not, you can install just the library; then it won't do anything apart from fixing asteroids.
Requires ModuleManager though.

#11 Updated by allista about 7 years ago

Note: if you're loading a game that was already saved in 1.3.1, the fix cannot prevent the first change, but it will prevent all the next.
If, however, you have a 1.3.0 save intact, the fix will work from the first time.

#12 Updated by Squelch about 7 years ago

  • Status changed from Updated to Being Worked On
  • % Done changed from 10 to 30

Thanks for all of the information and suggested workarounds. We have identified the problem and it is being addressed.

#13 Updated by NoShadows about 7 years ago

Squelch wrote:

The forum post indicates that this is related to older saves. Asteroids do not change shape following the reproduction steps in 1.3.1.

The workaround is to load the game in 1.3.0, go to the captured asteroid, undock, and save. When this save is loaded in 1.3.1 the asteroid can be captured again without causing problems.

I have a similar problem with a game I started with 1.3.1
I Use Linux
The versal name is Asteroid it is docket to the asteroid but now the asteroid locks different

#16 Updated by Squelch almost 7 years ago

  • Status changed from Being Worked On to Ready to Test
  • Target version set to 1.4.0
  • % Done changed from 30 to 80

#17 Updated by Anonymous about 6 years ago

  • Status changed from Ready to Test to Resolved
  • % Done changed from 80 to 100

Starting in 1.4.0 and still in 1.5.1, the save-file has an un-changing 'seed' written as an integer, and asteroids stay the same shape.

#18 Updated by joshua.collins about 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF