Skip to content

Commit

Permalink
add default value for serializedNamespace (#1044)
Browse files Browse the repository at this point in the history
* add default value for serializedNamespace

* add RETNIL for default behaviour
  • Loading branch information
xetra11 authored and commy2 committed Jan 18, 2019
1 parent 85d9212 commit b75f68b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addons/hashes/fnc_serializeNamespace.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Description:
Parameters:
_namespace - a namespace <LOCATION, OBJECT>
_defaultValue - Default value. Used when key doesn't exist. A key is also removed from the hash if the value is set to this default [Any, defaults to nil]
Returns:
_hash - a hash <ARRAY>
Expand All @@ -22,9 +23,9 @@ Author:
---------------------------------------------------------------------------- */
SCRIPT(serializeNamespace);

params [["_namespace", locationNull, [locationNull, objNull]]];
params [["_namespace", locationNull, [locationNull, objNull]], "_defaultValue"];

private _hash = [] call CBA_fnc_hashCreate;
private _hash = [[], RETNIL(_defaultValue)] call CBA_fnc_hashCreate;

{
[_hash, _x, _namespace getVariable _x] call CBA_fnc_hashSet;
Expand Down

0 comments on commit b75f68b

Please sign in to comment.