Jump to content

CompatibilityChecker Discussion Thread


ferram4

Recommended Posts

May I suggest a new thread in "Add-on Development" ( for me General Add-on Affairs & Add-on Requests and Support are "the place where people rant on MJ"), that start with the current goals and implementation ?

Right now a dev that want to add it need to find this thread ans then find the proper post.

Edit : and one more thing. Can we add a warning to people who run KSP on Windows from the Program File folders ? I stopped counting how many MJ users had their plugin banned from loading by Windows "security" feature or bad a AV.

Edited by sarbian
Link to comment
Share on other sites

@sarbian> I don't know how far you'll get with that considering Steam by default installs to a particular "Program Files" directory. I can't recall if you can specify what directory a particular game is installed to, however, you'd be asking the entire steam KSP user base to change their installation methods. It may be a one-off deal to install to a different directory, but, some people just don't know.

Link to comment
Share on other sites

Fair point Nathan :)

Pontiac: I agree it some work on the user end, but it fixed addon for a few of my users. I'll see if I can write a post with the steps

Edited by sarbian
Link to comment
Share on other sites

Just found this thread, I think the warning is a good idea. Just implemented the simplest version of it myself, just giving a warning, but not disabling stuff, since I seldom see game breaking bugs due to the nature of my part modules.

Their version errors are usually only constrained to themselves.

StYF1cH.png

Link to comment
Share on other sites

May I suggest a new thread in "Add-on Development" ( for me General Add-on Affairs & Add-on Requests and Support are "the place where people rant on MJ"), that start with the current goals and implementation ?

Yes, it seems this is necessary.

Just found this thread, I think the warning is a good idea. Just implemented the simplest version of it myself, just giving a warning, but not disabling stuff, since I seldom see game breaking bugs due to the nature of my part modules.

Why did you create your own warning?

There are a few benefits to the shared warning system we've been using. Firstly, updates to the system can be made by any participating mod, which is helpful when users update inconsistently. Secondly, it may carry more weight if users believe the warning is coming from KSP itself.

Link to comment
Share on other sites

There are a few benefits to the shared warning system we've been using. Firstly, updates to the system can be made by any participating mod, which is helpful when users update inconsistently. Secondly, it may carry more weight if users believe the warning is coming from KSP itself.

I think this might be caused by a feeling (that I also had) to display a "personalized" message to inform about the state of the mod in the new version. Perhaps it would be possible to include a "see more" button if defined?

Link to comment
Share on other sites

Yes, it seems this is necessary.

Why did you create your own warning?

There are a few benefits to the shared warning system we've been using. Firstly, updates to the system can be made by any participating mod, which is helpful when users update inconsistently. Secondly, it may carry more weight if users believe the warning is coming from KSP itself.

The code I saw you had posted did not seem to include anything that told me there was a common system up and running. I only read the first and last few pages though...

edit:

I re-read the code I had just glanced at previously and saw that it does handle multiple mods running the same piece of code, so I'll try to use your code.

Edited by Snjo
Link to comment
Share on other sites

FYI I added it to to Mechjeb2.

I do a full version check but nothing is disabled when it fails.


return Versioning.version_major == 0 && Versioning.version_minor == 23 && Versioning.Revision == 5;

Link to comment
Share on other sites

  • 3 months later...

Here's CompatibilityChecker version 3. It's a small update to add support for Unity version checking. This feature might be removed at a later date based on feedback and whether it turns out to be useful after the KSP 0.24 release.

Remember: Only the latest installed version of CompatibilityChecker will run, even if that version comes with a mod that's compatible, so it's not crucial that you update.


/**
* Copyright (c) 2014, Majiir
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;

/*-----------------------------------------*\
| SUBSTITUTE YOUR MOD'S NAMESPACE HERE. |
\*-----------------------------------------*/
namespace Compatibility
{

/**
* This utility displays a warning with a list of mods that determine themselves
* to be incompatible with the current running version of Kerbal Space Program.
*
* See this forum thread for details:
* http://forum.kerbalspaceprogram.com/threads/65395-Voluntarily-Locking-Plugins-to-a-Particular-KSP-Version
*/

[KSPAddon(KSPAddon.Startup.Instantly, true)]
internal class CompatibilityChecker : MonoBehaviour
{
public static bool IsCompatible()
{
/*-----------------------------------------------*\
| BEGIN IMPLEMENTATION-SPECIFIC EDITS HERE. |
\*-----------------------------------------------*/

// TODO: Implement your own compatibility check.
//
// If you want to disable some behavior when incompatible, other parts of the plugin
// should query this method:
//
// if (!CompatibilityChecker.IsCompatible()) {
// ...disable some features...
// }
//
// Even if you don't lock down functionality, you should return true if your users
// can expect a future update to be available.
//
return false;

/*-----------------------------------------------*\
| IMPLEMENTERS SHOULD NOT EDIT BEYOND THIS POINT! |
\*-----------------------------------------------*/
}

public static bool IsUnityCompatible()
{
/*-----------------------------------------------*\
| BEGIN IMPLEMENTATION-SPECIFIC EDITS HERE. |
\*-----------------------------------------------*/

// TODO: Implement your own Unity compatibility check.
//
return false;

/*-----------------------------------------------*\
| IMPLEMENTERS SHOULD NOT EDIT BEYOND THIS POINT! |
\*-----------------------------------------------*/
}

// Version of the compatibility checker itself.
private static int _version = 3;

public void Start()
{
// Checkers are identified by the type name and version field name.
FieldInfo[] fields =
getAllTypes()
.Where(t => t.Name == "CompatibilityChecker")
.Select(t => t.GetField("_version", BindingFlags.Static | BindingFlags.NonPublic))
.Where(f => f != null)
.Where(f => f.FieldType == typeof(int))
.ToArray();

// Let the latest version of the checker execute.
if (_version != fields.Max(f => (int)f.GetValue(null))) { return; }

Debug.Log(String.Format("[CompatibilityChecker] Running checker version {0} from '{1}'", _version, Assembly.GetExecutingAssembly().GetName().Name));

// Other checkers will see this version and not run.
// This accomplishes the same as an explicit "ran" flag with fewer moving parts.
_version = int.MaxValue;

// A mod is incompatible if its compatibility checker has an IsCompatible method which returns false.
String[] incompatible =
fields
.Select(f => f.DeclaringType.GetMethod("IsCompatible", Type.EmptyTypes))
.Where(m => m.IsStatic)
.Where(m => m.ReturnType == typeof(bool))
.Where(m =>
{
try
{
return !(bool)m.Invoke(null, new object[0]);
}
catch (Exception e)
{
// If a mod throws an exception from IsCompatible, it's not compatible.
Debug.LogWarning(String.Format("[CompatibilityChecker] Exception while invoking IsCompatible() from '{0}':\n\n{1}", m.DeclaringType.Assembly.GetName().Name, e));
return true;
}
})
.Select(m => m.DeclaringType.Assembly.GetName().Name)
.ToArray();

// A mod is incompatible with Unity if its compatibility checker has an IsUnityCompatible method which returns false.
String[] incompatibleUnity =
fields
.Select(f => f.DeclaringType.GetMethod("IsUnityCompatible", Type.EmptyTypes))
.Where(m => m != null) // Mods without IsUnityCompatible() are assumed to be compatible.
.Where(m => m.IsStatic)
.Where(m => m.ReturnType == typeof(bool))
.Where(m =>
{
try
{
return !(bool)m.Invoke(null, new object[0]);
}
catch (Exception e)
{
// If a mod throws an exception from IsUnityCompatible, it's not compatible.
Debug.LogWarning(String.Format("[CompatibilityChecker] Exception while invoking IsUnityCompatible() from '{0}':\n\n{1}", m.DeclaringType.Assembly.GetName().Name, e));
return true;
}
})
.Select(m => m.DeclaringType.Assembly.GetName().Name)
.ToArray();

Array.Sort(incompatible);
Array.Sort(incompatibleUnity);

String message = "Some installed mods may be incompatible with this version of Kerbal Space Program. Features may be broken or disabled. Please check for updates to the listed mods.";

if (incompatible.Length > 0)
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods detected: " + String.Join(", ", incompatible));
message += String.Format("\n\nThese mods are incompatible with KSP {0}.{1}.{2}:\n\n", Versioning.version_major, Versioning.version_minor, Versioning.Revision);
message += String.Join("\n", incompatible);
}

if (incompatibleUnity.Length > 0)
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods (Unity) detected: " + String.Join(", ", incompatibleUnity));
message += String.Format("\n\nThese mods are incompatible with Unity {0}:\n\n", Application.unityVersion);
message += String.Join("\n", incompatibleUnity);
}

if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0))
{
PopupDialog.SpawnPopupDialog("Incompatible Mods Detected", message, "OK", true, HighLogic.Skin);
}
}

private static IEnumerable<Type> getAllTypes()
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Type[] types;
try
{
types = assembly.GetTypes();
}
catch (Exception)
{
types = Type.EmptyTypes;
}

foreach (var type in types)
{
yield return type;
}
}
}
}
}

Example implementation of the (required) KSP version compatibility check:


public static bool IsCompatible()
{
const int compatibleMajor = 0;
const int compatibleMinor = 23;
const int compatibleRevision = 5;

return (Versioning.version_major == compatibleMajor) && (Versioning.version_minor == compatibleMinor) && (Versioning.Revision == compatibleRevision);
}

Example implementation of the (optional) Unity version compatibility check:


public static bool IsUnityCompatible()
{
return Application.unityVersion == "4.3.3f1";
}

Edited by Majiir
Link to comment
Share on other sites

  • 3 months later...
By not using a mod that is incompatible with your KSP.

That's like saying "hey, my mac game says it doesn't work on windows, how do I make it stop?"

Actually, it's a lot more like saying, "How do I get rid of the nag box that comes up EVERY TIME I RUN THE GAME saying my mods don't work when they actually work perfectly fine?"

Forget about it. I'll figure it out myself. Jesus Christ.

Link to comment
Share on other sites

If I stay away from requesting support for that combination I have to deal with a nag box every time I run the game until the plugin author decides to update. It's moot at this point. I recompiled one of them with the new version number and used a hex editor to fix the other two, since their source was incomplete.

In any case, we could be solution-oriented and maybe consider putting a check-box on the nag that allows it to not re-notify until there's a change (since end-users don't actually care about implementation details), but let's stick with the forum culture and use the "deal with it" approach.

Link to comment
Share on other sites

The entire point is to tell people that they're running out-of-date versions of mods that were not built for the KSP version they're running. Letting them shut off the reminder doesn't get them to update, and that's the entire point. Part of the reason that there isn't an alternative disable method is to put users in the position of either A) updating the mod like they should have in the first place or B) assume responsibility for themselves and compile it for their own use.

I don't see the problem, everything appears to be working as intended. :)

Link to comment
Share on other sites

The entire point is to tell people that they're running out-of-date versions of mods that were not built for the KSP version they're running.

Due diligence. Fine. I'm 200% okay with that.

Letting them shut off the reminder doesn't get them to update, and that's the entire point.

Contradictory to your previous statement.

Also, if there were current versions I would have installed them, although that's entirely irrelevant, since it's not up to you or anyone else to try and coerce me to install something on my own machine.

Part of the reason that there isn't an alternative disable method is to put users in the position of either A) updating the mod like they should have in the first place or B) assume responsibility for themselves and compile it for their own use.

A) If I don't have a constant nag screen to harass me I suddenly become incapable of updating my software. Thank you, mommy, for holding my hand through this difficult process.

B) Which is totally different from assuming responsibility and checking a check-box, which is commonly accepted warning behavior

I don't see the problem, everything appears to be working as intended. :)

Jogging is good for your health. How about someone comes to your house at 3AM every morning and knocks on your door as hard as they can and then runs off? If you start jogging on a daily basis then they'll stop.

Is that problematic? Or is that working as intended?

Link to comment
Share on other sites

Also, if there were current versions I would have installed them, although that's entirely irrelevant, since it's not up to you or anyone else to try and coerce me to install something on my own machine.

A message telling you that something is incompatible is coercive... That's a new one to me.

A) If I don't have a constant nag screen to harass me I suddenly become incapable of updating my software. Thank you, mommy, for holding my hand through this difficult process.

If users don't get the warning, they assume everything is hunky-dory. The reason this exists is because so many users are, apparently, incapable of remembering to update their mods.

B) Which is totally different from assuming responsibility and checking a check-box, which is commonly accepted warning behavior

You and I both know that people tell warnings to go away without thinking about them. Then, they come and blame us for giving them a way around it. Want to dismiss the warning? Go address the problems it's warning about.

Jogging is good for your health. How about someone comes to your house at 3AM every morning and knocks on your door as hard as they can and then runs off? If you start jogging on a daily basis then they'll stop.

Is that problematic? Or is that working as intended?

I didn't know that you were forced to install a mod (which is the only way to have a CC stuff), that it loads up KSP at inopportune times when you're trying to sleep, and that you had no other recourse. Would you mind telling us who forcibly installed that mod that takes over your computer so badly that it warrants a comparison to being woken up a 3AM ceaselessly? I didn't realize it was so bad, I thought we were talking about a message that popped up about a mod that you installed of your own volition was out of date when you went to play on your free time, not something that horrifying.

Link to comment
Share on other sites

A message telling you that something is incompatible is coercive... That's a new one to me.

Except that the statement you quoted there was not in the context of the notification. It was in the context of you saying things like

"Letting them" (because you decide what I may or may not do)

"get them to" (that's called coercion)

"put users in the position of" (who the hell do you think you are?)

"should have in the first place" (kay mom - still ignoring the fact that if there's no update you're stuck with the nag)

If users don't get the warning, they assume everything is hunky-dory.

I am not, nor have I ever, suggested that no warning be issued, and you know it.

The reason this exists is because so many users are, apparently, incapable of remembering to update their mods.

Fantastic. I hope it helps them. This is completely irrelevant, since - again - I'm not arguing that no notification should be given.

You and I both know that people tell warnings to go away without thinking about them.

SOME people do. That's their problem.

Then, they come and blame us for giving them a way around it.

[snip.] Not only would no one complain about it, they clearly never have, since it's never been implemented.

Want to dismiss the warning? Go address the problems it's warning about.

Fine.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;

namespace Compatibility
{
[KSPAddon(KSPAddon.Startup.Instantly, true)]
internal class CompatibilityChecker : MonoBehaviour
{
public static bool IsCompatible() { return true; }
public static bool IsUnityCompatible() { return true; }
private static int _version = 99;
public void Start() {}
}
}

I didn't know that you were forced to install a mod (which is the only way to have a CC stuff), that it loads up KSP at inopportune times when you're trying to sleep, and that you had no other recourse. Would you mind telling us who forcibly installed that mod that takes over your computer so badly that it warrants a comparison to being woken up a 3AM ceaselessly? I didn't realize it was so bad, I thought we were talking about a message that popped up about a mod that you installed of your own volition was out of date when you went to play on your free time, not something that horrifying.

It's just about as horrible as your nonsense about how terrible it would be if the user could have control over the behavior of their program.

KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK KNOCK

Edited by Vanamonde
Language.
Link to comment
Share on other sites

Well, bottom line is that implementation is the modder's choice, not the user's. No matter how annoying or inconveniencing the end user finds the "feature", the only control they have over an author's work is whether they install it (or modify it for personal use, of course.)

Link to comment
Share on other sites

If a mod has a feature that you find unacceptable, you can ask nicely for it to be changed, but that is up to the mod-maker, and if he/she decides not to, that's the end of the story. I'm not saying you should be happy about it, but I am saying you've made your point and it's time to move on. Please don't derail this thread with further argument.

Link to comment
Share on other sites

@Khatharr: I suggest that you try recompiling mods using the code you've provided; I think you'll discover it breaks quite a few of them. Aside from that, remember that you can always just recompile mods that include Compatibility Checker, but in the process not a single mod author who implements it will want to support you. I cannot think of a mod that implements Compatibility Checker that is not updated regularly, so your problem is one of your own making. I sincerely hope you don't run into any old bugs or issues caused by the wrong KSP version, since those ones tend to be quite nasty if they aren't the kind that throw compiler errors. And I'm not being sarcastic, a lot of those are a pain, and if you're getting CC warnings and you're trying to ignore them, you'll run into one of those probably soon.

Link to comment
Share on other sites

Maybe a good way to deal with the "community" woes is to make the popup NOT persist across scenes. This allows the user to simply continue doing what they are doing and blithely ignore helpful messages as they see fit. Simple boolean value change.

Edited by regex
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...