From 1b418db2e43c1210390b48744dbb16503bbf840a Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 31 Aug 2019 14:31:11 +0200 Subject: [PATCH 1/4] Fix VERSION_CONFIG version number API version should always be a number, while versionStr should be a string, no automatic conversions --- addons/main/script_macros_common.hpp | 8 +++++++- addons/main/script_mod.hpp | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/main/script_macros_common.hpp b/addons/main/script_macros_common.hpp index 18f33c785..c1d27c11a 100644 --- a/addons/main/script_macros_common.hpp +++ b/addons/main/script_macros_common.hpp @@ -51,16 +51,22 @@ #define MAINLOGIC main #endif +// TODO Document VERSION_CONFIG +// VERSION should always be a number (eg. float) #ifndef VERSION #define VERSION 0 #endif +#ifndef VERSION_STR + #define VERSION_STR VERSION +#endif + #ifndef VERSION_AR #define VERSION_AR VERSION #endif #ifndef VERSION_CONFIG - #define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION); versionAr[] = {VERSION_AR} + #define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION_STR); versionAr[] = {VERSION_AR} #endif #define ADDON DOUBLES(PREFIX,COMPONENT) diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 923bd0835..4d1f4e97d 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -5,8 +5,9 @@ // We will use the DATE for the BUILD# in the format YYMMDD - VM #include "script_version.hpp" -#define VERSION MAJOR.MINOR.PATCHLVL.BUILD -#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD +#define VERSION MAJOR.MINOR +#define VERSION_STR MAJOR.MINOR.PATCHLVL.BUILD +#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD // MINIMAL required version for the Mod. Components can specify others.. #define REQUIRED_VERSION 1.94 From 248c4e63b1ec3fa41367b7d37f3414bf3c64be30 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 2 Sep 2019 16:50:08 +0200 Subject: [PATCH 2/4] Read versionStr in help component, fall-back to version --- addons/help/XEH_preStart.sqf | 8 ++++++-- addons/xeh/config.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/help/XEH_preStart.sqf b/addons/help/XEH_preStart.sqf index 22eb8df47..80374eb7e 100644 --- a/addons/help/XEH_preStart.sqf +++ b/addons/help/XEH_preStart.sqf @@ -21,8 +21,12 @@ private _credits = []; private _version = ""; - if (isText (_x >> "version")) then { - _version = format [" v%1", getText (_x >> "version")]; + if (isText (_x >> "versionStr")) then { + _version = format [" v%1", getText (_x >> "versionStr")]; + } else { + if (isText (_x >> "version")) then { + _version = format [" v%1", getText (_x >> "version")]; + }; }; private _author = getText (_x >> "author") call CBA_fnc_sanitizeHTML; diff --git a/addons/xeh/config.cpp b/addons/xeh/config.cpp index acf0a946e..d9e06fba3 100644 --- a/addons/xeh/config.cpp +++ b/addons/xeh/config.cpp @@ -9,7 +9,7 @@ class CfgPatches { weapons[] = {}; requiredAddons[] = {"cba_common"}; requiredVersion = 0.1; - version = "4.0.0"; // Due to older mod versions requiring > 3,3,3 etc + version = 4.0; // Due to older mod versions requiring > 3,3,3 etc versionStr = "4.0.0"; versionAr[] = {4, 0, 0}; authors[] = {"Solus", "Killswitch", "commy2"}; From defdc09fd9d016c6188d435a973177b35d1a1849 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 6 Sep 2019 15:38:44 +0200 Subject: [PATCH 3/4] Document VERSION_CONFIG in macros file --- addons/main/script_macros_common.hpp | 38 ++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/addons/main/script_macros_common.hpp b/addons/main/script_macros_common.hpp index c1d27c11a..29b1e995c 100644 --- a/addons/main/script_macros_common.hpp +++ b/addons/main/script_macros_common.hpp @@ -51,8 +51,39 @@ #define MAINLOGIC main #endif -// TODO Document VERSION_CONFIG -// VERSION should always be a number (eg. float) +#define ADDON DOUBLES(PREFIX,COMPONENT) +#define MAIN_ADDON DOUBLES(PREFIX,main) + +/* ------------------------------------------- +Macro: VERSION_CONFIG + Define CBA Versioning System config entries. + + VERSION should be a floating-point number (1 separator). + VERSION_STR is a string representation of the version. + VERSION_AR is an array representation of the version. + + VERSION must always be defined, otherwise it is 0. + VERSION_STR and VERSION_AR default to VERSION if undefined. + +Parameters: + None + +Example: + (begin example) + #define VERSION 1.0 + #define VERSION_STR 1.0.1 + #define VERSION_AR 1,0,1 + + class CfgPatches { + class MyMod_main { + VERSION_CONFIG; + }; + }; + (end) + +Author: + ?, Jonpas +------------------------------------------- */ #ifndef VERSION #define VERSION 0 #endif @@ -69,9 +100,6 @@ #define VERSION_CONFIG version = VERSION; versionStr = QUOTE(VERSION_STR); versionAr[] = {VERSION_AR} #endif -#define ADDON DOUBLES(PREFIX,COMPONENT) -#define MAIN_ADDON DOUBLES(PREFIX,main) - /* ------------------------------------------- Group: Debugging ------------------------------------------- */ From 29c28fe10e5b0d879d3a24aa8828eef737d444f5 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 6 Sep 2019 16:12:51 +0200 Subject: [PATCH 4/4] Support number and text version as fall-back --- addons/help/XEH_preStart.sqf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/help/XEH_preStart.sqf b/addons/help/XEH_preStart.sqf index 80374eb7e..db4322040 100644 --- a/addons/help/XEH_preStart.sqf +++ b/addons/help/XEH_preStart.sqf @@ -24,8 +24,12 @@ private _credits = []; if (isText (_x >> "versionStr")) then { _version = format [" v%1", getText (_x >> "versionStr")]; } else { - if (isText (_x >> "version")) then { - _version = format [" v%1", getText (_x >> "version")]; + if (isNumber (_x >> "version")) then { + _version = format [" v%1", getNumber (_x >> "version")]; + } else { + if (isText (_x >> "version")) then { + _version = format [" v%1", getText (_x >> "version")]; + }; }; };