Skip to content

Commit

Permalink
Improve VERSION_CONFIG (#1221)
Browse files Browse the repository at this point in the history
* Fix VERSION_CONFIG version number API
version should always be a number, while versionStr should be a string, no automatic conversions

* Read versionStr in help component, fall-back to version

* Document VERSION_CONFIG in macros file

* Support number and text version as fall-back
  • Loading branch information
jonpas authored Sep 7, 2019
1 parent 8a94c03 commit 851b690
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
12 changes: 10 additions & 2 deletions addons/help/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ 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 (isNumber (_x >> "version")) then {
_version = format [" v%1", getNumber (_x >> "version")];
} else {
if (isText (_x >> "version")) then {
_version = format [" v%1", getText (_x >> "version")];
};
};
};

private _author = getText (_x >> "author") call CBA_fnc_sanitizeHTML;
Expand Down
42 changes: 38 additions & 4 deletions addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,55 @@
#define MAINLOGIC main
#endif

#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

#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)
#define MAIN_ADDON DOUBLES(PREFIX,main)

/* -------------------------------------------
Group: Debugging
------------------------------------------- */
Expand Down
5 changes: 3 additions & 2 deletions addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 851b690

Please sign in to comment.