Jump to content

[WIP] TweakScale - Development Thread


pellinor

Recommended Posts

Thought this may help, take a look, in this picture, first I remove the default Tweak scale module, that part works ok, then I add my own tweak scale with the type defined and on the left side, that is what i see, first of all, it's on default type without ability to change it in GUI, second, using the right button i set it to 2, not only the slider won't update, also the part is not changing it's scale, also, even if I use the slider in the GUI, still the part is not respecting the value at all

794e7c173d5247789cb86cac1da5b2cd.png

Link to comment
Share on other sites

Ok, tested the tweak scale on fresh install and it works, but now i can't figure what could interfere with it, thought to send a log file here and ask for help, there should be a mod interfering with this mod, someone plese help me, i am totally new to tracking bugs in ksp

https://www.dropbox.com/s/r9a9l91ktxxcbmb/output_log.zip?dl=0

thanks

Link to comment
Share on other sites

3 hours ago, Jiraiyah said:

Ok, tested the tweak scale on fresh install and it works, but now i can't figure what could interfere with it, thought to send a log file here and ask for help, there should be a mod interfering with this mod, someone plese help me, i am totally new to tracking bugs in ksp

https://www.dropbox.com/s/r9a9l91ktxxcbmb/output_log.zip?dl=0

thanks

A good start is to search for "exception" in the logfile (and there are many of them). These are problems that could cause collateral damage elsewhere. First thing I would try is to test without the mods mentioned in the exceptions (like partAngleDisplay). I didn't see any TweakScale related problem in the log.

Link to comment
Share on other sites

Well, I narrowed down the problem to Auto load mod, something is happening when the game is launched and a game instance is loaded normally that Auto Load mod is bypassing, I sent an issue message to it's developer's repo and he said he will look into it, but i never thought something like this would happen between the time ksp main menu shows up and when the user loads a game!

here is the link to the issue post :

https://github.com/allista/AutoLoadGame/issues/4

Edited by Jiraiyah
Link to comment
Share on other sites

Dev updates
* update MM
* two new stock parts
* messing with crewCapacity scaling (currently turned off because of problems)

[edit:]
* antenna scaling (range not tested yet)
(a large antenna is worth the same weight/cost in smaller combined antennas of the same type)

Edited by pellinor
Link to comment
Share on other sites

13 hours ago, Fonz said:

Is this 1.2 Compatible?

I believe it has been complied to work on 1.2 before the mm was updated, I am unsure if it has been modified scene the release of the 1.2pre mm dll. I have installed it and to my knowledge it works but it errors on start up, expect bugs but it works fonz.

12 hours ago, Tex_NL said:

Without testing, who knows?

Install.
Test.
Does it work?
- Yes: Hooray
- No: Too bad. Delete.

Tex its nice to see if someone as installed it and tested it, but yes you do test it to see if it works. i like to ask and also test so i have the answer if some one asks if no one know the answer

Edit: 3 posts up says he has updated it with the mm patch so it will mostly work better than my version but still espect bugs [Make sure you use dev not the 1.1 release]

Edited by xD-FireStriker
Link to comment
Share on other sites

@Shadowmage since the prerelease forum is locked, let's continue the discussion about changing crewCapacity here.

Are you adding of removing seats with respect to the prefab? You can probably get away with only handling one of those situations.

 

I tested your code and the call on onEditorShipModified, this is what I found:

Spoiler

// code for reference  
        private void updateCrewCapacity(int capacity)
        {
            MonoBehaviour.print("Setting crew capacity to: " + capacity + " current: " + part.CrewCapacity);
            part.CrewCapacity = capacity;
            if (!HighLogic.LoadedSceneIsEditor) { return; }//only run the following block in the editor; it updates the crew-assignment GUI
            if (EditorLogic.fetch.editorScreen == EditorScreen.Crew)
            {
                EditorLogic.fetch.SelectPanelParts();
            }

            VesselCrewManifest vcm = ShipConstruction.ShipManifest;
            if (vcm == null) { return; }
            PartCrewManifest pcm = vcm.GetPartCrewManifest(part.craftID);
            if (pcm == null) { return; }
            int len = pcm.partCrew.Length;
            for (int i = 0; i < len; i++)
            {
                pcm.RemoveCrewFromSeat(i);
            }
            pcm.partCrew = new string[capacity];
            //have to init the array to blank strings or it will null-ref on a stock method
            for (int i = 0; i < capacity; i++)
            {
                pcm.partCrew[i] = "";
            }
        }

        private void onEditorVesselModified(ShipConstruct ship)
        {
			//this could all be optimized, cleaned up, handled better... but mostly working
            if (inflated && part.CrewCapacity == inflatedCrew) { return; }
            else if (!inflated && part.CrewCapacity == deflatedCrew) { return; }
            MonoBehaviour.print("Updating crew capacity from editor vessel modified event");
            updateCrewCapacity(inflated ? inflatedCrew : deflatedCrew);
        }

 

== extra seats ==
* start with mk1 pod
* add seats (in my case 1->4)
* fill those seats with kerbals
* try to attach a new pod
  => editor breaks:
  IndexOutOfRangeException: Array index is out of range.
  at (wrapper stelemref) object:stelemref (object,intptr,object)
  at VesselCrewManifest.UpdatePartManifest (UInt32 id, .PartCrewManifest referencePCM) [0x00000] in <filename unknown>:0
  at VesselCrewManifest.UpdateCrewForVessel (.ConfigNode vesselNode, System.Func`2 persistFilter) [0x00000] in <filename unknown>:0
  at EditorLogic.RefreshCrewAssignment (.ConfigNode craftNode, System.Func`2 persistFilter) [0x00000] in <filename unknown>:0
  at EditorLogic.<SetupFSM>m__8C () [0x00000] in <filename unknown>:0
  at KerbalFSM.RunEvent (.KFSMEvent evt) [0x00000] in <filename unknown>:0
  at KerbalFSM.updateFSM (KFSMUpdateMode mode) [0x00000] in <filename unknown>:0
  at KerbalFSM.UpdateFSM () [0x00000] in <filename unknown>:0
  at EditorLogic.Update () [0x00000] in <filename unknown>:0

** The same happens if I try to launch with a filled extra seat. Did this work for you?
** When saving and launching directly from the pad, extra seats are ignored
** F5/F9 works (filled extra seats stay filled)

For TweakScale it might be a viable compromise if extra seats are available in flight but not in the editor or at launch.

 

== removed seats ==
* start with mk1 pod
* remove seat
* add another pod
  => seat has returned
Any further change will fix things, for example changing fuel amount in a tank. This is a bit annoying but would work as long as any reappeared seats are cleared when launching from the editor (or saving the vessel).

** When launching a saved vessel directly from the pad, I can assign kerbals to removed seats. This seems to fail silently (still it is a source of confusion and might lead to problems with other mods that mess with the launch of a ship).

Edited by pellinor
Link to comment
Share on other sites

@pellinor

For my purposes I'm reducing the number of seats compared to the prefab.  So the prefab contains the maximum seats that will ever be present, with the currently available seats being determined by the module stats.

Yes, I could see how there would be problems if trying to expand the number of seats compared to the prefab (due to the stock code relying on prefab crew capacity rather than actual instance of the part).

I actually had a thought on this the other night.  What if you Module-Manager patched all of the pods/crewed parts that had the TweakScale module in them to have a much higher crew capacity in the prefab, and limited this down to the 'current' value through the plugin code?  So you might patch the mk1 pod to have say 8 max crew, but this gets reset/limited down to 1 for a normal scale part, while still allowing for 2-8 crew for larger scaled sizes.

Hmm.. regarding the launching from the space-center scene -- that might be a problem that cannot be solved; I don't think that those GUIs ever initialize the parts at any point, so the module code never has a chance to run, and thus those GUIs will always use the values derived from the prefab.  My only thoughts on that would be to somehow query for whenever that GUI is open/opened and hack its internals a bit; not a clean or elegant solution, but about all that I can think of.


I'll be taking another pass at this stuff this weekend.  Sadly I don't get much good development time during the week anymore (or rather the time that I have, I do not have access to KSP to test stuff, can only do blind development...).

Link to comment
Share on other sites

1 hour ago, Shadowmage said:

What if you Module-Manager patched all of the pods/crewed parts that had the TweakScale module in them to have a much higher crew capacity

That would open quite a whole can of worms with its side effects, many of which also affect unscaled parts. I consider scaling of crewed parts a pretty exotic use of TweakScale, so it is quite important that glitches and side effects are limited to scaled parts. Most likely I'll also make the scaling of seats opt-in instead of doing it by default.

Link to comment
Share on other sites

46 minutes ago, pellinor said:

That would open quite a whole can of worms with its side effects, many of which also affect unscaled parts. I consider scaling of crewed parts a pretty exotic use of TweakScale, so it is quite important that glitches and side effects are limited to scaled parts. Most likely I'll also make the scaling of seats opt-in instead of doing it by default.

True enough; was merely an idea :)

 

Sure would be nice if the stock code didn't rely on the -prefab- part for the crew capacity information.  Though that may well require a substantial overhaul to the stock crew-handling code.  I'm honestly a bit surprised that RoverDude didn't fix up that end of the code for his MKS inflatables.

Anyhow, I'll be playing around with this code a bit more over the weekend and will see if I can come up with any solutions to the 'too many crew for the prefab' problems.

 

Edit:  Took a peek at RoverDude's crew capacity code.   https://github.com/BobPalmer/UmbraSpaceIndustries/blob/master/USITools/USITools/USIAnimation.cs

Apparently it doesn't support in-editor manipulation of crew capacity, and initializes parts to have zero capacity in the prefab/config ( https://github.com/BobPalmer/MKS/blob/master/FOR_RELEASE/GameData/UmbraSpaceIndustries/MKS/Parts/Tundra_HabRing.cfg ).

Hmm..... sadly nothing helpful there.

Edited by Shadowmage
Link to comment
Share on other sites

Could someone proficient with antennas test if scaled antennas work? A large antenna should be as strong as the same weight in smaller combined antennas of the same type. My suspicion is that the scaling will work for the antenna of the active vessel but not for unloaded relays.

Link to comment
Share on other sites

Dev update:
* CrewCapacity: has a configurable exponent now (not sure if it will be set by default)
* CrewCapacity: additional seats are only available in flight (hidden in the editor)
* scaling support for FloatCurve (for wheelTorque) and int (for CrewCapacity)
* removed a few log messages
* removed empty cfg files

Link to comment
Share on other sites

Dev update:
* antenna: refresh range display and tweak exponent  (so that downscaled antennas are a bit less overpowered)

Obviously unloaded relays use their unscaled range. Changing that would probably require making the range field persistent, so fixing it is out of my reach.

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