Skip to content

Commit

Permalink
Improve debugging experience (#88)
Browse files Browse the repository at this point in the history
* 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 ','
  • Loading branch information
3Mydlo3 authored Mar 21, 2024
1 parent 1326641 commit 0b2d99b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion addons/common/functions/fnc_getNearestLocation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
4 changes: 4 additions & 0 deletions addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions addons/markers/functions/fnc_loop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0b2d99b

Please sign in to comment.