Skip to content

Commit

Permalink
Update CBA macros to prevent bricking + other urgent fixes (#62)
Browse files Browse the repository at this point in the history
* Fix double return

* Delay equipment score check until arsenals are initialized

* CBA script macros update

* Ignore initSettings and fix macros in them

* Fix CUP_Loaded and RHS_Loaded
  • Loading branch information
3Mydlo3 authored Feb 1, 2024
1 parent 8154933 commit 3c274ae
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .hemtt/project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ author = "ArmaForces"

[version]
path = "addons/main/script_version.hpp"

[asc]
exclude = [
".inc.sqf"
]
2 changes: 1 addition & 1 deletion addons/civilian/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ADDON = false;
#include "XEH_PREP.hpp"

#include "initSettings.sqf"
#include "initSettings.inc.sqf"

// Killswitch
if (!EGVAR(common,enabled)) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "script_component.hpp"

[
QGVAR(initialCiviliansCount),
"SLIDER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ params ["_group"];
// Get all group vehicles
private _groupVehicles = units _group apply {_x getVariable [QGVAR(ownedVehicle), objNull]} select {!isNull _x};
_groupVehicles arrayIntersect _groupVehicles // return

_groupVehicles
5 changes: 3 additions & 2 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ GVAR(enabled) = ("SK" isEqualTo (getText (missionConfigFile >> "Header" >> "game

GVAR(ACE_Loaded) = isClass (configFile >> "CfgPatches" >> "ace_common");
GVAR(ACRE_Loaded) = isClass (configFile >> "CfgPatches" >> "acre_main");
GVAR(CUP_Loaded) = isClass (configFile >> "CfgPatches" >> "cup_common"); // Probably something else, not "cup_common"
GVAR(RHS_Loaded) = isClass (configFile >> "CfgPatches" >> "rhs_common"); // Same here
GVAR(AFFT_Loaded) = isClass (configFile >> "CfgPatches" >> "afft_main");
GVAR(CUP_Loaded) = isClass (configFile >> "CfgPatches" >> "CUP_Vehicles_Core");
GVAR(RHS_Loaded) = isClass (configFile >> "CfgPatches" >> "rhssaf_main_loadorder");

// Killswitch
if (!GVAR(enabled)) exitWith {};
Expand Down
2 changes: 1 addition & 1 deletion addons/equipment/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ADDON = false;
#include "XEH_PREP.hpp"

#include "initSettings.sqf"
#include "initSettings.inc.sqf"

// Killswitch
if (!EGVAR(common,enabled)) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "script_component.hpp"

[
QGVAR(equipmentPresetCustom),
"CHECKBOX",
Expand Down
2 changes: 1 addition & 1 deletion addons/killers/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ADDON = false;
#include "XEH_PREP.hpp"

#include "initSettings.sqf"
#include "initSettings.inc.sqf"

// Killswitch
if (!EGVAR(common,enabled)) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "script_component.hpp"

[
QGVAR(startPositionsCount),
"SLIDER",
Expand Down
8 changes: 4 additions & 4 deletions addons/main/script_version.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define MAJOR 1
#define MINOR 0
#define PATCH 0
#define BUILD 0
#define MAJOR 0
#define MINOR 95
#define PATCH 6
#define BUILD 20240201
2 changes: 1 addition & 1 deletion addons/markers/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ADDON = false;
#include "XEH_PREP.hpp"

#include "initSettings.sqf"
#include "initSettings.inc.sqf"

// Killswitch
if (!EGVAR(common,enabled)) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "script_component.hpp"

[
QGVAR(refreshRate),
"SLIDER",
Expand Down
4 changes: 3 additions & 1 deletion addons/police/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ if (isServer) then {
};

// Fill arsenal with starting items
call FUNC(equipmentScoreCheck);
[{GVAR(arsenals) isNotEqualTo []}, {
call FUNC(equipmentScoreCheck);
}] call CBA_fnc_waitUntilAndExecute;

// Event creating teleport actions to all police stations
[QGVAR(createTeleport), {
Expand Down
2 changes: 1 addition & 1 deletion addons/score/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ADDON = false;
#include "XEH_PREP.hpp"

#include "initSettings.sqf"
#include "initSettings.inc.sqf"

// Killswitch
if (!EGVAR(common,enabled)) exitWith {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "script_component.hpp"

[
QGVAR(killersScoreMax),
"SLIDER",
Expand Down
61 changes: 26 additions & 35 deletions include/x/cba/addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- Provide a solid structure that can be dynamic and easy editable (Which sometimes means we cannot adhere to Aim #1 ;-)
An example is the path that is built from defines. Some available in this file, others in mods and addons.
Follows Standard:
Follows Standard:
Object variables: PREFIX_COMPONENT
Main-object variables: PREFIX_main
Paths: MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\SCRIPTNAME.sqf
Expand All @@ -29,6 +29,10 @@
and include your mod's script_macros.hpp
In your scripts you can then include the addon's component.hpp with relative path)
use in subcomponents (subconfigs)
define SUBCOMPONENT and include parent component's script_component.hpp
currently only supported by SUBADDON, additional macros may be added in the future
TODO:
- Try only to use 1 string type " vs '
- Evaluate double functions, and simplification
Expand All @@ -54,6 +58,10 @@
#define ADDON DOUBLES(PREFIX,COMPONENT)
#define MAIN_ADDON DOUBLES(PREFIX,main)

#ifdef SUBCOMPONENT
#define SUBADDON DOUBLES(ADDON,SUBCOMPONENT)
#endif

/* -------------------------------------------
Macro: VERSION_CONFIG
Define CBA Versioning System config entries.
Expand Down Expand Up @@ -197,7 +205,7 @@ Macro: LOG()
------------------------------------------- */
#ifdef DEBUG_MODE_FULL

#define LOG(MESSAGE) LOG_SYS_FILELINENUMBERS('LOG',MESSAGE)
#define LOG(MESSAGE) LOG_SYS('LOG',MESSAGE)
#define LOG_1(MESSAGE,ARG1) LOG(FORMAT_1(MESSAGE,ARG1))
#define LOG_2(MESSAGE,ARG1,ARG2) LOG(FORMAT_2(MESSAGE,ARG1,ARG2))
#define LOG_3(MESSAGE,ARG1,ARG2,ARG3) LOG(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3))
Expand Down Expand Up @@ -265,7 +273,7 @@ Macro: WARNING()
------------------------------------------- */
#ifdef DEBUG_MODE_NORMAL

#define WARNING(MESSAGE) LOG_SYS_FILELINENUMBERS('WARNING',MESSAGE)
#define WARNING(MESSAGE) LOG_SYS('WARNING',MESSAGE)
#define WARNING_1(MESSAGE,ARG1) WARNING(FORMAT_1(MESSAGE,ARG1))
#define WARNING_2(MESSAGE,ARG1,ARG2) WARNING(FORMAT_2(MESSAGE,ARG1,ARG2))
#define WARNING_3(MESSAGE,ARG1,ARG2,ARG3) WARNING(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3))
Expand Down Expand Up @@ -304,7 +312,7 @@ Macro: ERROR()
Author:
Spooner
------------------------------------------- */
#define ERROR(MESSAGE) LOG_SYS_FILELINENUMBERS('ERROR',MESSAGE)
#define ERROR(MESSAGE) LOG_SYS('ERROR',MESSAGE)
#define ERROR_1(MESSAGE,ARG1) ERROR(FORMAT_1(MESSAGE,ARG1))
#define ERROR_2(MESSAGE,ARG1,ARG2) ERROR(FORMAT_2(MESSAGE,ARG1,ARG2))
#define ERROR_3(MESSAGE,ARG1,ARG2,ARG3) ERROR(FORMAT_3(MESSAGE,ARG1,ARG2,ARG3))
Expand Down Expand Up @@ -854,16 +862,13 @@ Macro: ISNILS()
#define COMPILE_FILE2(var1) COMPILE_FILE2_SYS('var1')
#define COMPILE_FILE2_CFG(var1) COMPILE_FILE2_CFG_SYS('var1')

#define COMPILE_SCRIPT(var1) compileScript ['PATHTO_SYS(PREFIX,COMPONENT_F,var1)']

#define VERSIONING_SYS(var1) class CfgSettings \
{ \
class CBA \
{ \
class Versioning \
{ \
class var1 \
{ \
}; \

#define VERSIONING_SYS(var1) class CfgSettings { \
class CBA { \
class Versioning { \
class var1 {}; \
}; \
}; \
};
Expand Down Expand Up @@ -1030,12 +1035,9 @@ Macro: PATHTO_FNC()
#define QQEFUNC(var1,var2) QUOTE(QEFUNC(var1,var2))

#ifndef PRELOAD_ADDONS
#define PRELOAD_ADDONS class CfgAddons \
{ \
class PreloadAddons \
{ \
class ADDON \
{ \
#define PRELOAD_ADDONS class CfgAddons { \
class PreloadAddons { \
class ADDON { \
list[]={ QUOTE(ADDON) }; \
}; \
}; \
Expand Down Expand Up @@ -1273,9 +1275,11 @@ Macro: xSTRING()
#define ELSTRING(var1,var2) QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2))
#define CSTRING(var1) QUOTE(TRIPLES($STR,ADDON,var1))
#define ECSTRING(var1,var2) QUOTE(TRIPLES($STR,DOUBLES(PREFIX,var1),var2))
#define SUBCSTRING(var1) QUOTE(TRIPLES($STR,SUBADDON,var1))

#define LLSTRING(var1) localize QUOTE(TRIPLES(STR,ADDON,var1))
#define LELSTRING(var1,var2) localize QUOTE(TRIPLES(STR,DOUBLES(PREFIX,var1),var2))
#define LSUBLSTRING(var1) localize QUOTE(TRIPLES(STR,SUBADDON,var1))
#endif


Expand Down Expand Up @@ -1812,9 +1816,9 @@ Macro: IS_ADMIN_LOGGED

/* -------------------------------------------
Macro: FILE_EXISTS
Check if a file exists on machines with interface
Check if a file exists
Reports "false" if the file does not exist and throws an error in RPT.
Reports "false" if the file does not exist.
Parameters:
FILE - Path to the file
Expand All @@ -1828,17 +1832,4 @@ Macro: FILE_EXISTS
Author:
commy2
------------------------------------------- */
#define FILE_EXISTS(FILE) (call {\
private _return = false;\
isNil {\
private _control = (uiNamespace getVariable ["RscDisplayMain", displayNull]) ctrlCreate ["RscHTML", -1];\
if (isNull _control) then {\
_return = loadFile (FILE) != "";\
} else {\
_control htmlLoad (FILE);\
_return = ctrlHTMLLoaded _control;\
ctrlDelete _control;\
};\
};\
_return\
})
#define FILE_EXISTS(FILE) (fileExists (FILE))

0 comments on commit 3c274ae

Please sign in to comment.