Bug #16087
Asteroids change shape on reload of a save
100%
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
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
- File ARM_Asteroid2.sfs ARM_Asteroid2.sfs added
- File quicksave.sfs quicksave.sfs added
- File persistent.sfs persistent.sfs added
- File screenshot0.jpg screenshot0.jpg added
- File screenshot1.jpg screenshot1.jpg added
- File output_log.txt output_log.txt added
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
- File AsteroidShapeSaves.zip AsteroidShapeSaves.zip added
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
- File persistent.loadmeta persistent.loadmeta added
- File persistent.sfs persistent.sfs added
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