dragonfly/addons/db/functions/fnc_processQueue.sqf
Jacob Schmidt 665561e29e
All checks were successful
Build / Build (push) Successful in 1m21s
feat(db): Implement hash deletion functions
This commit introduces functionality to delete hash values from the Dragonfly database. It includes two new functions: `hashDelete` for deleting a hash value by key, and `hashDeleteId` for deleting a hash value by both key and ID.

Key changes:

*   **`fnc_processQueue.sqf`:** Added cases for "hdel" and "hdelid" task types to process hash deletion requests, calling the corresponding `FUNC(hashDelete)` and `FUNC(hashDeleteId)` functions.
*   **`XEH_PREP.hpp`:** Added `PREP` definitions for `hashDelete` and `hashDeleteId` to enable event handlers for these functions.
2025-04-05 09:06:46 -05:00

181 lines
5.3 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: dragonfly_db_fnc_processQueue
* Author: Creedcoder, J.Schmidt
* Edit: 07.15.2024
* Copyright © 2024 Creedcoder, J.Schmidt, All rights reserved
*
* Do not edit without permission!
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, vist https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons,
* PO Box 1866, Mountain View, CA 94042
*
* [Description]
* Process queue of tasks.
*
* Arguments:
* N/A
*
* Return Value:
* N/A
*
* Examples:
* [] spawn dragonfly_db_fnc_processQueue (Server or Singleplayer Only)
* [] remoteExec ["dragonfly_db_fnc_processQueue", 2, false] (Multiplayer Only)
*
* Public: Yes
*/
GVAR(isProcessing) = true;
while { count GVAR(taskQueue) > 0} do {
private _task = GVAR(taskQueue) deleteAt 0;
private _taskType = _task select 0;
private _key = _task select 1;
private _keyField = _task select 2;
private _index = _task select 3;
private _value = _task select 4;
private _function = _task select 5;
private _call = _task select 6;
private _netId = _task select 7;
#ifdef __ARMA__DEBUG__
diag_log text format ["Initializing Task: %1", _task];
#endif
switch (_taskType) do {
case "get": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(get);
};
case "set": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(set);
};
case "del": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key] call FUNC(delete);
};
case "hget": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _function, _call, _netId] call FUNC(hashGet);
};
case "hgetid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _function, _call, _netId] call FUNC(hashGetId);
};
case "hgetall": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_function, _call, _netId] call FUNC(hashGetAll);
};
case "hgetallid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(hashGetAllId);
};
case "hset": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _value] call FUNC(hashSet);
};
case "hsetbulk": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetBulk);
};
case "hsetid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _value] call FUNC(hashSetId);
};
case "hsetidbulk": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetIdBulk);
};
case "hdel": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField] call FUNC(hashDelete);
};
case "hdelid": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField] call FUNC(hashDeleteId);
};
case "listadd": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(listAdd);
};
case "listidx": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _function, _call, _netId] call FUNC(listGet);
};
case "listrng": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(listLoad);
};
case "listrem": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index] call FUNC(listRemove);
};
case "listset": {
#ifdef __ARMA_DEBUG__
diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _value] call FUNC(listSet);
};
};
sleep 1;
};
GVAR(isProcessing) = false;