Jump to content

Adding small dll to Parts-Only mods to verify install loc


linuxgurugamer

Recommended Posts

As I’m working on the updates (7% done) of my mods, I’ve been adding an InstallChecker to them to verify that the mod is installed in the correct location.  

I’m thinking about adding a tiny DLL to all my Parts-Only mods to do the same thing.  This would ensure that if it is installed in the wrong location, that the user would be notified about it.

I can’t  think of any downside, and am wondering if anyone knows of any reason to not do this.

Link to comment
Share on other sites

I think this is a good idea.

Not to steal your thunder, but as I already have a mod that checks whether other mods have problems I could add this as a feature if you like?

My initial thoughts are: "MM patch that lets the mod author define a path where the mod is supposed to be, and if it's not there pop up a warning" (but I've literally thought about it for 5 seconds so there may well be another/better way)

Edited by severedsolo
Link to comment
Share on other sites

19 hours ago, severedsolo said:

I think this is a good idea.

Not to steal your thunder, but as I already have a mod that checks whether other mods have problems I could add this as a feature if you like?

My initial thoughts are: "MM patch that lets the mod author define a path where the mod is supposed to be, and if it's not there pop up a warning" (but I've literally thought about it for 5 seconds so there may well be another/better way)

Your mod checks for broken DLLs, but currently has no way to know if a parts mod is in the right location or not.  I suppose you could add some sort of config file, but then either you or the modder will need to supply it.  It would also require that your mod be installed, and while I don't think that's a problem in and of itself, given the example of someone who copied the GameData from KWRocketry into the GameData directory, it would be better if they were told what was wrong rather than them having to ask for help, be told to install another mod (which they can also mess up on), etc.

  What this will do (and yes, I'm going to add it), will only be added to mods which don't have a DLL.  It will be a simple run at Main Menu , show a message if it's not in the right location.  Essentially, it will be the InstallChecker.cs which I'm including in all my mods, but in a standalone mode.

 

Link to comment
Share on other sites

8 hours ago, paul23 said:

Are you now crawling my whole pc looking for files?

 

The idea of gpl is that I can replace part of a mod with my own parts, so it's bad in that you are now locking gpl requirements out.

What gives you the idea that it would? The purpose of the script is to check if the mod was installed into a valid location. To do this, it needs to run zero disk searches, and does not need to access any part files. Nor is this script required for the mod to function, so removing it does not break the mod and does not violate the license.

The one instruction this script needs to execute is a conditional along the lines of:

IF (MyOwnFilePath NOT MATCH "wildcard/Kerbal Space Program/GameData/ModName") THEN (Show Startup Message)

That is literally all of it.

The one problem I see with actually implementing that is that you can't guarantee that it won't show a false positive. For example, the KSP directory does not need to be named "Kerbal Space Program" for the game to work just fine. But if you do check for "wildcard/Kerbal Space Program/GameData/ModName", then the script will trigger errorneously when the KSP directory has a non-standard name. Meanwhile, you cannot just check for "wildcard/GameData/ModName" alone, because that would detect a file path of "Kerbal Space Program/GameData/GameData/ModName" as valid, which is a common installation error and sometimes results in a parts mod not working (depends on the mod in question).

Perhaps a double conditional then? Check for "wildcard/GameData/ModName" to start with, but additionally also flag any doubling of GameData.

Link to comment
Share on other sites

2 hours ago, Streetwind said:

 

The one problem I see with actually implementing that is that you can't guarantee that it won't show a false positive. For example, the KSP directory does not need to be named "Kerbal Space Program" for the game to work just fine. But if you do check for "wildcard/Kerbal Space Program/GameData/ModName", then the script will trigger errorneously when the KSP directory has a non-standard name. Meanwhile, you cannot just check for "wildcard/GameData/ModName" alone, because that would detect a file path of "Kerbal Space Program/GameData/GameData/ModName" as valid, which is a common installation error and sometimes results in a parts mod not working (depends on the mod in question).

There is a function that returns the games base install directory - you just start checking from there.

 

11 hours ago, linuxgurugamer said:

Your mod checks for broken DLLs, but currently has no way to know if a parts mod is in the right location or not.  I suppose you could add some sort of config file, but then either you or the modder will need to supply it.  It would also require that your mod be installed, and while I don't think that's a problem in and of itself, given the example of someone who copied the GameData from KWRocketry into the GameData directory, it would be better if they were told what was wrong rather than them having to ask for help, be told to install another mod (which they can also mess up on), etc.

That's a fair point - I just happened to like the idea, so thought I'd offer. Your way is probably easier for your needs anyway.

Edited by severedsolo
Link to comment
Share on other sites

11 hours ago, paul23 said:

Are you now crawling my whole pc looking for files?

 

The idea of gpl is that I can replace part of a mod with my own parts, so it's bad in that you are now locking gpl requirements out.

Of course not.  You can look at the code, it's all available on Github.  Just look in any of my mods for a file called InstallChecker.cs

But the line which does the checking is here:

var badPaths = assemblies.Select(a => a.path).Select(p => Uri.UnescapeDataString(new Uri(Path.GetFullPath(KSPUtil.ApplicationRootPath)).MakeRelativeUri(new Uri(p)).ToString().Replace('/', Path.DirectorySeparatorChar)));

Specifically the KSPUtil.ApplicationRootPathis is provided by the game to point to the GameData.

5 hours ago, King Arthur said:

I delete unnecessary bloat DLLs like MiniAVC because I want my /GameData directory to be reasonably clean and I can do the required upkeep myself, so I don't find the idea of looking out for another such DLL all that appealing.

You are absolutely free to do that.  It isn't needed to play the game, but it is needed to make sure that the mod is located in the wrong place.  

It also writes a line to the log file identifying the mod early in the startup process.  This line is useful for debugging if I need to look at the log file.

Moving forward, as I add this DLL to the mods, I may sometimes as that the mod be reinstalled and then generate a new log file.  If the line is missing in the new log file, I'll probably just throw up my hands and not do any more, since it would be obvious, at that time, that the player is not interested in listening to instructions.

The problem of a mod being put into the wrong directory happens more often than you might think.  This DLL is a very simple, non-intrusive, unmeasurable amount of time used, way to assist the player (meaning you) to make sure that the mod is at least installed in the correct location.

Link to comment
Share on other sites

I'm not going to make a fuss of it: since you're free to adapt gpl any shap and any way you like.

 

However gpl is about free software, not only open source or making the source freely available. The idea behind it is that any user can modify their software and you don't run checks (drm or anything) to verify software. You expect users to modify software. If that means a user likes to modify the binary: that should also be fine.

 

So why do the check in the first place? How the software handles is up to the user, as creator of gpl software you shouldn't try to influence that and you should be happy if people tear it apart and try to test unknown ways.

Again you're free to use gpl or a modified version of it, since it is your code: however the idea behind gpl is that you should not do such checks; it's gray waters since effictively you add a DRM to the software. - What if I use another library to create those files during runtime?  Because a future mod is "automatically balancing & creating parts based on all mods installed"?

Edited by paul23
Link to comment
Share on other sites

2 hours ago, paul23 said:

I'm not going to make a fuss of it: since you're free to adapt gpl any shap and any way you like.

[ more meandering arguments....]

What has this to do with the GPL ?!?

KSP expects its mods to be placed in GameData and only looks for them there.  By convention, mods live in separate subdirectories under GameData.  And like @linuxgurugamer says, a *very* common player mistake is to place mods in the wrong file system location, causing all sorts of issues.

Sure, the GPL allows you to fork code.  And even modify the code wrong so that it fails, sometimes silently.  But that has nothing to do with what's happening here.

This is about coding courtesy and user privacy, due to the code investigating the file system.  But if done correctly, it can be effective and courteous and respect privacy.

Considering that @linuxgurugamer will be publishing the code, that can be checked too.  And considering @linuxgurugamer's dedication to KSP modding done over the many years in an outstanding manner, I would expect the code to comply to be courteous and to respect privacy.

Edited by Jacke
Link to comment
Share on other sites

why not one .dll, and have each mod include a .txt file to work with it? I like that better - only one copy of the .dll.

heck, the .version file should have enough information to start with

 

so the new .dll reads the .version files, and check to see if installed correctly. or something like that.

Link to comment
Share on other sites

9 minutes ago, Jacke said:

Sure, the GPL allows you to fork code.  And even modify the code wrong so that it fails, sometimes silently.  But that has nothing to do with what's happening here.

GPL's origin is also about replacing & removing tertiary/external libraries whenever a user may seem it fit. And not putting any barrier whatsoever to empower the user to do so.

Link to comment
Share on other sites

8 minutes ago, paul23 said:

GPL's origin is also about replacing & removing tertiary/external libraries whenever a user may seem it fit. And not putting any barrier whatsoever to empower the user to do so.

The GPL says nothing explicitly about that.  It allows the forking and modifying of code if the user wishes.  This isn't about this.  This is about having a mod's code check if it's in the correct location so it can work correctly.  Which isn't in the GPL.

Link to comment
Share on other sites

1 hour ago, paul23 said:

So why do the check in the first place? How the software handles is up to the user, as creator of gpl software you shouldn't try to influence that and you should be happy if people tear it apart and try to test unknown ways

For someone who has been around the forums for 5 years, you seem to be unaware of the countless times people install mods in the wrong location.  You also seem to ignore what this is supposed to do, and the reasons which I explained earlier why I'm adding this.

Beyond that, see the above message from @Jacke , who says the rest of what I was going to say

 

Link to comment
Share on other sites

2 hours ago, paul23 said:

So why do the check in the first place?

Because KSP mods, especially parts mods are path specific.  There are tons of times the people put them in the wrong place, then things don't work, and we waste time helping them troubleshoot it.  This often takes many posts and eventually a screenshot of their gamedata folder.

And @linuxgurugamer just beat me to it. :sticktongue:

Link to comment
Share on other sites

40 minutes ago, zer0Kerbal said:

why not one .dll, and have each mod include a .txt file to work with it? I like that better - only one copy of the .dll.

heck, the .version file should have enough information to start with

 

so the new .dll reads the .version files, and check to see if installed correctly. or something like that.

Because it would then have to search for the .version files, etc.  This way no searching needs to be done.

I've released one parts-only mod with it, Bargain Rockets, you can see how it works there

39 minutes ago, paul23 said:

GPL's origin is also about replacing & removing tertiary/external libraries whenever a user may seem it fit. And not putting any barrier whatsoever to empower the user to do so.

Please explain to me what your discussion of the GPL has to do with this?  Because I can't see anything in any of my posts where I mentioned the GPL or any other licensing. 

If you have questions about what this is doing, fine.  But leave licensing out of it, since there is nothing mentioned about it

Link to comment
Share on other sites

5 minutes ago, Nertea said:

@linuxgurugamer, what if this was simply an optional block in the AVC version file and a feature that was rolled into there?

That would be fine if people weren't busily deleting all the MiniAVC.dll files and not installing the full AVC mod.

I thought a lot about this.  Adding the DLL actually takes longer than just updating the AVC version file would take.  At least this way, I know that if someone tries to install a single parts-only mod of mine, that they will either install it correctly or will be told that they installed it to the wrong location.

It's a good idea @Nertea, and I'll think about it.  I'll probably add it after I'm done with all the 1.8 updates, but as of now, I have about 180 mods to go, so it's going to be at least a month or so before I do anything new other than bug fixes.

What I'll do is get out a specification in the next day or so as to what it will be, so that people can start adding it now for when it is released.  Probably just a one liner, but I want to make sure I cover all bases

 

Edited by linuxgurugamer
Link to comment
Share on other sites

5 minutes ago, paul23 said:

Why discomfort people when just to try to fix "foolish" behaviour? I fail to see what the problem is? People installing in the wrong location is their problem.

People installing in wrong location and then asking for help when the mod doesn't work (or just saying 'it doesn't work') becomes the mod author's problem - at least in that other more useful feedback is obscured, even if you discount that mod authors typically try to help people get their mods working.

This does sound like a great idea.  I'm a bit hesitant on adding yet another set of mini-dlls and like the idea of adding a config line to the .version file - but either way it's a good idea.

Link to comment
Share on other sites

10 minutes ago, paul23 said:

Why discomfort people when just to try to fix "foolish" behaviour? I fail to see what the problem is? People installing in the wrong location is their problem.

Please explain how a silent DLL "discomforts" people?  It only makes noise when there is a problem

Link to comment
Share on other sites

@DStaal @Nertea

I'm thinking about the change to the .version file.  I'm thinking of something along these lines:

	"INSTALL_LOC":
	{
		"FILE":         "fileName",
		"DIRECTORY":    "dirName",
		"MESSAGE":      "message to display"
	}

If multiple files would need to be checked:

	"INSTALL_LOC_1":
	{
		"FILE":         "fileName",
		"DIRECTORY":    "dirName",
		"MESSAGE":      "message to display"
	},
	"INSTALL_LOC_2":
	{
		"FILE":         "fileName",
		"DIRECTORY":    "dirName",
		"MESSAGE":      "message to display"
	},

 

The message line would  be optional, if not there, then a generic message with the mod name and other appropriate info would be displayed

Link to comment
Share on other sites

20 minutes ago, paul23 said:

Why discomfort people when just to try to fix "foolish" behaviour? I fail to see what the problem is? People installing in the wrong location is their problem.

I would say they discomfort many more people (including mod authors) when they come onto the forums to complain that mod X doesn't work. It takes probably on average 4+ replies to get the relevant information from them only to realize they installed it wrong.

Link to comment
Share on other sites

24 minutes ago, linuxgurugamer said:

Please explain how a silent DLL "discomforts" people?  It only makes noise when there is a problem

Like I said: I might have a filesystem where the files aren't there on "loading" and only later are there. Or I might use some linkage that the game understands but the way you check for existance does not. Or I might work over a network drive... I've seen lots of times when it should be unobtrusive, and it is at first sigh, but in the end it turns out to be a pain in the ass.

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