mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 21:34:08 -07:00
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.
43 lines
1.2 KiB
JavaScript
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) });
|
|
}
|