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 // Should 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; // Should 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"};
            };
        };
    };
};
You can’t perform that action at this time.