Skip to content

Commit

Permalink
Merge pull request #1715 from CBATeam/getMacros
Browse files Browse the repository at this point in the history
Add `CBA_fnc_getMacro`
  • Loading branch information
PabstMirror authored Dec 14, 2024
2 parents ca68f5f + ad233fa commit 6986fd6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/common/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class CfgFunctions {
PATHTO_FNC(deleteNamespace);
PATHTO_FNC(allNamespaces);
PATHTO_FNC(directCall);
PATHTO_FNC(getMacro);
PATHTO_FNC(objectRandom);
PATHTO_FNC(execNextFrame);
PATHTO_FNC(execAfterNFrames);
Expand Down
44 changes: 44 additions & 0 deletions addons/common/fnc_getMacro.inc.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
switch (_this) do {
case "__DATE_ARR__": { [__DATE_ARR__] }; // [2024,11,10,16,19,39]
case "__DATE_STR__": { __DATE_STR__ }; // "2024/11/10, 16:19:39"
case "__DATE_STR_ISO8601__": { __DATE_STR_ISO8601__ }; // "2024-11-10T22:19:39Z"
case "__TIME__": { '__TIME__' }; // 16:19:39 (quoted because invalid number)
case "__TIME_UTC__": { '__TIME_UTC__' }; // 22:19:39
case "__TIMESTAMP_UTC__": { '__TIMESTAMP_UTC__' }; // 1731277179 (quoted because float will not have precision for 32+ bits)
case "__DAY__": { __DAY__ }; // 10
case "__MONTH__": { __MONTH__ }; // 11
case "__YEAR__": { __YEAR__ }; // 2024
case "__GAME_VER__": { '__GAME_VER__' }; // 2.18.152302 (quoted because invalid number)
case "__GAME_VER_MAJ__": { __GAME_VER_MAJ__ }; // 2
case "__GAME_VER_MIN__": { __GAME_VER_MIN__ }; // 18
case "__GAME_BUILD__": { __GAME_BUILD__ }; // 152302
case "__A3_DIAG__": {
#if __A3_DIAG__
true
#else
false
#endif
};
case "__A3_DEBUG__": {
#if __A3_DEBUG__
true
#else
false
#endif
};
case "__A3_EXPERIMENTAL__": {
#if __A3_EXPERIMENTAL__
true
#else
false
#endif
};
case "__A3_PROFILING__": {
#if __A3_PROFILING__
true
#else
false
#endif
};
default { "ERROR-invalid macro"};
}
25 changes: 25 additions & 0 deletions addons/common/fnc_getMacro.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_getMacro
Description:
Gets the value of special macros
Parameters:
0: Macro Name <STRING>
Returns:
None
Examples:
(begin example)
"__DATE_ARR__" call CBA_fnc_getMacro;
(end)
Author:
PabstMirror
---------------------------------------------------------------------------- */

params ["_macro"];

_macro call compileScript [QPATHTOF(fnc_getMacro.inc.sqf)]

0 comments on commit 6986fd6

Please sign in to comment.