0ad/binaries/data/mods/mod/gui/common/mod.js
wraitii 07e44a75a1 Allow mods to say they should be ignored in replay/MP compatibility checks
Since it is very non-trivial to determine which mods change checksums
and which don't, this relies on modder goodwill (and on verification on
our end for signed mods).

The declaration is an optional "ignoreInCompatibilityChecks" boolean in
mod.json

Also rework slightly the MP lobby mod display to always show the host
mods in a clear manner.

Differential Revision: https://code.wildfiregames.com/D3968
This was SVN commit r25634.
2021-06-02 06:50:16 +00:00

43 lines
1.2 KiB
JavaScript

/**
* Check the mod compatibility between the saved game to be loaded and the engine.
* This is a wrapper around an engine function to allow mods to to fancier or specific things.
*/
function hasSameMods(modsA, modsB)
{
if (!modsA || !modsB)
return false;
return Engine.AreModsPlayCompatible(modsA, modsB);
}
/**
* Print the shorthand identifier of a mod.
*/
function modToString(mod)
{
// Skip version for play-compatible mods.
if (mod.ignoreInCompatibilityChecks)
return mod.name;
return sprintf(translateWithContext("Mod comparison", "%(mod)s (%(version)s)"), {
"mod": mod.name,
"version": mod.version
});
}
/**
* Converts a list of mods and their version into a human-readable string.
*/
function modsToString(mods)
{
return mods.map(mod => modToString(mod)).join(translate(", "));
}
/**
* Convert the required and active mods and their version into a humanreadable translated string.
*/
function comparedModsString(required, active)
{
return sprintf(translateWithContext("Mod comparison", "Required: %(mods)s"),
{ "mods": modsToString(required) }
) + "\n" + sprintf(translateWithContext("Mod comparison", "Active: %(mods)s"),
{ "mods": modsToString(active) });
}