Ludeon Forums

Ludeon Forums

  • June 01, 2020, 05:27:05 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 7

Author Topic: [LIB] ModCheck: patch tests and error logging for mod loading  (Read 23511 times)

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
[LIB] ModCheck: patch tests and error logging for mod loading
« on: October 31, 2017, 06:57:04 PM »

Toolkit for xml modders. Adds 13 new patch operations. Eliminate the need for patchmods. Patch according to presence, order or version of mods. Reorder xml elements, write patching results and test results to the log. Allow faster patching (shorter startup time) and measure how long each patch spends patching.

The primary task for ModCheck is to remove the need for patch mods. It's done by adding test operations, which can tell if another mod is loaded, if one mod is before another, is of at least a certain version, either in About or in ModSync. Each of those can be reversed (not loaded etc).

Adds logic operators, like sequence, AND, OR, If else conditions. This can be used together with the test operations or vanilla operations to make complex test conditions if needed.

Boost performance. Need to do multiple patching operations on the same building? Search, keep the result and run a list of patches without performing a full xpath search for each operation.

Added a bed and want it to appear in the build menu next to the vanilla beds? The Move operation allows you to alter where your modded building will appear.

Feature rich log writing. Get operations to write messages, warnings and errors if operations succeed or fail. Tell the user if a needed mod isn't loaded or load order is incorrect. Also allow writing conditionless with whatever message you might want to add.

Profile patches. Measure how much time is spend on each patch. ModCheck is aware of which mod owns which patch, meaning you can get a precise view of the startup time of your mod. You can name your patches if root operation is from ModCheck, like ModCheck.Sequence. This will allow performance printout with names rather than just patch 1,2,3....

Links:
Steam
GitHub (direct download, source code and wiki manual)

Quote from: Changelog
Updating ModCheck will not break existing xml files unless stated otherwise.

v1.8.1
- Fixed compatibility issue with updated Rimworld. Profiling works again.
- Updated version URL for Fluffy's Mod Manager

v1.8 (RW 1.0)
Update to about only. The DLL file will not even have to be updated.

- RimWorld 1.0 support
- Added support for Fluffy's Mod Manager

v1.8
This is a significant update from a coding point of view. B19 vanilla changed completely regarding patching.
While the code is significantly better, all Harmony calls from ModCheck had to be redesigned and rewritten.

- Added B19 support
- Added Search operation to speed up patching when the same object is patched multiple times in a row
- Added Move operation to control cases where order matters (like order of building buttons)
- Patch profiling now measures the time more accurately (less rounding errors)

XML BREAKING ALERT!!!
Removed FindFile operation (vanilla rewrite renders it both obsolete and impossible to implement)
Any xml file with FindFile will need updating.

v1.7
- Speedboost: cached mod indexes for massive speed boost of some ModCheck internals
- Rewritten the log writing system to give better control/more features to patch writers
- Rewritten error messages to make it easier to find the error
- Changed profiling output. Total on top, one entry for each mod
- All PatchOperation names can now be used starting with both upper and lower case (fixes naming inconsistency)
- Added new mode to LoadOrder. It can now use first and last strings instead of the old approach (which still works)
- Added Sequence operation, which does the same as the vanilla operation, but with ModCheck specific options
- Added logic operations AND, OR, IfElse, Loop and Once
- Added warning/error if outdated versions of ModCheck are being loaded (risk of new vs old conflicts)
- Added a preview logo (thanks to larSyn for drawing it)
- Added support for ModSync RW
- Fix: profiling now displays correct time if the hardware has a high precision timer
- Fix: profiling will no longer cut off the output if you have a lot of patches
- Removed the need to include yourMod and modName unless they are actually used

v1.6
- Added FindFile to greatly speed up patch files
- Added patch operation profiling (with verbose logging only)

v1.5
- Added ModSync.xml
- Added PatchOperation isModSyncVersion

v1.4
- Fixed issue where cache failed to update as needed

v1.3
- Fix: checks are now only executed once (massive performance boost)
- Fix: writing to the log will now always only write one line and never repeat the same many times

v1.2
- Added custom message support (like logging: My mod detected modX and will patch itself accordingly)
- Added ability to detect another mod by more than one name (like name v1.3 and name v1.4)
- Major code redesign to greatly reduce the risk of bugs when adding new features

Note: stopped releasing for A17 due to the release of stable B18.
If you want to use A17, copying the v1.2 DLL will likely work, but it's untested.

v1.1
- Converted to mod layout for steam release

v1.0
- Initial release

« Last Edit: May 29, 2019, 05:14:26 PM by Nightinggale »
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #1 on: October 31, 2017, 09:39:16 PM »

reserved
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #2 on: October 31, 2017, 09:39:24 PM »

reserved
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

kaptain_kavern

  • Planetologist
  • ****
  • Posts: 2074
  • started 10 mods in one tick.
    • View Profile
    • RimWorldMod Slack - A place for live chatting about RimWorld modding
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #3 on: November 01, 2017, 01:43:16 AM »

Looks quite promising. Thanks for making that

Redfire1200

  • Drifter
  • **
  • Posts: 57
  • Potatoes
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #4 on: November 01, 2017, 06:36:56 PM »

including error messages for incorrect setup. .
What exactly do you mean by this, do you mean if I was making a mod and did something wrong in the defs it would point it out? Or do you mean if a put the mods in the wrong order or some thing like that?
Logged
The Red Empire shall rise, The Red Empire shall grow... POTATOES!!!

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #5 on: November 01, 2017, 07:06:25 PM »

including error messages for incorrect setup. .
What exactly do you mean by this, do you mean if I was making a mod and did something wrong in the defs it would point it out? Or do you mean if a put the mods in the wrong order or some thing like that?
No, it refers to incorrect setup of by the user in the mod load order list. It means the user will get an error if required mod is not loaded, is loaded after your mod if it has to be before etc. It will not verify the work you have done in your xml files and you have to make a patch file to tell what it should test on game startup. The front page on GitHub has some examples of setup at the bottom.
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

Redfire1200

  • Drifter
  • **
  • Posts: 57
  • Potatoes
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #6 on: November 01, 2017, 07:25:16 PM »

So if a mod needed hugslib or jecstools loaded first and I put them last it would tell me?
Logged
The Red Empire shall rise, The Red Empire shall grow... POTATOES!!!

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #7 on: November 01, 2017, 07:41:52 PM »

So if a mod needed hugslib or jecstools loaded first and I put them last it would tell me?
Yes it's precisely that, though depending on configuration, it can tell about incompatible mods and outdated mods as well.

Half of the code from the first example in the guide. You want to make ModX require HugsLib.
Code: [Select]
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="ModCheck.isModLoaded">
<modName>HugsLib</modName>
<yourMod>ModX</yourMod>
<errorOnFail>true</errorOnFail>
</li>
<li Class="ModCheck.loadOrder">
<modName>HugsLib</modName>
<yourMod>ModX</yourMod>
<errorOnFail>true</errorOnFail>
</li>
</operations>
</Operation>
It can produce the following errors: (just one, not both at once)
Code: [Select]
Missing mod: "HugsLib", needed by "ModX"
Mod load order: "HugsLib" needs to be loaded before "ModX"
As all other errors, those lines will show up in the log, be printed in red and force the log to appear on game start.

And do remember that those checks returns a bool, meaning they can be used for conditional patching as well. If errorOnFail is not mentioned, it will not print to the log, meaning you can make patch operations trigger on presence of other mods. No need to make separate patch mods to add compatibility.
« Last Edit: November 01, 2017, 07:45:59 PM by Nightinggale »
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #8 on: November 06, 2017, 12:45:42 AM »

I have realized I didn't add support for the error strings to be translated. I plan to fix that as well as adding support for a custom error message.

Since it looks like I will be updating anyway, do anybody have any feature requests?
By design you can add whatever you want in as many tags as you like and then it has access to do whatever we want in C# as it has access to everything in the game and then it results in a true/false statement to use to tell if something should be patched. This gives a whole lot of options, but I don't know what you need, so tell me.

Another question: do anybody use this?
So far there has been just 5 downloads and I don't know of any mods, which use this or plan to use it. I'm considering putting development on hold until I know for sure people are actually using this. If you aren't using this, I would like to know why and if there is anything I can do about it. Part of my goal is to get mods to tell me when I make a mistake in mod load order (it has happened), but this tool doesn't help with that problem unless mod creators/maintainers add ModCheck and fill out a patch file with the mod requirements.
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

kaptain_kavern

  • Planetologist
  • ****
  • Posts: 2074
  • started 10 mods in one tick.
    • View Profile
    • RimWorldMod Slack - A place for live chatting about RimWorld modding
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #9 on: November 06, 2017, 10:39:48 AM »

A18 will have a method to check for other mods natively BTW

https://ludeon.com/forums/index.php?topic=36208.msg375367#msg375367

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #10 on: November 06, 2017, 01:43:22 PM »

A18 will have a method to check for other mods natively BTW
Looks like I'm not doing too well  :'(

I had a look since it's already in A18 unstable. I find it a bit odd because it requires a list of mods and it is true if one or more is present. In other words to check for 3 mods, you have to make 3 checks, not one check with 3 mods in the list.

Now I'm considering major redesigning of ModCheck. It should be one check, but then it contains lists, like:
Code: [Select]
<MyModName>something</MyModName>
<MandatoryBefore>
    <li>HugsLib</li>
</MandatoryBefore>
<Incompatible>
    <li>some other mod</li>
</Incompatible>
Would people use it if it is written like this?

Would people be more likely to use this if I turn this into a mod? (no need to include a DLL file in your mod)

What would it take to make this a must have mod? I would really like if the mods themselves tell if your modlist results in incorrectly working mods.
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [TOOL] ModCheck: patch tests and error logging for mod loading
« Reply #11 on: November 08, 2017, 09:05:52 PM »

Released version 1.1. The only change is that it can now be loaded as a mod. This allows me to put it on steam. Hopefully this will make more people aware of what I have made as it seems to be fairly unknown and unused so far   :'(
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

larSyn

  • Developer
  • Colonist
  • *****
  • Posts: 150
  • Refugee
    • View Profile
Re: [LIB] ModCheck: patch tests and error logging for mod loading
« Reply #12 on: November 11, 2017, 09:08:26 PM »

Released version 1.1.....Hopefully this will make more people aware of what I have made as it seems to be fairly unknown and unused so far   :'(

Don't feel bad, Nightingale.  After you posted in my Help thread I downloaded it and rewrote all my patches using it.  I didn't know about the new Patch Operation either... ::)  Anyway, ModCheck worked very well during my testing, and I plan on using it for now.  I would definitely be interested in seeing what else you add.
Logged

Nightinggale

  • Colonist
  • ***
  • Posts: 378
  • Refugee
    • View Profile
Re: [LIB] ModCheck: patch tests and error logging for mod loading
« Reply #13 on: November 12, 2017, 12:02:50 AM »

Don't feel bad, Nightingale.
I don't feel bad about getting awareness anymore. In the very precisely 3 days it has been on steam, ModCheck has gained 98 subscribers. Granted that's for A17 and A18 combined, but A18 has 67 subscribers alone, meaning it is somewhat known by now.

After you posted in my Help thread I downloaded it and rewrote all my patches using it.  I didn't know about the new Patch Operation either... ::)  Anyway, ModCheck worked very well during my testing, and I plan on using it for now.
First mod confirmed to actually using ModCheck. Sounds good and thanks for reporting back. While I expected it to work just fine, it's good to know other people can figure out how to make it work as well.

I would definitely be interested in seeing what else you add.
Me too. Right now all I can think of is allowing the strings to be translated and to allow custom error messages, like adding an xml tag of a line, which will be used if set. While I might change lots of stuff in the future, I plan to be backward compatible meaning the patch xml files being written now should work with future versions as well.

Ideas for new features are welcome.
Logged
ModCheck - boost your patch loading times and include patchmods in your main mod.

larSyn

  • Developer
  • Colonist
  • *****
  • Posts: 150
  • Refugee
    • View Profile
Re: [LIB] ModCheck: patch tests and error logging for mod loading
« Reply #14 on: November 15, 2017, 10:18:53 AM »

I don't feel bad about getting awareness anymore. In the very precisely 3 days it has been on steam, ModCheck has gained 98 subscribers. Granted that's for A17 and A18 combined, but A18 has 67 subscribers alone, meaning it is somewhat known by now.

Yeah, Steam seems to be the place to post mods.  I got far more users there than from here.  But, that's all right, I like it here.  Lots of helpful, friendly people.

...While I expected it to work just fine, it's good to know other people can figure out how to make it work as well.

The only bit of trouble I had was which mod name to use, the folder name or the name in About.xml.  I obviously figured it out, but maybe you should throw that in the guide on your Github page to prevent any future confusion.  Other than that, everything was very easy to follow.

Me too. Right now all I can think of is allowing the strings to be translated and to allow custom error messages, like adding an xml tag of a line, which will be used if set. While I might change lots of stuff in the future, I plan to be backward compatible meaning the patch xml files being written now should work with future versions as well.

Ideas for new features are welcome.

That sounds good.  I was going to ask about the patch operation staying the same, since I don't really want to go back and rewrite it all...lol 

Would something that lets users know about compatibility patches be possible?  For example, I have a patch for Vegetable Garden in my mod.  When someone activates my mod would it be possible to have it say something like "Hey this mod works great with Vegetable Garden!" or something else along those lines?  Perhaps have it in green text on the log, a pop-up, or something in the Mod Settings menu?  And, while I'm at it here, maybe also a way to direct them to the Steam/forum page to download it (a url in the xml maybe)?  I'm just starting to learn about C#, so I don't really know what is and isn't doable in regards to this kind of stuff...so don't worry about it if this isn't possible.
Logged
Pages: [1] 2 3 ... 7