-
Notifications
You must be signed in to change notification settings - Fork 150
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
Remove cba hash #1458
Open
commy2
wants to merge
5
commits into
master
Choose a base branch
from
remove-cba-hash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Remove cba hash #1458
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d37b5e
Ordered Dicts Macros
commy2 4bc018f
Replace CBA Hash in CBA_fnc_addPlayerAction
commy2 4cb711e
Replace CBA Hash in Versioning, Refactor Versioning
commy2 330542c
Merge branch 'master' of https://github.com/CBATeam/CBA_A3 into remov…
commy2 a0ac805
Optimize
commy2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#define DICT_CREATE [createHashMap, []] | ||
#define _DICT_MAP(D) ((D) select 0) | ||
#define _DICT_LIST(D) ((D) select 1) | ||
|
||
#define DICT_SET(D,k,v) (call {\ | ||
_DICT_MAP(D) set [k, v];\ | ||
_DICT_LIST(D) pushBackUnique (k) != -1\ | ||
}) | ||
|
||
#define DICT_GET(D,k) (_DICT_MAP(D) get (k)) | ||
#define DICT_GET_DEFAULT(D,k,d) (_DICT_MAP(D) getOrDefault [k, d]) | ||
#define DICT_POP(D,k) (_DICT_MAP(D) deleteAt (_DICT_LIST(D) deleteAt (_DICT_LIST(D) find (k)))) | ||
#define DICT_CONTAINS(D,k) ((k) in _DICT_MAP(D)) | ||
|
||
#define DICT_KEYS(D) (+ _DICT_LIST(D)) | ||
#define DICT_VALUES(D) (_DICT_LIST(D) apply {_DICT_MAP(D) get _x}) | ||
#define DICT_COUNT(D) (count _DICT_LIST(D)) | ||
|
||
// note, overwrites "_this" variable | ||
#define DICT_FOR_EACH(D) call {\ | ||
{\ | ||
private _y = DICT_GET(D, _x);\ | ||
call _this;\ | ||
} forEach DICT_KEYS(D);\ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
#endif | ||
|
||
#include "\x\cba\addons\main\script_macros.hpp" | ||
|
||
#include "orderedDicts.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include "script_component.hpp" | ||
|
||
SCRIPT(test_orderedDicts); | ||
|
||
// ---------------------------------------------------------------------------- | ||
#define DEBUG_MODE_FULL | ||
|
||
LOG("Testing Ordered Dicts"); | ||
|
||
// happy basic operations | ||
private _dict = DICT_CREATE; | ||
DICT_SET(_dict, "A", []); | ||
DICT_SET(_dict, "B", "x"); | ||
DICT_SET(_dict, "C", 1); | ||
|
||
private _result = DICT_GET(_dict, "A"); | ||
TEST_OP(_result,isEqualTo,[],"DICT_GET()/A"); | ||
|
||
_result = DICT_GET(_dict, "B"); | ||
TEST_OP(_result,==,"x","DICT_GET()/B"); | ||
|
||
_result = DICT_GET(_dict, "C"); | ||
TEST_OP(_result,==,1,"DICT_GET()/C"); | ||
|
||
_result = DICT_GET(_dict, "D"); | ||
TEST_TRUE(isNil "_result","DICT_GET()/missing"); | ||
|
||
DICT_SET(_dict, "A", objNull); | ||
_result = DICT_GET(_dict, "A"); | ||
TEST_TRUE(isNull _result,"DICT_GET()/overwrite"); | ||
|
||
_result = DICT_GET_DEFAULT(_dict, "B", ""); | ||
TEST_OP(_result,==,"x","DICT_GET_DEFAULT()/defined"); | ||
|
||
_result = DICT_GET_DEFAULT(_dict, "E", -2); | ||
TEST_OP(_result,==,-2,"DICT_GET_DEFAULT()/missing"); | ||
|
||
DICT_POP(_dict, "A"); | ||
_result = DICT_GET_DEFAULT(_dict, "A", west); | ||
TEST_OP(_result,isEqualType,sideEmpty,"DICT_GET_DEFAULT()/removed"); | ||
|
||
_result = DICT_POP(_dict, "B"); | ||
TEST_OP(_result,==,"x","DICT_POP()/return value"); | ||
|
||
_result = DICT_POP(_dict, "D"); | ||
TEST_TRUE(isNil "_result","DICT_POP()/missing"); | ||
|
||
_result = DICT_GET(_dict, "B"); | ||
TEST_TRUE(isNil "_result","DICT_GET()/already removed before"); | ||
|
||
DICT_SET(_dict, "B", 2); | ||
_result = DICT_GET_DEFAULT(_dict, "B", "x"); | ||
TEST_OP(_result,==,2,"DICT_GET_DEFAULT()/re-added"); | ||
|
||
_result = DICT_CONTAINS(_dict, "E"); | ||
TEST_FALSE(_result,"DICT_CONTAINS()/missing"); | ||
|
||
_result = DICT_CONTAINS(_dict, "A"); | ||
TEST_FALSE(_result,"DICT_CONTAINS()/removed"); | ||
|
||
DICT_SET(_dict, "A", 3); | ||
_result = DICT_GET_DEFAULT(_dict, "A", west); | ||
TEST_OP(_result,==,3,"DICT_GET_DEFAULT()/re-added"); | ||
|
||
_result = DICT_CONTAINS(_dict, "A"); | ||
TEST_TRUE(_result,"DICT_CONTAINS()/found"); | ||
|
||
_result = DICT_KEYS(_dict); | ||
#define EXPECTED ["C","B","A"] | ||
TEST_OP(_result,isEqualTo,EXPECTED,"DICT_KEYS()"); | ||
|
||
_result = DICT_VALUES(_dict); | ||
#define EXPECTED [1,2,3] | ||
TEST_OP(_result,isEqualTo,EXPECTED,"DICT_VALUES()"); | ||
|
||
_result = DICT_COUNT(_dict); | ||
TEST_OP(_result,==,3,"DICT_COUNT()"); | ||
|
||
_result = ""; | ||
{ | ||
_result = _result + format ["%1=%2;", _x, _y]; | ||
} DICT_FOR_EACH(_dict); | ||
TEST_OP(_result,==,"C=1;B=2;A=3;","DICT_FOR_EACH()"); | ||
|
||
|
||
// nasty evil edge-cases | ||
_dict = DICT_CREATE; | ||
DICT_SET(_dict, [], "value"); | ||
(DICT_KEYS(_dict) select 0) pushBack 1; | ||
_result = [1] in DICT_KEYS(_dict); // uses list | ||
TEST_FALSE(_result,"DICT array keys-list"); | ||
|
||
_result = DICT_CONTAINS(_dict, [1]); | ||
TEST_FALSE(_result,"DICT array keys-map"); | ||
|
||
DICT_SET(_dict, "key", []); | ||
DICT_GET(_dict, "key") pushBack 2; | ||
_result = DICT_GET(_dict, "key"); | ||
TEST_OP(_result,isEqualTo,[2],"DICT array values"); | ||
|
||
private _resultLeft = DICT_KEYS(_dict) select 0; | ||
_resultLeft pushBack 3; // [1,3] | ||
_result = DICT_KEYS(_dict) select 0; // [1] | ||
TEST_OP(_resultLeft,isNotEqualTo,_result,"DICT array keys modified"); | ||
|
||
_resultLeft = DICT_GET(_dict, "key"); | ||
_resultLeft pushBack 4; // [2,4] | ||
_result = DICT_GET(_dict, "key"); // [2,4] | ||
TEST_OP(_resultLeft,isEqualTo,_result,"DICT array values modified"); | ||
|
||
_dict = DICT_CREATE; | ||
DICT_SET(_dict, "key", nil); // key works, value set to nil w/o error | ||
DICT_SET(_dict, nil, "value"); // key fails silently, no additional value | ||
_result = str DICT_KEYS(_dict); | ||
TEST_OP(_result,==,"[""key""]","DICT nil keys"); | ||
|
||
_result = str DICT_VALUES(_dict); | ||
TEST_OP(_result,==,"[any]","DICT nil values"); | ||
|
||
_result = DICT_GET(_dict, nil); | ||
TEST_TRUE(isNil "_result","DICT nil values\DICT_GET"); | ||
|
||
_result = DICT_GET_DEFAULT(_dict, nil, 127); | ||
TEST_OP(_result,==,127,"DICT nil values\DICT_GET_DEFAULT"); | ||
|
||
_dict = DICT_CREATE; | ||
DICT_SET(_dict, "Key", true); | ||
_result = DICT_GET_DEFAULT(_dict, "keY", false); | ||
TEST_FALSE(_result,"DICT key case-sensitivity"); | ||
|
||
_result = "keY" in DICT_KEYS(_dict); | ||
TEST_FALSE(_result,"DICT key case-sensitivity-list"); | ||
|
||
_result = DICT_CONTAINS(_dict, "keY"); | ||
TEST_FALSE(_result,"DICT key case-sensitivity-map"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,87 @@ | ||
#include "script_component.hpp" | ||
|
||
if (SLX_XEH_MACHINE select 1) exitWith { LOG("WARNING: YOUR MACHINE WAS DETECTED AS SERVER INSTEAD OF CLIENT!") }; | ||
if (SLX_XEH_MACHINE select 1) exitWith { | ||
LOG("WARNING: YOUR MACHINE WAS DETECTED AS SERVER INSTEAD OF CLIENT!"); | ||
}; | ||
|
||
GVAR(versions_serv) = + GVAR(versions); // For latest versions | ||
GVAR(versions_server) = + GVAR(versions); // For legacy versions | ||
GVAR(versions_serv) = + GVAR(versions); // For latest versions | ||
GVAR(versions_server) = + GVAR(versions); // For legacy versions | ||
|
||
publicVariable QGVAR(versions_serv); | ||
publicVariable QGVAR(versions_server); // TODO: Deprecate? | ||
|
||
// Paranoid; yet pretty annoying gamebreaking issue :-) | ||
FUNC(paranoid) = { | ||
diag_log [diag_frameNo, diag_tickTime, time, _this, "WARNING: Some client seems to have overriden the versions array; please report to CBA devs!"]; | ||
diag_log [GVAR(versions), GVAR(versions_serv)]; | ||
if (isMultiplayer) then { | ||
GVAR(versions_serv) = + GVAR(versions); | ||
publicVariable QGVAR(versions_serv); | ||
QGVAR(versions_serv) addPublicVariableEventHandler { | ||
(_this select 1) call { | ||
diag_log [ | ||
diag_frameNo, diag_tickTime, time, _this, | ||
"WARNING: Some client seems to have overriden the versions array; please report to CBA devs!" | ||
]; | ||
|
||
diag_log [GVAR(versions), GVAR(versions_serv)]; | ||
|
||
if (isMultiplayer) then { | ||
GVAR(versions_serv) = + GVAR(versions); | ||
publicVariable QGVAR(versions_serv); | ||
}; | ||
}; | ||
}; | ||
|
||
QGVAR(versions_serv) addPublicVariableEventHandler { (_this select 1) call FUNC(paranoid) }; | ||
|
||
// Skip missing mod check if it is disabled. | ||
if (getNumber (configFile >> "CBA_disableMissingModCheck") == 1) exitWith {}; | ||
|
||
// Missing Modfolder check | ||
FUNC(handleMismatch) = { | ||
params ["_machine","_mod"]; | ||
[format["%1 - Not running! (Machine: %2)", _mod, _machine], QUOTE(COMPONENT), [CBA_display_ingame_warnings, true, true]] call CBA_fnc_debug; | ||
QGVAR(mismatch) addPublicVariableEventHandler { | ||
(_this select 1) call { | ||
params ["_machine", "_component"]; | ||
|
||
private _msg = format ["%1 - Not running! (Machine: %2)", _component, _machine]; | ||
[_msg, QUOTE(COMPONENT), [CBA_display_ingame_warnings, true, true]] call CBA_fnc_debug; | ||
}; | ||
}; | ||
|
||
QGVAR(mismatch) addPublicVariableEventHandler { (_this select 1) call FUNC(handleMismatch) }; | ||
|
||
private "_str"; | ||
_str = 'if(isServer)exitWith{};if (isNil "CBA_display_ingame_warnings") then { CBA_display_ingame_warnings = true; };LOG("cba_versioning_check");0 = objNull spawn { sleep 1; sleep 1; _func={GVAR(mismatch)=[format["%2 (%1)",name player, player],_this];publicVariable QGVAR(mismatch);_this spawn{_t=format["You are missing the following mod: %1",_this];diag_log text _t;sleep 2;if (CBA_display_ingame_warnings) then {player globalChat _t}}};'; | ||
[GVAR(versions_serv), { | ||
_cfg = (configFile >> "CfgSettings" >> "CBA" >> "Versioning" >> _key); | ||
_addon = if (isClass _cfg) then { if (isText (_cfg >> "main_addon")) then { getText (_cfg >> "main_addon") } else { _key + "_main" }; } else { _key + "_main" }; | ||
// TODO: Make sensitive to level, if -2, do not check for mod | ||
_str = _str + format['if !(isClass(configFile >> "CfgPatches" >> "%1"))exitWith{"%1" call _func};', _addon]; | ||
}] call CBA_fnc_hashEachPair; | ||
ADD(_str,"};"); | ||
(compile _str) remoteExecCall ["BIS_fnc_call", -2]; | ||
private _cfgVersioning = configFile >> "CfgSettings" >> "CBA" >> "Versioning"; | ||
private _components = []; | ||
|
||
{ | ||
private _config = _cfgVersioning >> _x; | ||
|
||
if (isClass _config && {isText (_config >> "main_addon")}) then { | ||
_components pushBack getText (_config >> "main_addon"); | ||
} else { | ||
_components pushBack (_x + "_main"); | ||
}; | ||
} forEach GVAR(versions_serv); | ||
|
||
[[_components], { | ||
if (!hasInterface) exitWith {}; | ||
params ["_components"]; | ||
|
||
LOG("cba_versioning_check"); | ||
|
||
if (isNil "CBA_display_ingame_warnings") then { | ||
CBA_display_ingame_warnings = true; | ||
}; | ||
|
||
private _showError = { | ||
params ["_component"]; | ||
|
||
sleep 2; | ||
GVAR(mismatch) = [format ["%2 (%1)", name player, player], _component]; | ||
publicVariable QGVAR(mismatch); | ||
|
||
private _msg = format ["You are missing the following mod: %1", _component]; | ||
diag_log text _msg; | ||
|
||
if (CBA_display_ingame_warnings) then { | ||
sleep 2; | ||
player globalChat _msg; | ||
}; | ||
}; | ||
|
||
{ | ||
if (!isClass (configFile >> "CfgPatches" >> _x)) exitWith { | ||
_x spawn _showError; | ||
}; | ||
} forEach _components; | ||
}] remoteExecCall ["BIS_fnc_call"]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semi-colon ... according to the test. The test is broken.