Skip to content

Versioning System

jonpas edited this page Sep 6, 2019 · 7 revisions

Versioning System

The versioning system allows you to register your mod, including version.

In Multiplayer, the versions are compared between server and clients, and warnings are displayed when mismatches have been detected.

Implementation

Define the required macros and use them in CfgPatches section of MyMod's config.cpp

#define VERSION 1.0 // Must be a floating-point number (1 separator)
#define VERSION_STR 1.0.1 // Since CBA v3.13.0
#define VERSION_AR 1,0,1

class CfgPatches {
    class MyMod_main {
        VERSION_CONFIG;
    };
};

Or alternatively without macros:

class CfgPatches {
    class MyMod_main {
        version = 1.0; // Must be a floating-point number (1 separator)
        versionStr = "1.0.1";
        versionAr[] = {1, 0, 1};
    };
};

To register the mod with the CBA Versioning System:

class CfgSettings {
    class CBA {
        class Versioning {
            // This registers MyMod with the versioning system and looks for version info at CfgPatches -> MyMod_main
            class MyMod {
                // Optional: Manually specify the Main Addon for this mod
                main_addon = "MyModAddon";

                // Optional: Add a custom handler function triggered upon version mismatch
                // Make sure this function is compiled in preInit, not spawn/execVM
                handler = "myMod_fnc_mismatch";

                // Optional: Dependencies
                // Example: Dependency on CBA
                class Dependencies {
                    CBA[] = {"cba_main", {0, 8, 0}, "true"};
                };

                // Optional: Removed addons Upgrade registry
                // Example: myMod_addon1 was removed and it's important the user doesn't still have it loaded
                removed[] = {"myMod_addon1"};
            };
        };
    };
};

Shared version display (optional)

Aimed at saving space on the main menu. You find this at the Main menu, right-down. It cycles between version numbers for any mods added to the system.

Operation: Mouse over to temporarily pause cycling. Left click to cycle forward. Right click to cycle back. Double click to perform currently displayed mod's action, if any.

Implementation

  • versionDesc - String for Display Name. Add to the cycling display of mod names and versions on the main menu.
  • versionAct - String for Code, optional. Add a double click action using MouseButtonDblClick. Leave empty ("") or omit if not used.

Example CfgPatches entries from the ACE3 mod:

versionDesc = "ACE3";
versionAct = "call compile preprocessFileLineNumbers 'z\ace\addons\common\init_versionTooltip.sqf'";