cleanup, don't setVar public if no change

This commit is contained in:
PabstMirror 2016-01-14 16:21:47 -06:00
parent 9a3972de76
commit d2e006397d
3 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,6 @@
/*
* Author: PabstMirror
*
* Handles locality switch, runs a respawn check and then reapplies all effect events.
*
* Arguments:
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
@ -29,7 +29,7 @@ if !(GVAR(settingsInitFinished)) exitWith {
if (!_isLocal) exitWith {TRACE_1("object no longer local", _this)};
if (isNull _object) exitWith {TRACE_1("object null", _this)};
//Reset any variables because of respawn
//Reset any variables because of respawn
[_object, false] call FUNC(statusEffect_resetVariables);
//Send all Variables to client

View File

@ -1,6 +1,6 @@
/*
* Author: PabstMirror
*
* Resets all effect numbers to 0 when an object respawns (but does not apply the effect event).
*
* Arguments:
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>

View File

@ -1,6 +1,6 @@
/*
* Author: PabstMirror
* Adds or removes an id to a status effect and then updates the value
* Adds or removes an id to a status effect and will send an event to apply.
*
* Arguments:
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
@ -51,12 +51,18 @@ if ((_effectNumber == -1) && {!_set}) exitWith {
TRACE_2("Set False on nil array, exiting",_set,_effectNumber);
};
if (_effectNumber == -1) then {_effectNumber = 0};
if (_effectNumber == -1) then {_effectNumber = 0}; //reset (-1/nil) to 0
//if no change: skip sending publicVar and events
private _effectBoolArray = [_effectNumber, count _statusReasons] call FUNC(binarizeNumber);
TRACE_3("Setting New Value", _set, _statusIndex, _effectBoolArray);
TRACE_2("bitArray",_statusIndex,_effectBoolArray);
if (_set isEqualTo (_effectBoolArray select _statusIndex)) exitWith {
TRACE_2("No Change, exiting",_set,_effectBoolArray select _statusIndex);
};
TRACE_2("Setting to new value",_set,_effectBoolArray select _statusIndex);
_effectBoolArray set [_statusIndex, _set];
_effectNumber = _effectBoolArray call FUNC(toBitmask);
_effectNumber = _effectBoolArray call FUNC(toBitmask); //Convert array back to number
TRACE_2("Saving globaly",_effectVarName,_effectNumber);
_object setVariable [_effectVarName, _effectNumber, true];