Switched to event based sync system for open wounds

This commit is contained in:
Glowbal
2015-04-14 21:17:36 +02:00
parent 0ae27d16c5
commit af255604ac
5 changed files with 9 additions and 12 deletions

View File

@ -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. // 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); [_x, _newPlayer] call FUNC(requestWoundSync);
}foreach units group player; }foreach units group _newPlayer;
}; };
}] call EFUNC(common,addEventhandler); }] call EFUNC(common,addEventhandler);
}; };

View File

@ -133,7 +133,6 @@ if (count _woundsCreated > 0) then {
}; };
if (USE_WOUND_EVENT_SYNC) 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. // 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); ["medical_propagateWound", [_unit, _x]] call EFUNC(common,globalEvent);

View File

@ -1,11 +1,10 @@
/* /*
* Author: Glowbal * Author: Glowbal
* Enabled the vitals loop for a unit. * Handles an wound update request.
* *
* Arguments: * Arguments:
* 0: The Unit <OBJECT> * 0: The Unit <OBJECT>
* 1: the last known ID <NUMBER> * 1: Origin object <OBJECT>
* 2: Origin object <OBJECT>
* *
* ReturnValue: * ReturnValue:
* <NIL> * <NIL>
@ -14,12 +13,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_lastId", "_openWounds"]; private ["_unit", "_openWounds"];
_unit = _this select 0; _unit = _this select 0;
_lastId = _this select 1; _originOfrequest = _this select 1;
_originOfrequest = _this select 2;
if (local _unit) then { if (local _unit && !(local _originOfrequest)) then {
_openWounds = _unit getvariable [QGVAR(openWounds), []]; _openWounds = _unit getvariable [QGVAR(openWounds), []];
{ {
["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent); ["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent);

View File

@ -14,11 +14,11 @@
#include "script_component.hpp" #include "script_component.hpp"
private [ "_target", "_caller", "_openWounds","_lastId"]; private [ "_target", "_caller", "_openWounds"];
_target = _this select 0; _target = _this select 0;
_caller = _this select 1; _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 (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 {}; if (_target getvariable [QGVAR(isWoundSynced), false]) exitwith {};
_target setvariable [QGVAR(isWoundSynced), true]; _target setvariable [QGVAR(isWoundSynced), true];
["medical_woundUpdateRequest", [_target], [_target, _lastId, _caller]] call EFUNC(common,targetEvent); ["medical_woundUpdateRequest", [_target], [_target, _caller]] call EFUNC(common,targetEvent);

View File

@ -11,4 +11,4 @@
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define USE_WOUND_EVENT_SYNC false #define USE_WOUND_EVENT_SYNC true