From af255604ac098030613ab983a313e790dac2a02e Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 14 Apr 2015 21:17:36 +0200 Subject: [PATCH] Switched to event based sync system for open wounds --- addons/medical/XEH_postInit.sqf | 2 +- addons/medical/functions/fnc_handleDamage_wounds.sqf | 1 - .../medical/functions/fnc_onWoundUpdateRequest.sqf | 12 +++++------- addons/medical/functions/fnc_requestWoundSync.sqf | 4 ++-- addons/medical/script_component.hpp | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 1b0a38f1af..3743511790 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -247,7 +247,7 @@ if (USE_WOUND_EVENT_SYNC) then { // We are only pulling the wounds for the units in the player group. Anything else will come when the unit interacts with them. { [_x, _newPlayer] call FUNC(requestWoundSync); - }foreach units group player; + }foreach units group _newPlayer; }; }] call EFUNC(common,addEventhandler); }; diff --git a/addons/medical/functions/fnc_handleDamage_wounds.sqf b/addons/medical/functions/fnc_handleDamage_wounds.sqf index 5933651e57..b45a974166 100644 --- a/addons/medical/functions/fnc_handleDamage_wounds.sqf +++ b/addons/medical/functions/fnc_handleDamage_wounds.sqf @@ -133,7 +133,6 @@ if (count _woundsCreated > 0) then { }; if (USE_WOUND_EVENT_SYNC) then { - // TODO Should this be done in a single broadcast? // Broadcast the new injuries across the net in parts. One broadcast per injury. Prevents having to broadcast one massive array of injuries. { ["medical_propagateWound", [_unit, _x]] call EFUNC(common,globalEvent); diff --git a/addons/medical/functions/fnc_onWoundUpdateRequest.sqf b/addons/medical/functions/fnc_onWoundUpdateRequest.sqf index c160e47ea0..ccbb373648 100644 --- a/addons/medical/functions/fnc_onWoundUpdateRequest.sqf +++ b/addons/medical/functions/fnc_onWoundUpdateRequest.sqf @@ -1,11 +1,10 @@ /* * Author: Glowbal - * Enabled the vitals loop for a unit. + * Handles an wound update request. * * Arguments: * 0: The Unit - * 1: the last known ID - * 2: Origin object + * 1: Origin object * * ReturnValue: * @@ -14,12 +13,11 @@ */ #include "script_component.hpp" -private ["_unit", "_lastId", "_openWounds"]; +private ["_unit", "_openWounds"]; _unit = _this select 0; -_lastId = _this select 1; -_originOfrequest = _this select 2; +_originOfrequest = _this select 1; -if (local _unit) then { +if (local _unit && !(local _originOfrequest)) then { _openWounds = _unit getvariable [QGVAR(openWounds), []]; { ["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent); diff --git a/addons/medical/functions/fnc_requestWoundSync.sqf b/addons/medical/functions/fnc_requestWoundSync.sqf index bf6f881930..7144c49684 100644 --- a/addons/medical/functions/fnc_requestWoundSync.sqf +++ b/addons/medical/functions/fnc_requestWoundSync.sqf @@ -14,11 +14,11 @@ #include "script_component.hpp" -private [ "_target", "_caller", "_openWounds","_lastId"]; +private [ "_target", "_caller", "_openWounds"]; _target = _this select 0; _caller = _this select 1; if (local _target || GVAR(level) < 2) exitwith {}; // if the target is local, we already got the most update to date information if (_target getvariable [QGVAR(isWoundSynced), false]) exitwith {}; _target setvariable [QGVAR(isWoundSynced), true]; -["medical_woundUpdateRequest", [_target], [_target, _lastId, _caller]] call EFUNC(common,targetEvent); +["medical_woundUpdateRequest", [_target], [_target, _caller]] call EFUNC(common,targetEvent); diff --git a/addons/medical/script_component.hpp b/addons/medical/script_component.hpp index 939a811a41..bac6744bc1 100644 --- a/addons/medical/script_component.hpp +++ b/addons/medical/script_component.hpp @@ -11,4 +11,4 @@ #include "\z\ace\addons\main\script_macros.hpp" -#define USE_WOUND_EVENT_SYNC false +#define USE_WOUND_EVENT_SYNC true