Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set negative draw priority for Building Markers #733

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions addons/building_markers/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

if (isServer) then {
[QGVAR(set), LINKFUNC(set)] call CBA_fnc_addEventHandler;

addMissionEventHandler ["MarkerDeleted", {
params ["_marker"];

ampersand38 marked this conversation as resolved.
Show resolved Hide resolved
// Filter all non-ZEN markers
if !(QUOTE(ADDON) in _marker) exitWith {};

[_marker] call CBA_fnc_removeGlobalEventJIP;
[(_marker splitString "_" select -1) call BIS_fnc_objectFromNetId, false] call FUNC(set);
}];
};

if (hasInterface) then {
Expand Down
2 changes: 2 additions & 0 deletions addons/building_markers/functions/fnc_set.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ if (_set) then {
_marker setMarkerDir getDir _object;
_object setVariable [QGVAR(marker), _marker, true];

[QEGVAR(common,setMarkerDrawPriority), [_marker, -1], _marker] call CBA_fnc_globalEventJIP;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to handle removing the JIP event if the marker is deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should building markers be removable for other reasons than building deletion?
Do building markers remain global or should local changes be permitted?

If not, I imagine it's possible to replace the removed marker by detecting when a marker has been deleted with this EH:

  • You could add this EH on all clients and they would raise an event on the server which would handle the deletion or replacement of the marker, depending if the marker was deleted because the building was deleted or for another reason.
  • You could add this EH on the server only and have it deal with the marker deletion or replacement. This assumes that all building marker deletions would be global though.

If building markers should be removable, I guess the EH linked above still can be used, but it would be a bit more tricky: What if deleteMarkerLocal is used on building markers? Should the marker be replaced, so that you force people to use deleteMarker instead, or should the marker be editable on each client individually, as in permit different marker settings (existence, visibility, size, direction, etc)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one 3ea5c51
I don't think any mod can be so protective of its stuff.
What use case is there for building markers showing differently between clients?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one 3ea5c51 I don't think any mod can be so protective of its stuff. What use case is there for building markers showing differently between clients?

I agree that a mod shouldn't be that overprotective. As for the use case of building markers showing differently on clients, I don't really know, I'm not a mission maker. I was mostly thinking of how badly the marker system could/would break if you started messing with markers on a per client basis.

Copy link
Contributor

@rautamiekka rautamiekka May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, CBA_fnc_removeGlobalEventJIP can be told to wait for the object (in this case the marker) to be deleted before actually proceeding with deleting the JIP order, so this should work, adding some inherent sleep by spawn:

Suggested change
[QEGVAR(common,setMarkerDrawPriority), [_marker, -1], _marker] call CBA_fnc_globalEventJIP;
private _jipID = [QEGVAR(common,setMarkerDrawPriority), [_marker, -1], _marker] call CBA_fnc_globalEventJIP;
[_jipID, _marker] spawn CBA_fnc_removeGlobalEventJIP;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool indeed. It would probably need to be _object not _marker I think, looking at the params?

Copy link
Contributor

@rautamiekka rautamiekka May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I dunno; just interpreted this line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Delete marker when the object is deleted
private _eventID = _object addEventHandler ["Deleted", {
params ["_object"];
Expand Down
5 changes: 5 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@
_object setObjectScale _scale;
}] call CBA_fnc_addEventHandler;

[QGVAR(setMarkerDrawPriority), {
params ["_markerName", "_priority"];
_markerName setMarkerDrawPriority _priority;
}] call CBA_fnc_addEventHandler;

[QGVAR(setVehicleRadar), {
params ["_vehicle", "_mode"];
_vehicle setVehicleRadar _mode;
Expand Down
Loading