PDA

View Full Version : Sanitize Mod Files Windows Command Script



zombielord
May 14th, 2020, 17:24
Put together a some scripts for windows to Sanitize the mod files so I thought I'd share it.

It unpacks mod files, replaces characters in the db.xml, and repacks the file and replaces the original mod file.
It implements all the changes the listed as common substitutions.

Common Substitutions
searching replacing (description)
… ... (3 periods)
‘ ' (standard single quote)
’ ' (standard single quote)
“ " (standard double quote)
” " (standard double quote)
• * (asterisk)
– - (standard dash)
— - (standard dash)
& & (note this looks for & with a space after it)

Update 5-18-20: Added 2 if file exists db.xml / common.xml checks for the modules before attempting to sanitize and create them.

(WINDOWS ONLY) Unzip the contents of Sanitize_Mod into its own folder and just drag and drop your mod files onto CleanModFile.cmd

IMPORTANT!!! This creates and deletes files so its a use at your own risk kind of thing. Everything works fine for me, but I make no guarantees.

LordEntrails
May 14th, 2020, 17:32
Nice work. I'm sure this is going to make lots of people happy :)

Trenloe
May 14th, 2020, 21:17
Moved to the Armory sub-forum.

RocksFall
May 18th, 2020, 08:35
Im sanitizing a .mod right now. I have now idea what this does but it looks like fun. Thnx man!

damned
May 18th, 2020, 13:46
Is this effective against corona viruses?

zombielord
May 18th, 2020, 16:38
It purges any heretical glyphs to the machine code and renders the blessings of the Omnissiah to appease the machine spirit.

OR...

It swaps out bits of text to common substitutions so things will display nicely in Unity or with non-extended font sets.

hawkwind
May 18th, 2020, 18:22
just tried it on Shaderavens Bestairy PF2 mod and it broke it, neither classic or unity versions could see the module any more

zombielord
May 18th, 2020, 20:55
Thanks for the feedback. I'm doing a test with that specific file.
Results of testing using current file: Created (SR-U) Bestiary.mod. The mod file created successfully. I don't have the pathfinder rule set to verify but I've included the created file.

Note: it did take a long time for the script to parse through everything, but that's not un-common for mod files with lots of text.
Let me know if it works for you. If not I'll do some more digging.

I did, recently add a new check to see if db.xml and common.xml exists in the mod files before creating them

hawkwind
May 21st, 2020, 11:09
the mod loads but i have this problem
35848
the damage should be d4-1
its a problem with Paizo using a &"150 en dash instead of a regular minus, this isn't a problem in classic but in Unity...

Talyn
May 21st, 2020, 13:48
I don't have the pathfinder rule set to verify

Yes, you do, it ships free with FG.


ts a problem with Paizo using a en dash instead of a regular minus

That is the correct character to use for publication; every publisher does it, including everyone's oh-so-precious Wizards of the Coast. Copying out of a PDF will get the correct-for-publication characters, which won't work in the trash encoding set that the cross-platform Unity library is currently stuck with. Having said that, it is the incorrect character for any computer to do math with, such as being present in a damage string here in FG.

I haven't used this script, but what it should probably do is check for both the character itself and the entity code for the character range 128–159 if it's doing pure text searching. There are plenty of community modules out there where the author just copied directly out of the PDF (which of course will have the correct characters) and never did any sanitization on their own. FG will by default convert the five characters which are XML entities, but pretty much everything else it leaves alone.

zombielord
May 22nd, 2020, 06:57
Thanks Talyn, I really haven't spent much time checking out all the rulesystems included with purchase but it's good to know.

I'll add in some conversions looking for and converting the entity code for the range listed. Currently it is what is listed in the first post, but expect an update soon-ish.
On a related note Modules created in classic convert them to the entity code, but modules created in UNITY does not (however the default font used with corerpg supports those characters).