Jump to content

Kerbal Construction Time/StageRecovery Dev Thread


magico13

Recommended Posts

For some reason it looks like it's swapping in the KCT save and then the game is saving. That's definitely not right. If I get a chance I'll try to take a look at it myself tonight. Thanks for testing that for me. If I weren't at work I'd test it myself right now.

No problem. Just found this; it might or might not be related.

When 'newMethod' is false it seems this line is commented out (and/or maybe missing in the newMethod=false path):

//GamePersistence.LoadGame("KCT_simulation_backup", HighLogic.SaveFolder, true, false);

At one place in gameSceneEvent there is a line left that says this:

KCT_Utilities.LoadSimulationSave(false);

Edit:

After some more random searching, this bit of code looks 'suspect':

        public void TechDisableEvent()
{
if (KCT_PresetManager.Instance != null && KCT_PresetManager.Instance.ActivePreset != null)
{
if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUnlockTimes && KCT_PresetManager.Instance.ActivePreset.generalSettings.BuildTimes)
{
foreach (KCT_TechItem tech in KCT_GameStates.TechList)
{
tech.DisableTech();
}
//Need to somehow update the R&D instance
GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
}
}
}

Edited by Rodhern
Link to comment
Share on other sites

I am using KCT dev version along with RO dev and RP-0 pre6 for testing. However if you conduct an experiment and transmit it during a simulation KCT doesn't reverse it. So it's like you've done the experiment in normal game.

Edit: oh and it is amazing with RP-0 preset, thanks magico13 :)

Edit 2: I've just noticed that simulation actually doesn't work at all. You can complete contracts as well as science experiments. It still has a timer and costs funds to start simulation, but apart from that it doesn't work.

Edited by batuhantasli
Link to comment
Share on other sites

Edit 2: I've just noticed that simulation actually doesn't work at all. You can complete contracts as well as science experiments. It still has a timer and costs funds to start simulation, but apart from that it doesn't work.

I am reasonably convinced that what is needed is an exception to the SaveGame in TechDisableEvent() for those circumstances where the scene change is a revert after ending a simulation. All in all what happens is that you don't really revert after ended simulation because the save game is overwritten. Guess that is good news, because that probably means there is only one issue to solve :-)

Link to comment
Share on other sites

I am using KCT dev version along with RO dev and RP-0 pre6 for testing. However if you conduct an experiment and transmit it during a simulation KCT doesn't reverse it. So it's like you've done the experiment in normal game.

Edit: oh and it is amazing with RP-0 preset, thanks magico13 :)

Edit 2: I've just noticed that simulation actually doesn't work at all. You can complete contracts as well as science experiments. It still has a timer and costs funds to start simulation, but apart from that it doesn't work.

The current topic of discussion is actually that simulations don't appear to be working at all. When I get home from work I'll make it top priority. Thanks for the report and being patient :)

As for the RP-0 Preset, that's all (mostly) NathanKell. Expect some changes to it when he gets a chance to play around with more of the settings.

I think I got some null reference exceptions (from KerbalConstructionTime.KCT_Events.gameSceneEvent (GameScenes scene)) when visiting the KSP settings screen after exiting a career.

I'll add it to my list, hopefully related to the other issues you're seeing. Two bugs are less fun than one :P

E: The reason that save command was added was to get around the fact that when you close the RnD screen after purchasing a node, the game thinks that you still have those nodes unlocked, but KCT gives you points for the nodes that are in progress, meaning it double counts until the next save. My shortcut was to just save it manually. Apparently that has the fun side effect of breaking everything!

Edited by magico13
Link to comment
Share on other sites

I'll add it to my list, hopefully related to the other issues you're seeing. Two bugs are less fun than one :P

I made a coarse hack on my system, adding this at the top of gameSceneEvent:

if (scene == GameScenes.SETTINGS)
return;

Don't know if it breaks everything, but it seems to fix the settings issue :-) [at least now you have an idea where the bug is].

E: The reason that save command was added was to get around the fact that when you close the RnD screen after purchasing a node, the game thinks that you still have those nodes unlocked, but KCT gives you points for the nodes that are in progress, meaning it double counts until the next save. My shortcut was to just save it manually. Apparently that has the fun side effect of breaking everything!

Ok, cool. I guess that means that you can safely omit the SaveGame instruction when specifically called in the context loading a simulation save. I.e. something like this (or maybe it is just getting too late in Europe for me to think straight):

                //Check for simulation save and load it.
if (System.IO.File.Exists(KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs"))
{
KCT_Utilities.LoadSimulationSave(false);
TechDisableEvent(false);
}
else
{
TechDisableEvent(true);
}

Link to comment
Share on other sites

Ok. Think all the mentioned issues are fixed now. Update your Presets again since I changed how reconditioning is calculated (another RP-0 request). Just need to add "*abs([RE]-)" to the end of the line to get it to behave how it does currently. All the KCT presets should reflect the change. The change allows rollout and reconditioning to be calculated completely separately from each other, with a bit of careful formula construction at least.

I'd like to lock things down sooner rather than later, so if there's any other suggestions make them soon! I'll probably push a release as soon as I can get the build server up and running, which will hopefully be this weekend (I'm spoiled and like not having to do it manually anymore :P)

Link to comment
Share on other sites

Let me list the status of the issues as I see them (latest commit 2b2b7bbd79).

Simulation costs, simulation around Sun et cetera - FIXED (and really nice)

The simulation cost for unlimited simulation is now (again) very expensive.

You can simulate in orbit, even around Sun, which is cool ... well hot actually.

You can simulate launch from the launch pad even if the launch pad is occupied. Neat!

Tech nodes in progress and count of nodes - FIXED (unpolished)

Tech nodes are counted in the old fashioned way. Nodes currently being unlocked counts toward the total number of upgrades. The only (tiny) detail is the already known fact that the KCT upgrade screen won't show you the points for just unlocked nodes - you need to do a scene change first. It's just a visual thing though, the points are still there.

Default settings of KCT - FIXED (unpolished)

The bug with the settings getting reset has been fixed. There is a caveat though. If you leave one career with the KCT settings window open, the next career you enter will (visually) inherit the values of the window. Just press 'cancel' and your new career save is unchanged though.

KSP Settings screen - Work-around possible

The KSP settings screen (the one you get to from the main menu) can't be used with KCT. There is a work-around possible for this issue; listed at the bottom of this post.

Reentering career (loading bug) - Work-around possible

If you use the Blizzy Toolbar Mod you can enter a saved career once, then you need to restart KSP before continuing another KCT enabled career save. There is a work-around possible for this issue; listed at the bottom of this post.

Simulation save restore - FIXED

This was the major fix of the day; works perfectly for me :)

New preset ("*abs([RE]-)") - DONE

The presets are updated. I have updated the "Rodhern Low-tech" preset as well.


Settings pointer work-around:

                if (KCT_PresetManager.Instance != null) // Rodhern: Work around for settings menu etc.
{
KCT_PresetManager.Instance.ClearPresets();
KCT_PresetManager.Instance = null;
}

In this case we need to be careful not to clear presets when it is already done.

Loading bug work-around:

                if (KCT_GameStates.kctToolbarButton != null)
{
if (!KCT_PresetManager.PresetLoaded()) // Rodhern: Work around for preset needed in constructor
{
KCT_PresetManager.Instance = new KCT_PresetManager();
KCT_PresetManager.Instance.SetActiveFromSaveData();
}

if (KCT_PresetManager.PresetLoaded() && !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
else
KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR });

KCT_GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture();
KCT_GameStates.kctToolbarButton.ToolTip = "Kerbal Construction Time";
KCT_GameStates.kctToolbarButton.OnClick += ((e) =>
{
KCT_GUI.ClickToggle();
});
}

In this case we need the preset manager in the constructor, before we can get on to the Start method.

Link to comment
Share on other sites

I'll add in those workarounds tonight, thanks for coming up with them. As for "Tech nodes in progress and count of nodes" that should be fixed. KCT is now counting in-progress nodes automatically and shouldn't be double counting anymore (which is why there's a save game in the TechDisableEvent). If that's not the case, then let me know, but that should already be fixed.

Looks like the thing I'll take a look at most tonight is switching saves within one KSP session. It's not something I do frequently, so I don't catch those bugs as often. There used to be some really bad bleed over, especially when creating a new save (since OnLoad isn't called because there's no preexisting save file).

There are definitely some other places that could use polished up. If you notice them, jot them down, and I can try to fix them up before release. I'm thinking mostly of GUI issues. Things like the build list still having the VAB or SPH button highlighted but that sub-window no longer being open, requiring a double click to open it again. Or window sizes being off. Etc. I have a bad habit of not spending enough time on polish :/

Link to comment
Share on other sites

... KCT is now counting in-progress nodes automatically and shouldn't be double counting anymore (which is why there's a save game in the TechDisableEvent). If that's not the case, then let me know, but that should already be fixed.

The GUI feature that I am referring to shows up like this:

I resume a career save, I have 18 upgrade points at this point (scene is Space Center).

I go to the Research building and order a new node.

I now have 19 upgrade points (scene is Space Center).

I warp to completion, and let Kerbal Alarm Clock set the speed to x1.

It now shows I have 18 upgrade points (scene is still Space Center).

I go to Research building (or where ever) and exit the building.

I correctly have 19 upgrade points (because the scene was reloaded).

If you notice them, jot them down, and I can try to fix them up before release.

In that case I have a GUI request. When I first open the Build List it shows up on the right at the top, which is almost optimal. I now slide the window a little to the left to not obscure my message column. This setting is remembered as long as I keep KSP open. When I relaunch KSP (maybe tomorrow) the Build List window position is forgotten. B.t.w. I use the Blizzy Toolbar Mod.

Link to comment
Share on other sites

The GUI feature that I am referring to shows up like this:

I resume a career save, I have 18 upgrade points at this point (scene is Space Center).

I go to the Research building and order a new node.

I now have 19 upgrade points (scene is Space Center).

I warp to completion, and let Kerbal Alarm Clock set the speed to x1.

It now shows I have 18 upgrade points (scene is still Space Center).

I go to Research building (or where ever) and exit the building.

I correctly have 19 upgrade points (because the scene was reloaded).

Ah, I think I know why. The tech tree itself hasn't updated after the nodes are enabled. I might just try to find a different way of getting which nodes are enabled, since referencing the snapshot is easy but apparently not updating frequently enough. More playing around in the Object Browser I guess :/

In that case I have a GUI request. When I first open the Build List it shows up on the right at the top, which is almost optimal. I now slide the window a little to the left to not obscure my message column. This setting is remembered as long as I keep KSP open. When I relaunch KSP (maybe tomorrow) the Build List window position is forgotten. B.t.w. I use the Blizzy Toolbar Mod.

It used to save the position, but when I switched to using the Stock toolbar as the primary I forced it into the top right with the other windows (and it has exclusivity applied). Then an update or two later I made it so you could move it if, and only if, you were using Blizzy's toolbar. I can probably re-enable the position saving and just add a check for if the user has stopped using Blizzy's toolbar (otherwise the window will get stuck at wherever you put it when you still had the toolbar mod).

Link to comment
Share on other sites

I think I fixed those issues. Also added the ability to have each tech node go at a different rate (so you can do FIFO or all at once). It should be that if the rates are all the same, no buttons appear. If the rates are different, buttons appear to let you reorder things.

I'm tired, so I didn't test everything. I didn't get around to playing with loading different saves and fixing whatever bleed over was happening, sorry :(

Edit: (7/25/2015, 12:04AM) I don't want to post three times in a row. That seems like a bad thing to do.

Added Kerbal Konstructs support. You set the launch site at build time (will probably eventually add the ability to set it at launch, but this is easier) and each launchpad has its own rollout and reconditioning queue. One caveat, resuming a save will require you to enter the editor and select any launch sites you might decide to use (just for a moment, you can just click all of them). I might be able to fix that, but I think it's semi-KK induced.

This does open up the possibility of having multiple launchpads in the Stock game now that KCT supports any number of individual launchpadIDs. May or may not make it to release. Will probably save it for next version.

Edited by magico13
Link to comment
Share on other sites

Well, that wasn't in a function I expected to see a failure in. Might be because of how I'm defining the type of vessel now. I'm guessing you loaded an existing save? New saves likely won't have any issues since the vessels will have the additional data stored in them that I needed to add.

I'll get a fix out in a minute. Gotta think of a good way to do it.

Edit: Try it now. Hopefully that fix is good enough...

Edit2: You can now change the launch site for any vessel at any time, instead of only at build time. I think that makes Kerbal Konstructs support pretty much done :)

Edited by magico13
Link to comment
Share on other sites

Same problem in existing saves with newest version uploaded 4 hours prior to this message. No build numbers right now so time reference seems to be the best we can do :)

There's a chance that wasn't the most recent, but I think it probably messed up the ships anyway when you tried to load them previously. You'll have to open up the save file, find the ships in the KCT Data and change EditorFacility to 1 for all VAB vessels and change it to... something else... for SPH vessels (I don't know off the top of my head. I'd guess either 0 or 2, you can start a new save, build something in the SPH, and then build it through KCT and check the save game to verify. I'll do that at some point).

I think I've got a save backed up where I can check if I fixed it, but I develop in Windows (and test in Windows) but play in Linux with a fairly heavily modded game, so I can't easily test that save and I can't reproduce it in Windows (since it requires pre-existing ships).

E: The server won't be up for longer than I had planned. Don't have the equipment to install the hard drives into the computer I was planning on using for the server, so I'm going to be using the computer I was using before. But that computer only has 3 SATA ports and I want to have the OS on a different HDD from the RAID array, meaning I need 4 drives. So I bought a 4 SATA port PCI-e expansion card thingy, but had to buy it online, meaning it won't get here until maybe Tuesday :/

Edited by magico13
Link to comment
Share on other sites

I was able to load up with a previous DLL and all came up good, so not sure if they are ok or the corruption is being ignored by the earlier version. I'll also try emptying out all the ships in the lists and update to see if having nothing in them still generates the problem.

Building computers I know all too well the frustration of waiting for parts to come in.

Link to comment
Share on other sites

The "corruption" is just that I have to store an extra number to reliably know which type of vessel (VAB of SPH) it is, but existing vessels don't have that number. So then it incorrectly gives it the wrong number (VAB craft were getting the SPH number) and when KCT goes to find it in the list, it can't, because it's looking in the wrong list, which makes it freak out. I think I've got it set up now that if that number doesn't exist it will find the correct one, but if the wrong one is already set then it'll keep loading the wrong one.

Back up that save and see if you can load it with the new .dll. I haven't uploaded a new version yet because I think that should be working. Can you also check if tech nodes are being counted properly for upgrades? In my save they weren't being counted at all, but when I tried testing with a new save they were fine.

Link to comment
Share on other sites

That does seem to do it and if there are no ships in the lists is also loads up fine without freaking out. New DLL up and running. Haven't done much with it yet as I wanted to report back that loading was working since without that not much more can be done ;)

I seem to have gotten bonus tech node points somehow in the new DLL though. I'll see how it changes with new unlocks

Got some more nodes unlocked and it added points to both the total and available :)

Link to comment
Share on other sites

I seem to have gotten bonus tech node points somehow in the new DLL though. I'll see how it changes with new unlocks

Got some more nodes unlocked and it added points to both the total and available :)

The total and the available should obviously increase (since available is just total-spent). I'm not totally sure why it doesn't seem to be counting the tech nodes properly. I'll play around with it some more. Let me know if you notice any other weird behavior (especially with the number of upgrades).

Link to comment
Share on other sites

It is looking like it is giving the right number for new tech nodes, but too many for ones that were already unlocked on existing saves. So far anyway, as nutty as this thing can be it might change its mine :P

EDIT: One weird thing, on starting a new save it starts with 37 points. I'm thinking that might be a little high ;)

EDIT 2: It seems other errors creep in during play. In the existing save was unable to enter the VAB due to an error, and in a new save was unable to recover craft. Went back to the release DLL to see if it might have been something else going nuts and everything started working fine with the old DLL so looking like something in the test version of KCT. What that something might be though I have no idea.

LOG: https://www.dropbox.com/s/kqdilzsqxqpiorw/output_log.txt?dl=0

Edited by JeffreyCor
Link to comment
Share on other sites

Same error both times. Both caused by it trying to save the game I think. Give me a sec. (both when trying to disable the tech nodes.)

Might be caused by the stuff I tried to add to make it so Experimental Parts are still available to use.

E: Removed the experimental parts stuff and switched to use only one method of counting tech nodes. See if that works any better :)

Edited by magico13
Link to comment
Share on other sites

This is indeed working better :)

New rollout time seems a little long at 10 days to roll out. Were the old times too fast and just got used to it?

You need to update your Presets. You can now define rollout and reconditioning separately, but since your Preset isn't updated it's requiring twice the total time.

Either get it from GitHub or just add "*abs([RE]-)" to the end of the reconditioning formula.

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...