dragonfly/addons/db/functions/fnc_fetch.sqf
Jacob Schmidt ce98c86def
All checks were successful
Build / Build (push) Successful in 34s
(chore) Removed white space.
2026-01-13 20:30:08 -06:00

65 lines
1.7 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: dragonfly_db_fnc_fetch
* Author: Creedcoder, J.Schmidt
* Edit: 07.15.2024
*
* [Description]
* Receives DB response chunks, rebuilds the payload, and forwards it to the handler when complete.
*
* Arguments:
* 0: Unique request ID <STRING>
* 1: Function name to execute <STRING>
* 2: Chunk index <NUMBER>
* 3: Total chunk count <NUMBER>
* 4: Chunk data <STRING>
* 5: Callback identifier or code <STRING/CODE>
* 6: Network ID <STRING>
*
* Return Value:
* N/A
*
* Examples:
* Called by the DB extension; not intended for direct use.
*
* Public: Yes
*/
#ifdef __A3__DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_fetch' Input: %1", _this];
#endif
params ["_uniqueID", "_function", "_index", "_total", "_datachunk", "_call", "_netId"];
private _dataString = "";
private _index_array = [];
private _count_total = 0;
dragonfly_db_fetch_array pushBackUnique [_uniqueID, _function, _index, _total, _datachunk, _call, _netId];
_count_total = {
if (_uniqueID == _x select 0) then {
_index_array pushBackUnique [_x select 2, _x select 4];
true
} else {
false
}
} count dragonfly_db_fetch_array;
if (_count_total == _total) then {
_index_array sort true;
{
_dataString = _dataString + (_x select 1);
} forEach _index_array;
#ifdef __ARMA__DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_fetch' Data String: %1", _dataString];
#endif
[_uniqueID, _function, _call, (parseSimpleArray _dataString), _netId] call FUNC(handler);
dragonfly_db_fetch_array = dragonfly_db_fetch_array select {!((_x select 0) in [_uniqueID])};
};