feat(db): Enhance debugging and fix NetId handling
All checks were successful
Build / Build (push) Successful in 30s

This commit enhances debugging capabilities and addresses issues related to NetId handling within the DragonflyDB system.

Key changes:

*   **Improved Debugging:** Added more detailed logging in `Utils.cs` to track data chunks and strings, improving the ability to diagnose issues.
*   **NetId Handling Fix:** Modified `fnc_handler.sqf` to correctly handle NetIds, including a fallback mechanism if the target object is null. This ensures that remote execution attempts don't fail silently.
*   **Function Examples:** Updated examples in `fnc_hashSetIdBulk.sqf` and `fnc_hashSetBulk.sqf` to correctly use array syntax for function calls.
*   **Simplified fetch.sqf:** Removed unecessary conversion of the _call variable.
*   **Binary Updates:** Updated the compiled DLL and SO files.
This commit is contained in:
Jacob Schmidt 2025-03-28 09:45:16 -05:00
parent b05c76edf2
commit 8c64bfe4a9
9 changed files with 60 additions and 27 deletions

Binary file not shown.

Binary file not shown.

View File

@ -52,9 +52,7 @@ if (_count_total == _total) then {
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_fetch' Data String: %1", _dataString];
#endif
private _callValue = (_call == "true");
[_uniqueID, _function, _callValue, (parseSimpleArray _dataString), _netId] call FUNC(handler);
[_uniqueID, _function, _call, (parseSimpleArray _dataString), _netId] call FUNC(handler);
dragonfly_db_fetch_array = dragonfly_db_fetch_array select {!((_x select 0) in [_uniqueID])};
};

View File

@ -32,7 +32,7 @@
* Public: Yes
*/
params [["_uniqueID", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_data", [], [[]]], ["_netId", nil, [""]]];
params [["_uniqueID", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_data", [], [[]]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_handler' UniqueID: '%1', Function: '%2', Call: '%3', Data: '%4', NetId: '%5'", _uniqueID, _function, _call, _data, _netId];
@ -44,10 +44,34 @@ if (_function == "" || count _data == 0) exitWith {
private _func = call compile format ["%1", _function];
if ((!isNil "_netId") and (_netId isNotEqualTo "")) then {
if (_netId != "") then {
private _target = objectFromNetId _netId;
if (_call) then { _data remoteExecCall [_function, _target, false]; } else { _data remoteExec [_function, _target, false]; };
if (!isNull _target) then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_handler' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_data remoteExecCall [_function, _target, false];
} else {
_data remoteExec [_function, _target, false];
};
} else {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_handler' NetId '%1' resolved to null object, using local execution", _netId];
#endif
if (_call) then {
_data call _func;
} else {
_data spawn _func;
};
};
} else {
if (_call) then { _data call _func; } else { _data spawn _func; };
if (_call) then {
_data call _func;
} else {
_data spawn _func;
};
};

View File

@ -22,8 +22,8 @@
* N/A
*
* Examples:
* ["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] call dragonfly_db_fnc_hashSetBulk (Server or Singleplayer Only)
* ["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] remoteExecCall ["dragonfly_db_fnc_hashSetBulk", 2, false] (Multiplayer Only)
* [["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]]] call dragonfly_db_fnc_hashSetBulk (Server or Singleplayer Only)
* [["loadout", [getUnitLoadout player], "position", [getPosASLVisual player]]] remoteExecCall ["dragonfly_db_fnc_hashSetBulk", 2, false] (Multiplayer Only)
*
* Public: Yes
*/

View File

@ -22,8 +22,8 @@
* N/A
*
* Examples:
* [getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] call dragonfly_db_fnc_hashSetIdBulk (Server or Singleplayer Only)
* [getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]] remoteExecCall ["dragonfly_db_fnc_hashSetIdBulk", 2, false] (Multiplayer Only)
* [[getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]]] call dragonfly_db_fnc_hashSetIdBulk (Server or Singleplayer Only)
* [[getPlayerUID player, "loadout", [getUnitLoadout player], "position", [getPosASLVisual player]]] remoteExecCall ["dragonfly_db_fnc_hashSetIdBulk", 2, false] (Multiplayer Only)
*
* Public: Yes
*/

View File

@ -50,25 +50,30 @@ namespace ArmaDragonflyClient
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"{data}", "debug");
Main.Log($"Single chunk data: {data}", "debug");
string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call.ToString().ToLower()},{data},\"{entity}\"]";
Main.Log($"{dataAsString}", "debug");
Main.Log($"Single chunk data string: {dataAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_handler", dataAsString);
}
else
{
if (!data.StartsWith('['))
if (!data.StartsWith('[') || !data.EndsWith(']'))
data = BuildArray(data);
Main.Log($"{data}", "debug");
Main.Log($"Single chunk data: {data}", "debug");
var chunks = SplitIntoChunks(data, bufferSize);
int totalChunks = chunks.Count;
for (int i = 0; i < chunks.Count; i++)
for (int chunkIndex = 0; chunkIndex < chunks.Count; chunkIndex++)
{
string escapedChunk = chunks[i].Replace("\"", "\"\"");
string callString = call ? "true" : "false";
string chunkAsString = $"[\"{uniqueId}\",\"{function}\",{i+1},{totalChunks},\"{escapedChunk}\",\"{callString}\",\"{entity}\"]";
string escapedChunkData = chunks[chunkIndex].Replace("\"", "\"\"");
string chunkAsString = $"[\"{uniqueId}\",\"{function}\",{chunkIndex+1},{totalChunks},\"{escapedChunkData}\",{call.ToString().ToLower()},\"{entity}\"]";
Main.Log($"Chunk {chunkIndex+1}/{totalChunks}: {chunkAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_fetch", chunkAsString);
}
}
@ -80,24 +85,30 @@ namespace ArmaDragonflyClient
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"{data}", "debug");
Main.Log($"Single chunk data: {data}", "debug");
string dataAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{data},\"{target}\"]";
Main.Log($"{dataAsString}", "debug");
Main.Log($"Single chunk data: {dataAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_pubSubHandler", dataAsString);
}
else
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"{data}", "debug");
Main.Log($"Single chunk data: {data}", "debug");
var chunks = SplitIntoChunks(data, bufferSize);
int totalChunks = chunks.Count;
for (int i = 0; i < chunks.Count; i++)
for (int chunkIndex = 0; chunkIndex < chunks.Count; chunkIndex++)
{
string escapedChunk = chunks[i].Replace("\"", "\"\"");
string chunkAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{i+1},{totalChunks},\"{escapedChunk}\",\"{target}\"]";
string escapedChunkData = chunks[chunkIndex].Replace("\"", "\"\"");
string chunkAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{chunkIndex+1},{totalChunks},\"{escapedChunkData}\",\"{target}\"]";
Main.Log($"Chunk {chunkIndex+1}/{totalChunks}: {chunkAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_pubSubFetch", chunkAsString);
}
}