Jump to content

[1.8.x-1.12.x] Module Manager 4.2.3 (July 03th 2023) - Fireworks season


sarbian

Recommended Posts

  On 2/20/2023 at 8:48 PM, sarbian said:

It seems that people forgot about the advanced MM options. Add  "-nyan-nyan -ncats" to your KSP launch options. It will change your loading experience drastically.

Expand  

W00T! On Demand - That's awesome!

Anyone else finding Alt-F11 not doing anything? Tried in main menu and spacecenter view, is there a trick to it I'm missing?

Edited by tg626
This forum software continues to be hot garbage - multipost
Link to comment
Share on other sites

  • 4 weeks later...

A question for the experts regarding using MM to apply patches to many parts, using MechJeb as the example:

Which would most help minimize loading times to add MechJeb to command capable parts in a HIGHLY modded game? 

1) A single patch file that changes all files that need changing, using @PART[*].  (I.E. @PART[*]:HAS[@MODULE[ModuleCommand]|!@MODULE[MechJebCore]]:NEEDS[MechJeb2])
2) A patch file for each mod, specifying each command  capable part in that mod?  (I.E. @PART[xxxx|yyyy|zzzz]:HAS[!MODULE[MechJebCore}]:NEEDS[Squad&MechJeb2])
3) A single CFG file for each part calling out the part? (I.E. @PART[xxxx]:HAS[!MODULE[MechJebCore}]:NEEDS[Squad&MechJeb2]

Or some other permutation?

Background, I'm writing a system that takes apart the ModuleManager.ConfigCache and parses out / stores data about the parts.  Part of the system contains a file with all the desired changes I want to patch.  (I.E. a line in the file will say to change the title to something, and to change the required tech.  Another line might change a category on another part)  This system can then generate patch files that never forget any change once noted in the system, and never have a 'fat-fingers' moment.

Edited by Padrone
Somehow double posted in one post.
Link to comment
Share on other sites

  On 3/29/2023 at 2:30 AM, Padrone said:

Which would most help minimize loading times to add MechJeb to command capable parts in a HIGHLY modded game? 

Expand  

:NEEDS is the way to go.

@PART[xxxx]:HAS[!MODULE[MechJebCore]]:NEEDS[Squad&MechJeb2]

Any non satisfied :NEEDS clausule automatically removes the patch before the patching itself begins, saving time.

About how the patch are stored on files, is doesn't matter. Everything is loaded into the GameDatabase before Module Manager is even loaded into memory. Module Manager works from the GameDatabase after every .CFG file is already loaded.

— POST EDIT — 

Additionally, please pay special attention on the use of "[" and "]". You inadvertently mistyped one ] (right bracket) by } (right brace), and this is pretty harsh to detect by eye balling later! :)  

Edited by Lisias
post edit
Link to comment
Share on other sites

Congrats to the true gentlemen who introduced the rainbow-sh*ting cat to the loading screen, I was going insane thinking I had somehow made some mistaking while installing mods, when I looked at today's date. Well played.

Edited by mateusviccari
The forums does not allow me to write the word that begins with "sh" and ends with "it"
Link to comment
Share on other sites

@sarbian or anyone who can clarify..

 

I'm writing a patch to add KIS modules to a bunch of parts (that dont have KIS modules)

Whats the proper edit to add a module to a part that doesnt have the module originally?  to be clear i want to **ADD a module, not edit a module... since the module isnt in the part config

Do I use something like this:

 

@PART[SomePart]
{
	%MODULE

	{

	name = ModuleKISInventory

	xxx = xxxx

	xxxx = xxx

	}
}

 

 

basically im asking If all I do is just add a % before MODULE to add a module?  Since its an addition and not an edit. Or do i use the same as if its just efiting the module and it will be recognized as a new module and add it?

 

Just want to make sure im doing it correctly

 

 

Link to comment
Share on other sites

  On 4/3/2023 at 7:19 AM, Astra Infinitum said:

Whats the proper edit to add a module to a part that doesnt have the module originally?  to be clear i want to **ADD a module, not edit a module... since the module isnt in the part config

Expand  

If you want to add the module to a part that doesn't have the module originally (either through Stock+KIS implementation or via a patch for a modded part included within the mod), you might then want to consider doing the following.

@PART[SomePart]:HAS[!MODULE[ModuleKISInventory]]:FINAL
{
	MODULE
	{
		name = ModuleKISInventory
		xxx = xxxx
		xxxx = xxx
	}
}

It would mean that your patch would get overruled by a patch that was included by a mod at a later date, only applying your patch if the part didn't get the module applied during the normal MM pass.

Edited by Poodmund
Link to comment
Share on other sites

  • 4 weeks later...

Hi there! I found an issue today. 

In some Kopernicus configs, some array elements are separated by space or tab, e.g.:

key = 0 292 0.00000E+00 -6.04157E-03


However, if I need to edit the values with module manager, e.g:

@key,*[0, ] *= 1.61

It can only identify the elements separate with space, but not with tab. An error will be reported and here is what the log looks like:

Error - Failed to do a maths replacement: @temperatureCurve : original value="0	292	0.00000E+00	-6.04157E-03" operator=Multiply mod value="1.61"

It can be a problem since both space and tab works in KSP.
Is it possible to fix the issue?

Link to comment
Share on other sites

Question #01

Does the dash/hyphen count as an alphanumeric character with respect to module manager * filters? Asking because the documentation states that

  Quote

" * for any number of alphanumeric chars.."

Expand  

 

and technically the dash/hyphen isnt an "alphanumeric"


Example: I want to create a patch that edits a resource module on every NearFuture spacecraft command pod. The command pos part names are:

command-25-1
command-25-1_shiny
command-25-landing-1
command-125-1
command-125-1_shiny
command-125-landing-1
command-125-orbit-1
command-375-biconic-1

 

Would the following patch work to cover all these parts?

  Quote

@PART[command*]:FOR[NearFutureSpacecraft]

Expand  

or another example, in case other mods have parts that start with command...:

  Quote

@PART[command-25*,command-125*,command-375*]:FOR[NearFutureSpacecraft]

Expand  

In short, can I put "command*] and would that be recognized by module manager and apply to all parts that begin with ? 

 

 

Question #02

 

With another NF spacecraft command pod as my example, since thats what I'm wanting to make it for, I would like to first, add a crazy amount of electric charge resource to a pod, and secondly I would like to remove the monopropellant from the command pods and replace it with small amount if liquid fuel and oxidizer instead. 

Which way is the correct way to go about this, and if neither of these are correct, how do i go about removing one resource and replacing it with 2 resources?

(The main differences between Option A and Option B are in bold Red text)

Option A

  Quote

@PART[command-25*]:FOR[NearFutureSpacecraft]
{
    @RESOURCE[ElectricCharge]
    {
        @amount = 800
        @maxAmount = 800
    }
    @RESOURCE[MonoPropellant]
    {
        @name = LiquidFuel
        @amount = 450
        @maxAmount = 450
    }
    %RESOURCE
    {
        %name = Oxidizer
        %amount = 550
        %maxAmount = 550
    }

}    

Expand  

or

Option B

  Quote

 

@PART[command-25*]:FOR[NearFutureSpacecraft]
{

    @RESOURCE[ElectricCharge]
    {
        @amount = 800
        @maxAmount = 800
    }
    @RESOURCE[MonoPropellant]
    {
        @name = LiquidFuel
        @amount = 450
        @maxAmount = 450
    }
    %RESOURCE[Oxidizer]
    {
        %amount = 550
        %maxAmount = 550
    }

}    

 

Expand  

 

 

 

Edited by Astra Infinitum
Link to comment
Share on other sites

  On 4/30/2023 at 7:23 PM, Astra Infinitum said:

Question #01

Does the dash/hyphen count as an alphanumeric character with respect to module manager * filters? Asking because the documentation states that

<….>

and technically the dash/hyphen isnt an "alphanumeric"

Expand  

Yes, on this context, dashes but also dots and spaces are considered "alphanumeric" for the filters. With Unity aggravating  the situation by replacing a lot of non alphanumeric characters (as braces) into a dot - so what you type is not what you get.

Since we are here, spaces are also allowed on Unity's names, but MM doesn't handle that. If you have something named using a space, in order to patch it you will need to use a '?' in the place of the space and then pray to have nothing else similarly named with something else in the place of the space. :)

 

  On 4/30/2023 at 7:23 PM, Astra Infinitum said:

Question #01

Example: I want to create a patch that edits a resource module on every NearFuture spacecraft command pod. The command pos part names are:

command-25-1
command-25-1_shiny
command-25-landing-1
command-125-1
command-125-1_shiny
command-125-landing-1
command-125-orbit-1
command-375-biconic-1

 

Would the following patch work to cover all these parts?

@PART[command*]:FOR[NearFutureSpacecraft]

or another example, in case other mods have parts that start with command...:

@PART[command-25*,command-125*,command-375*]:FOR[NearFutureSpacecraft]

In short, can I put "command*] and would that be recognized by module manager and apply to all parts that begin with ? 

Expand  

Both will work, but both are dangerous because they will patch everything starting with the given string, not only the NFS parts. You see, "command" is a pretty common name to be used on parts, it's not NFS's prerogative to use them.

Some add'ons are making our lifes easier by adding a prefix to their part names, as "nfs-<something>". This make things easier are by prefixing the parts you don't risk patching 3rd parties by accident.

On my patches, I choose to address the parts by name without filters. You will not see any of my patching causing trouble to anyone else - unfortunately, the reciprocate is not true.

If you really think that using wildcards is the way to go, consider using :HAS[] checking for something that only the parts your target addon uses, as the name of the author (but even this got me headaches once, as one author allowed a part to be used on another add'on, and then I got double patching the same on a user's rig).

 

  On 4/30/2023 at 7:23 PM, Astra Infinitum said:

Question #02

Which way is the correct way to go about this, and if neither of these are correct, how do i go about removing one resource and replacing it with 2 resources?

(The main differences between Option A and Option B are in bold Red text)

Option A

 %RESOURCE
    {
        %name = Oxidizer
        %amount = 550
        %maxAmount = 550
    }

or

Option B

 %RESOURCE[Oxidizer]
    {
        %amount = 550
        %maxAmount = 550
    }

 

Expand  

Option A will add or edit a node called RESOURCE (any one), rename it to `Oxidixer` no matter what  it was its name before, and then add or edit the `amount` and `maxAmount` values. This is rarely what you want.

Option B will add or edit a node called RESOURCE with name `Oxidizer` - i.e., if theres no RESOURCE node with a `Oxidizer` in the `name` value, one is created. If it exists, the first one is edited with the new values.

Since we are here, there's also a Option C:

 %RESOURCE[Oxidizer]
    {
        %name = something-else
    }

This will create a new node called `something-else`, or will edit the first `Oxidizer` node it finds to be named `something-else`. This is what you appears to want (as long the remaining values are the same)

However, I would do things differently:

-RESOURCE[Oxidizer] { }, *
&RESOURCE[Resource1]
{
	yada yada yada
}
&RESOURCE[Resource2]
{
	yada yada yada
}

The first patch will remove all nodes named `Oxidizer`, and the following two will add new RESOURCE nodes with the respective name and content. These patches will silently "fail" if the resources `Resource1` and `Resource2` already exists. If you want to be sure to have your definitions overwritting the existent ones, I suggest to use:

-RESOURCE[Oxidizer,Resource1,Resource2] { }, *

This will guarantee that what you end up having is really what you wanted - some other patch may had added things you don't expect (as flow constraints) on the RESOURCE, and this creates very harsh to debug problems later.

Edited by Lisias
Hit "Save" too soon.
Link to comment
Share on other sites

  • 2 weeks later...

Ok, got an issue with a computer that too fast.

Getting the following error while starting up:

  Reveal hidden contents

Game runs ok, it's just that because of these exceptions, it doesn't generate the ModuleManager.configcache file

This is a complete game directory which was copied over from my old computer, where it works without any issue

I'm not sure how to resolve this, anybody have any ideas?

Link to complete log:   https://www.dropbox.com/s/9ds5vzdt6w1eos4/ModuleManagerTooFastBoot.zip?dl=0

Edited by linuxgurugamer
Link to comment
Share on other sites

  On 5/10/2023 at 1:01 PM, linuxgurugamer said:

Ok, got an issue with a computer that too fast.

Getting the following error while starting up:

  Reveal hidden contents

Game runs ok, it's just that because of these exceptions, it doesn't generate the ModuleManager.configcache file

This is a complete game directory which was copied over from my old computer, where it works without any issue

I'm not sure how to resolve this, anybody have any ideas?

Link to complete log:   https://www.dropbox.com/s/9ds5vzdt6w1eos4/ModuleManagerTooFastBoot.zip?dl=0

Expand  

I solved the problem, will be doing a PR in a bit.

It's a simple fix, just adding a parameter to the File.Open "FileShare.ReadWrite" in FileUtils.cs

Link to comment
Share on other sites

Is there a way to search for a specific module when a part has multiple of that part? For instance if there are two modules called configure. I can easily grab the first one or the second one, but I would like to make sire I grab the correct one. Can I use something like HAS[title[start xyz]] ? 

Link to comment
Share on other sites

  On 5/14/2023 at 10:09 PM, Nori said:

Is there a way to search for a specific module when a part has multiple of that part? For instance if there are two modules called configure. I can easily grab the first one or the second one, but I would like to make sire I grab the correct one. Can I use something like HAS[title[start xyz]] ? 

Expand  

Yes, you can. It would look something like this:

@MODULE[configure]:HAS[#title[xyz*]]

Link to comment
Share on other sites

  On 5/14/2023 at 9:06 PM, linuxgurugamer said:

I solved the problem, will be doing a PR in a bit.

It's a simple fix, just adding a parameter to the File.Open "FileShare.ReadWrite" in FileUtils.cs

Expand  

The real issue if that Module Manager is being instantiated twice (or even more). If only one copy of ModuleManager would be in execution, the situation in which it would try to compute the SHA for a given file in different threads would just not happen.

Having multiple Module Managers running at the same time on the rig is terrible, with some patches ending up being corrupted (by some reason, the Localization ones are specially prone to the problem).

I had said before, and I will say it again: there must be only ONE Module Manager running in memory, and without solving this problem, people will still be screwed by bad patching happening randomly across the system.

Once you secure only one ModuleManager running at a given time, you don't need to scramble patching every single place where code that was meant to run solo subtly is facing concurrency with itself.

 

Edited by Lisias
some entertaining grammars made less entertaining.
Link to comment
Share on other sites

  On 5/15/2023 at 3:57 AM, Lisias said:

The real issue if that Module Manager is being instantiated twice (or even more). If only one copy of ModuleManager would be in execution, the situation in which it would try to compute the SHA for a given file in different threads would just not happen.

Having multiple Module Managers running at the same time on the rig is terrible, with some patches ending up being corrupted (by some reason, the Localization ones are specially prone to the problem).

I had said before, and I will say it again: there must be one ONE Module Manager running in memory, and without solving this problem, people will still be screwed by bad patching happening randomly across the system.

Once you secure only one ModuleManager running at a given time, you don't need to scramble patching every single place where code that was meant to run solo subtly is facing concurrency with itself.

 

Expand  

Please don't assume I'm an idiot.

  On 5/15/2023 at 3:57 AM, Lisias said:

The real issue if that Module Manager is being instantiated twice (or even more). If only one copy of ModuleManager would be in execution, the situation in which it would try to compute the SHA for a given file in different threads would just not happen.

Expand  

There is only one copy of MM in the install.  While I can't be positive, I suspect it may be the game itself which is keeping the file open;  I tested this extensively, and copied an entire install from one computer where this doesn't happen onto a new computer (much faster) where it does happen.

Edited by linuxgurugamer
Link to comment
Share on other sites

  On 5/15/2023 at 12:06 PM, linuxgurugamer said:

There is only one copy of MM in the install.  While I can't be positive, I suspect it may be the game itself which is keeping the file open;  I tested this extensively, and copied an entire install from one computer where this doesn't happen onto a new computer (much faster) where it does happen.

Expand  

With all due respect, sir, opening any kind of executable code with a Write option enabled is for anti-virus what honey is for honeybadgers - and I assumed that someone that worked on I.T. infrastructure would be aware of that.

Additionally, by the time Unity starts to call the Awake method on the Monobehaviours, everything was already loaded into memory. KSP (at least the latest ones) first loads all the available DLLs, then it links them in memory (this is where missing dependencies are detected), and only then KSP starts to call code inside it. By the time ModuleManager opens a DLL for reading its contents, everything should be set for some time already and it's pretty awkward that KSP would keep these files opened after resolving all the dependencies.

Granted, not impossible (but that would be another flaw on KSP, I think).

Did you monitored the opened files in the system in order to determine who had these files opened at the time of the occurrence? Did you tried to make all the DLLs read/only on the file system to see if the problem goes away (or if a new one is created)?

In a way or another, instead of opening everything using a Write enabled share option (potentially attracting undesired attention from antivirus monitors), would not be better and safer putting the whole SHA thing inside a try catch, inside a loop, and doing a small busy wait if the problem happens and trying again?

Edited by Lisias
tyop! Surprised?
Link to comment
Share on other sites

Among other things, what I did to test this was:

  • Review log file to verify only one copy of MM
  • Add a sleep delay when trying to open the file, just in case it would be closed.

My conclusions are this:

  1. Only one copy of MM is installed
  2. Something else (KSP and/or Unity) is keeping the file open, even after reading it into memory

The file is still being opened in a read-only manner.  The new option simply specified what ways other processes can open the file.  Now, it's quite possible that instead of the FileShare.ReadWrite it should be FileShare.Read, but in any event, MM is not writing to the file, and if MM wasn't there, whatever else is opening the file would still be able to do what it can.  So this would be a minor criticism, at most.

I do have other things I'm working on, so I did enough to prove that:

  1. This allows MM to proceed without getting the file exceptions
  2. While KSP may have loaded all the DLLs into memory, that doesn't mean that KSP/Unity has closed the files.  This allows MM to read the files even while KSP/Unity is keeping the files open
  3. MM is now able to write the ModuleManager.ConfigCache file.  This is necessary for debugging MM scripts, and somewhat useful in reducing the load time of the game
Link to comment
Share on other sites

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