From 30ba80b516fa52c3db6e437f85ab2f127f63d2f1 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Mon, 4 Nov 2024 13:05:20 +0100 Subject: [PATCH] Tagging - Minor improvements (#228) * Tagging - Improve marker creation * Tagging - Improve color check performance * Tagging - Add support for yellow and white colors --- addons/common/functions/fnc_createPlayerMarker.sqf | 4 ++-- addons/tagging/XEH_postInit.sqf | 13 ++++++------- addons/tagging/script_component.hpp | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/common/functions/fnc_createPlayerMarker.sqf b/addons/common/functions/fnc_createPlayerMarker.sqf index ca552f23..4337ff56 100644 --- a/addons/common/functions/fnc_createPlayerMarker.sqf +++ b/addons/common/functions/fnc_createPlayerMarker.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: veteran29 - * Create player owned marker. + * Create player owned marker locally. * * Arguments: * 0: Marker position @@ -43,4 +43,4 @@ GVAR(playerMarkerIdx) = GVAR(playerMarkerIdx) + 1; private _markerId = format ["_USER_DEFINED #%1/%2/%3", getPlayerID _player, _id, _channel]; -createMarker [_markerId, _position, _channel, _player] // return +createMarkerLocal [_markerId, _position, _channel, _player] // return diff --git a/addons/tagging/XEH_postInit.sqf b/addons/tagging/XEH_postInit.sqf index f56adfb0..0eae99f2 100644 --- a/addons/tagging/XEH_postInit.sqf +++ b/addons/tagging/XEH_postInit.sqf @@ -9,17 +9,16 @@ if (hasInterface) then { // Check if tag created on building by local player if (!(_object isKindOf "Building") || {_unit isNotEqualTo player}) exitWith {}; - private _colorIndex = { - if (_texture find _x != -1) exitWith {_forEachIndex}; - -1 - } forEach TEXTURE_COLORS; + private _colorIndex = TEXTURE_COLORS findIf {toLower _texture find _x != -1}; // no matching color, do not create marker - if (_colorIndex == -1) exitWith {}; + if (_colorIndex == -1) exitWith { + WARNING_1("Unsupported tag color %1",_texture); + }; private _marker = [_object, "side", _unit] call EFUNC(common,createPlayerMarker); - _marker setMarkerShape "ICON"; - _marker setMarkerType "hd_dot"; + _marker setMarkerShapeLocal "ICON"; + _marker setMarkerTypeLocal "hd_dot"; _marker setMarkerColor (MARKER_COLORS select _colorIndex); }] call CBA_fnc_addEventHandler; diff --git a/addons/tagging/script_component.hpp b/addons/tagging/script_component.hpp index e57576dc..2dfd1bb2 100644 --- a/addons/tagging/script_component.hpp +++ b/addons/tagging/script_component.hpp @@ -13,5 +13,5 @@ #include "\z\afm\addons\main\script_macros.hpp" -#define MARKER_COLORS ["ColorRed", "ColorGreen", "ColorBlue", "ColorBlack"] -#define TEXTURE_COLORS ["red", "green", "blue", "black"] +#define MARKER_COLORS ["ColorRed", "ColorGreen", "ColorBlue", "ColorBlack", "ColorYellow", "ColorWhite"] +#define TEXTURE_COLORS ["red", "green", "blue", "black", "yellow", "white"]