JSON validation for mods

In latest revision I improved json validation which now implements ~90% of latest draft. There are some missing elements but nothing major (and nothing that can be implemented easily).

But the main part is set of schema’s that are used to validate all input from mods (see config/schemas directory). What this means is that vcmi can now find:

  • all typos like incorrectly named field.
  • all missing fields that were marked as required.
  • several other checks like incorrect length of an array
    And the main feature is that instead of crash modders will see exactly what’s wrong with mod :slight_smile:

Surprisingly all of this has almost 0 effect on loading time - 1-2 extra mods impose much bigger delays.

This also revealed several bugs in our mods (cove/witchking). Here are updated versions:
dl.dropbox.com/u/22372764/vcmi/mods/cove.zip
dl.dropboxusercontent.com/u/223 … g-arts.zip
Old versions should work but vcmi will throw a dozen of complains.

Some possibilities for future:

  • Make validation required and drop any data that will not pass it. Right now vcmi detects just too many errors in some 3rd party mods I found. And some of them are obvious bugs.

  • Use or write tool similar to onde to implement some kind of mod making utility.
    repo: exavolt.github.com/onde/

And one more thing - would be great if somebody would recheck schemas especially one that validates bonus system. For example remove fields that should not be used by mods, check if all fields that can accept string ID’s are marked as such, add better description for use in tools like onde.

Good job, will need to have a look at this!

It’s great to hear, that validation is almost completed!
When to wait version 0.93?
This version will much easer life of modder like me :sunglasses:

I removed my old folder and put the one from trunk.

Now get crash because file “modsettings” was not found.

That’s not something I tested often enough. Should be fixed now.

Now it does not load anything, application closes at launch. No crash, though.
VCMI_Client_log.txt (11.3 KB)

You’ve copied config/schemas/settings.json into config/settings.json? You shouldn’t do this.

Deleting config/settings.json should fix this. I’ll try to add some handling for cases similar to this.

Thanks, worked :slight_smile:

I’m to talk about “entry attackClimaxFrame”

I saw logfile for Forge, and there absence of this area reported as error:
“At /graphics
Error: Required entry attackClimaxFrame is missing
Data in CyberDead is invalid!”

I think, this is overstrict.
Nobody garantees, that number of frames for animating attack Up/Straight/Down and for Shoot Up/Straight/Down is the same. So by the way there must be some array for each attack climax Frame.
I think, it at all is not needed parameter.
VCMI can count number of frames in DEF for each attack and just take as Climax frame in the center (if attackClimaxFrame is not specified).

Right now most of configuration file have same set of fields as original .txt files. This field comes from crtraits.txt

Quick check - elves have 12 frames with attack climax at 11
Gogs - 6 out of 8
Lich - 8 out of 11

I haven’t found any creature where “attack climax” is exactly at center. Although this field seems to be used only for ranged attacks so melee creatures don’t need it.

I throught so after looking Cove.
I think than it’s not an error at all (or syntax checker must report error only if SHOOTER ability enabled…