From 0b2d99b74bfa1fa9abc3372ae6687493c557d7f4 Mon Sep 17 00:00:00 2001 From: 3Mydlo3 Date: Thu, 21 Mar 2024 16:54:16 +0100 Subject: [PATCH] Improve debugging experience (#88) * Introduce DEV_DEBUG macro * Show civilians in vehicles as yellow in DEV_DEBUG * Log sideChat to RPT on server for easier troubleshooting * Disable DEV_DEBUG and add a comment * Change getNearesLocation log to TRACE to avoid spam in RPT * Fix macro issues with ',' --- addons/common/XEH_postInit.sqf | 8 ++++++++ addons/common/functions/fnc_getNearestLocation.sqf | 6 +++++- addons/main/script_mod.hpp | 4 ++++ addons/markers/functions/fnc_loop.sqf | 7 +++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 5b69bbd3..d6e4d125 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -8,6 +8,14 @@ if (isServer) then { [QGVAR(playMusicServer), { _this call FUNC(playMusicServer); }] call CBA_fnc_addEventHandler; + + // Log side chat messages to RPT for easier troubleshooting + [QGVAR(showSideChatMsg), { + params [["_side", sideEmpty], ["_msg", ""]]; + if (_msg isEqualTo "") exitWith {}; + private _sideText = if (_side isEqualTo sideEmpty) then { "ALL" } else { _side }; + INFO_2("(Side Chat) %1: %2",_sideText,_msg); + }] call CBA_fnc_addEventHandler; }; [QGVAR(showMessage), FUNC(showMessage)] call CBA_fnc_addEventHandler; diff --git a/addons/common/functions/fnc_getNearestLocation.sqf b/addons/common/functions/fnc_getNearestLocation.sqf index 0388cdd7..d465cba5 100644 --- a/addons/common/functions/fnc_getNearestLocation.sqf +++ b/addons/common/functions/fnc_getNearestLocation.sqf @@ -27,6 +27,10 @@ if (_pos isEqualType objNull) then { // Get nearest locations to object. private _locations = nearestLocations [_pos, GVAR(allLocationTypes), _searchRadius]; -diag_log format ["[AFSK] [COMMON] [getNearestLocation] Pos: %1, Location: %2", _pos, _locations param [0, locationNull]]; + +// Introduced so that there are no issues with ',' in TRACE macro. +#define GET_NEAREST_LOCATION _locations param [0, locationNull] +TRACE_2("(getNearestLocation) Pos: %1 Location: %2", _pos, GET_NEAREST_LOCATION); + // Select nearest location from array. _locations param [0, locationNull] diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index f2223363..238a201d 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -20,3 +20,7 @@ #else #define LINKFUNC(x) FUNC(x) #endif + +// Enables some debugging functionality. +// Should never be enabled during normal gameplay as it might reveal information! +// #define DEV_DEBUG diff --git a/addons/markers/functions/fnc_loop.sqf b/addons/markers/functions/fnc_loop.sqf index 76026596..a3e01783 100644 --- a/addons/markers/functions/fnc_loop.sqf +++ b/addons/markers/functions/fnc_loop.sqf @@ -23,6 +23,13 @@ _marker = [_civilian] call FUNC(createCivilianMarker); } else { _marker setMarkerPosLocal (position _civilian); +#ifdef DEV_DEBUG + if (vehicle _civilian isEqualTo _civilian) then { + _marker setMarkerColorLocal "ColorGreen"; + } else { + _marker setMarkerColorLocal "ColorUnknown"; + }; +#endif }; } foreach EGVAR(civilian,civilians);